Changeset 901 for code/branches/core2/src/orxonox/core/NamespaceNode.cc
- Timestamp:
- Mar 19, 2008, 12:38:32 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/core/NamespaceNode.cc
r895 r901 49 49 std::set<NamespaceNode*> nodes; 50 50 51 if ( name == "")51 if ((name.size() == 0) || (name == "")) 52 52 { 53 53 nodes.insert(this); … … 56 56 { 57 57 unsigned int pos = name.find("::"); 58 std::string firstPart = name.substr(0, pos); 59 std::string secondPart = name.substr(pos + 2, std::string::npos); 58 std::string firstPart = name; 59 std::string secondPart; 60 61 if (pos != std::string::npos) 62 { 63 firstPart = name.substr(0, pos); 64 secondPart = name.substr(pos + 2, std::string::npos); 65 } 60 66 61 67 if (firstPart == "..") … … 64 70 { 65 71 COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", namespace is root." << std::endl; 72 nodes = this->getNodeRelative(secondPart); 73 } 74 else if (!this->parent_) 75 { 76 COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", no parent namespace set." << std::endl; 66 77 nodes = this->getNodeRelative(secondPart); 67 78 } … … 78 89 79 90 if ((*it).second->isHidden()) 91 { 80 92 COUT(2) << "Warning: Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << std::endl; 93 nodes.insert(this); 94 } 81 95 else 96 { 82 97 nodes = (*it).second->getNodeRelative(secondPart); 98 } 83 99 } 84 100 else 85 101 { 102 bool bFoundMatchingNamespace = false; 103 86 104 for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it) 87 105 { … … 90 108 std::set<NamespaceNode*> temp2 = (*it).second->getNodeRelative(secondPart); 91 109 nodes.insert(temp2.begin(), temp2.end()); 110 bFoundMatchingNamespace = true; 92 111 } 112 } 113 114 if (!bFoundMatchingNamespace) 115 { 116 COUT(2) << "Warning: No file included with name '" << firstPart.substr(1, std::string::npos) << "' at this part of the level file, using parent namespace instead." << std::endl; 117 nodes = this->getNodeRelative(secondPart); 93 118 } 94 119 } … … 113 138 return false; 114 139 } 140 141 std::string NamespaceNode::toString() const 142 { 143 std::string output = this->name_; 144 145 if (this->subnodes_.size() > 0) 146 { 147 output += " ("; 148 149 int i = 0; 150 for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); i++, ++it) 151 { 152 if (i > 0) 153 output += ", "; 154 155 output += (*it).second->toString(); 156 } 157 158 output += ")"; 159 } 160 161 return output; 162 } 163 164 std::string NamespaceNode::toString(const std::string& indentation) const 165 { 166 std::string output = (indentation + this->name_ + "\n"); 167 168 for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it) 169 output += (*it).second->toString(indentation + " "); 170 171 return output; 172 } 115 173 }
Note: See TracChangeset
for help on using the changeset viewer.