Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 19, 2008, 12:38:32 AM (16 years ago)
Author:
landauf
Message:

Namespaces are working now. I love this feature, can't stop playing with it :D

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/core/Namespace.cc

    r898 r901  
    4141
    4242        this->bAutogeneratedFileRootNamespace_ = false;
    43         this->bDeleteNamespaceNodesAfterDestruction_ = false;
     43        this->bRoot_ = false;
    4444        this->operator_ = "or";
    4545    }
     
    4747    Namespace::~Namespace()
    4848    {
    49         if (this->bDeleteNamespaceNodesAfterDestruction_)
     49        if (this->bRoot_)
    5050            for (std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)
    5151                delete (*it);
     
    7373            name.replace(pos, 1, " ");
    7474        SubString tokens(name, " ", "", false, '\\', '"', '\0', '\0', '\0');
    75         for (unsigned int i = 0; i < tokens.size(); i++)
     75        if (this->bRoot_)
    7676        {
    77             for (std::set<NamespaceNode*>::iterator it = this->getNamespace()->representingNamespaces_.begin(); it != this->getNamespace()->representingNamespaces_.end(); ++it)
     77            this->representingNamespaces_.insert(new NamespaceNode(this->getName()));
     78        }
     79        else
     80        {
     81            for (unsigned int i = 0; i < tokens.size(); i++)
    7882            {
    79                 std::set<NamespaceNode*> temp = (*it)->getNodeRelative(tokens[i]);
    80                 this->representingNamespaces_.insert(temp.begin(), temp.end());
     83                for (std::set<NamespaceNode*>::iterator it = this->getNamespace()->representingNamespaces_.begin(); it != this->getNamespace()->representingNamespaces_.end(); ++it)
     84                {
     85                    std::set<NamespaceNode*> temp = (*it)->getNodeRelative(tokens[i]);
     86                    this->representingNamespaces_.insert(temp.begin(), temp.end());
     87                }
    8188            }
    8289        }
     
    138145        return false;
    139146    }
     147
     148    std::string Namespace::toString() const
     149    {
     150        std::string output;
     151
     152        int i = 0;
     153        for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
     154        {
     155            if (i > 0)
     156                output += " / ";
     157
     158            output += (*it)->toString();
     159        }
     160
     161        return output;
     162    }
     163
     164    std::string Namespace::toString(const std::string& indentation) const
     165    {
     166        std::string output;
     167
     168        int i = 0;
     169        for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
     170        {
     171            if (i > 0)
     172                output += "\n";
     173
     174            output += (*it)->toString(indentation);
     175        }
     176
     177        return output;
     178    }
    140179}
Note: See TracChangeset for help on using the changeset viewer.