Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 27, 2009, 2:30:06 AM (14 years ago)
Author:
rgrieder
Message:

Replaced "=" with " = " in our ini files for the config value.
Also made some changes to have const std::string& forwarding with getValue().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/ConfigFileManager.h

    r6417 r6425  
    5858
    5959    _CoreExport bool config(const std::string& classname, const std::string& varname, const std::string& value); // tolua_export
    60     _CoreExport std::string getConfig(const std::string& classname, const std::string& varname); // tolua_export
     60    _CoreExport const std::string& getConfig(const std::string& classname, const std::string& varname); // tolua_export
    6161    _CoreExport bool tconfig(const std::string& classname, const std::string& varname, const std::string& value);
    6262    _CoreExport void reloadConfig();
     
    7474            virtual ~ConfigFileEntry() {};
    7575            virtual void setValue(const std::string& value) = 0;
    76             virtual std::string getValue() const = 0;
     76            virtual const std::string& getValue() const = 0;
    7777            virtual const std::string& getName() const = 0;
    7878            virtual void setComment(const std::string& comment) = 0;
    7979            virtual unsigned int getIndex() const { return 0; }
    8080            virtual void setString(bool bString) = 0;
    81             virtual std::string getFileEntry() const = 0;
     81            virtual const std::string& getFileEntry() const = 0;
    8282    };
    8383
     
    9494                , bString_(bString)
    9595                , additionalComment_(additionalComment)
    96                 {}
     96                { this->update(); }
     97
    9798            inline virtual ~ConfigFileEntryValue() {}
    9899
     
    101102
    102103            inline virtual void setComment(const std::string& comment)
    103                 { this->additionalComment_ = comment; }
    104 
    105             virtual void setValue(const std::string& value);
    106             virtual std::string getValue() const;
    107 
    108             inline bool isString() const
    109                 { return this->bString_; }
    110             inline void setString(bool bString)
    111                 { this->bString_ = bString; }
    112 
    113             virtual std::string getFileEntry() const;
     104                { this->additionalComment_ = comment; this->update(); }
     105
     106            inline virtual void setValue(const std::string& value)
     107                { this->value_ = value; this->update(); }
     108            inline virtual const std::string& getValue() const
     109                { return this->value_; }
     110
     111            inline void virtual setString(bool bString)
     112                { this->bString_ = bString; this->update(); }
     113
     114            inline virtual const std::string& getFileEntry() const
     115                { return this->fileEntry_; }
     116
     117            inline virtual const std::string& getKeyString() const
     118                { return this->name_; }
    114119
    115120        protected:
    116             std::string name_;
     121            virtual void update();
     122
     123            const std::string name_;
    117124            std::string value_;
     125            std::string additionalComment_;
     126            std::string fileEntry_;
    118127            bool bString_;
    119             std::string additionalComment_;
    120     };
    121 
    122 
    123     ///////////////////////////////
     128    };
     129
     130
     131    ////////////////////////////////
    124132    // ConfigFileEntryVectorValue //
    125     ///////////////////////////////
     133    ////////////////////////////////
    126134    class _CoreExport ConfigFileEntryVectorValue : public ConfigFileEntryValue
    127135    {
    128136        public:
    129             inline ConfigFileEntryVectorValue(const std::string& name, unsigned int index, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") : ConfigFileEntryValue(name, value, bString, additionalComment), index_(index) {}
    130             inline virtual ~ConfigFileEntryVectorValue() {}
    131 
    132             inline virtual unsigned int getIndex() const
     137            inline ConfigFileEntryVectorValue(const std::string& name, unsigned int index, const std::string& value = "", bool bString = false, const std::string& additionalComment = "")
     138                : ConfigFileEntryValue(name, value, bString, additionalComment)
     139                , index_(index)
     140                { this->update(); /*No virtual calls in base class ctor*/ }
     141
     142            inline ~ConfigFileEntryVectorValue() {}
     143
     144            inline unsigned int getIndex() const
    133145                { return this->index_; }
    134146
    135             virtual std::string getFileEntry() const;
    136 
    137         private:
     147            inline const std::string& getKeyString() const
     148                { return this->keyString_; }
     149
     150        private:
     151            void update();
     152
    138153            unsigned int index_;
     154            std::string keyString_;
    139155    };
    140156
     
    157173            inline virtual void setValue(const std::string& value)
    158174                {}
    159             inline virtual std::string getValue() const
     175            inline virtual const std::string& getValue() const
     176                { return BLANKSTRING; }
     177
     178            inline void setString(bool bString)
     179                {}
     180
     181            inline virtual const std::string& getFileEntry() const
    160182                { return this->comment_; }
    161183
    162             inline void setString(bool bString) {}
    163 
    164             inline virtual std::string getFileEntry() const
    165                 { return this->comment_; }
     184            inline virtual const std::string& getKeyString() const
     185                { return BLANKSTRING; }
    166186
    167187        private:
     
    193213            inline void setValue(const std::string& name, const std::string& value, bool bString)
    194214                { this->getEntry(name, value, bString)->setValue(value); }
    195             inline std::string getValue(const std::string& name, const std::string& fallback, bool bString)
     215            inline const std::string& getValue(const std::string& name, const std::string& fallback, bool bString)
    196216                { return this->getEntry(name, fallback, bString)->getValue(); }
    197217
    198218            inline void setValue(const std::string& name, unsigned int index, const std::string& value, bool bString)
    199219                { this->getEntry(name, index, value, bString)->setValue(value); }
    200             inline std::string getValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     220            inline const std::string& getValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
    201221                { return this->getEntry(name, index, fallback, bString)->getValue(); }
    202222
     
    252272            inline void setValue(const std::string& section, const std::string& name, const std::string& value, bool bString)
    253273                { this->getSection(section)->setValue(name, value, bString); this->save(); }
    254             inline std::string getValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
     274            inline const std::string& getValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
    255275                { const std::string& output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; }
    256276
    257277            inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
    258278                { this->getSection(section)->setValue(name, index, value, bString); this->save(); }
    259             inline std::string getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     279            inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
    260280                { const std::string& output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; }
    261281
     
    304324            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& value, bool bString)
    305325                { this->getFile(type)->setValue(section, name, value, bString); }
    306             inline std::string getValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& fallback, bool bString)
     326            inline const std::string& getValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& fallback, bool bString)
    307327                { return this->getFile(type)->getValue(section, name, fallback, bString); }
    308328
    309329            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
    310330                { this->getFile(type)->setValue(section, name, index, value, bString); }
    311             inline std::string getValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     331            inline const std::string& getValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
    312332                { return this->getFile(type)->getValue(section, name, index, fallback, bString); }
    313333
Note: See TracChangeset for help on using the changeset viewer.