Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2539


Ignore:
Timestamp:
Dec 28, 2008, 7:32:17 PM (15 years ago)
Author:
rgrieder
Message:

XML Attribute are case insensitive now. However this does not applay to tags since they refer to actual classes, which are case sensitive.

Location:
code/branches/presentation/src/core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/core/BaseObject.cc

    r2485 r2539  
    6161        this->oldGametype_ = 0;
    6262
     63        this->lastLoadedXMLElement_ = 0;
     64
    6365        this->functorSetMainState_ = 0;
    6466        this->functorGetMainState_ = 0;
  • code/branches/presentation/src/core/BaseObject.h

    r2485 r2539  
    6262    class _CoreExport BaseObject : virtual public OrxonoxClass
    6363    {
     64        template <class T> friend class XMLPortClassParamContainer;
     65
    6466        public:
    6567            BaseObject(BaseObject* creator);
     
    173175
    174176        protected:
    175             std::string name_;                          //!< The name of the object
    176             std::string oldName_;                       //!< The old name of the object
    177             mbool       bActive_;                       //!< True = the object is active
    178             mbool       bVisible_;                      //!< True = the object is visible
     177            std::string name_;                                 //!< The name of the object
     178            std::string oldName_;                              //!< The old name of the object
     179            mbool       bActive_;                              //!< True = the object is active
     180            mbool       bVisible_;                             //!< True = the object is visible
    179181            std::string mainStateName_;
    180182            Functor*    functorSetMainState_;
     
    185187            Template* getTemplate(unsigned int index) const;
    186188
    187             bool                   bInitialized_;         //!< True if the object was initialized (passed the object registration)
    188             const XMLFile*         file_;                 //!< The XMLFile that loaded this object
    189             std::string            loaderIndentation_;    //!< Indentation of the debug output in the Loader
     189            bool                   bInitialized_;              //!< True if the object was initialized (passed the object registration)
     190            const XMLFile*         file_;                      //!< The XMLFile that loaded this object
     191            Element*               lastLoadedXMLElement_;      //!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map
     192            std::map<std::string, std::string> xmlAttributes_; //!< Lowercase XML attributes
     193            std::string            loaderIndentation_;         //!< Indentation of the debug output in the Loader
    190194            Namespace*             namespace_;
    191195            BaseObject*            creator_;
  • code/branches/presentation/src/core/XMLIncludes.h

    r2500 r2539  
    6464namespace orxonox
    6565{
    66     typedef ticpp::Document Document;
    67     typedef ticpp::Element Element;
    68     typedef ticpp::Declaration Declaration;
    69     typedef ticpp::StylesheetReference StylesheetReference;
    70     typedef ticpp::Text Text;
    71     typedef ticpp::Comment Comment;
    72     typedef ticpp::Attribute Attribute;
     66    using ticpp::Document;
     67    using ticpp::Element;
     68    using ticpp::Declaration;
     69    using ticpp::StylesheetReference;
     70    using ticpp::Text;
     71    using ticpp::Comment;
     72    using ticpp::Attribute;
    7373}
  • code/branches/presentation/src/core/XMLPort.h

    r2536 r2539  
    182182        ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \
    183183    } \
    184     containername->port((BaseObject*)this, object, xmlelement, mode)
     184    containername->port(static_cast<BaseObject*>(this), object, xmlelement, mode)
    185185
    186186// --------------------
     
    360360            XMLPortParamContainer& port(BaseObject* owner, T* object, Element& xmlelement, XMLPort::Mode mode)
    361361            {
     362                OrxAssert(owner, "XMLPortParamContainer must have a BaseObject as owner.");
    362363                this->owner_ = owner;
    363364                this->parseParams_.object = object;
     
    369370                    try
    370371                    {
    371                         std::string attribute = xmlelement.GetAttribute(this->paramname_);
    372                         if ((attribute.size() > 0) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet()))
     372                        if (this->owner_->lastLoadedXMLElement_ != &xmlelement)
     373                        {
     374                            this->owner_->xmlAttributes_.clear();
     375                            // Iterate through the attributes manually in order to make them case insensitive
     376                            Attribute* attribute = xmlelement.FirstAttribute(false);
     377                            while (attribute != 0)
     378                            {
     379                                this->owner_->xmlAttributes_[getLowercase(attribute->Name())] = attribute->Value();
     380                                attribute = attribute->Next(false);
     381                            }
     382                            this->owner_->lastLoadedXMLElement_ = &xmlelement;
     383                        }
     384                        std::map<std::string, std::string>::const_iterator it = this->owner_->xmlAttributes_.find(getLowercase(this->paramname_));
     385                        std::string attributeValue("");
     386                        if (it != this->owner_->xmlAttributes_.end())
     387                            attributeValue = it->second;
     388
     389                        // TODO: Checking the iterator would be better since then we can have strings with value "" as well.
     390                        //       Unfortunately this does not seem to work with the Executor parser yet.
     391                        if ((!attributeValue.empty()) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet()))
    373392                        {
    374393                            COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
    375                             if (this->loadexecutor_->parse(object, attribute, ",") || (mode  == XMLPort::ExpandObject))
     394                            if (this->loadexecutor_->parse(object, attributeValue, ",") || (mode  == XMLPort::ExpandObject))
    376395                                this->parseResult_ = PR_finished;
    377396                            else
Note: See TracChangeset for help on using the changeset viewer.