Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 14, 2008, 12:48:25 AM (16 years ago)
Author:
landauf
Message:

config-value accepts now strings with special chars like \n or \t and hopefully every other. strings are enclosed by "…", but the quotes are only visible in the config-file. if you want something like " ← whitespace" you must add quotes, otherwise this would be stripped to "← whitespace".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/core/ConfigFileManager.h

    r1030 r1049  
    6363        public:
    6464            virtual void setValue(const std::string& value) = 0;
    65             virtual const std::string& getValue() const = 0;
     65            virtual std::string getValue() const = 0;
    6666            virtual const std::string& getName() const = 0;
    6767            virtual void setComment(const std::string& comment) = 0;
    6868            virtual unsigned int getIndex() const { return 0; }
     69            virtual void setString(bool bString) = 0;
    6970            virtual std::string getFileEntry() const = 0;
    7071    };
     
    7778    {
    7879        public:
    79             inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", const std::string& additionalComment = "") : name_(name), value_(value), additionalComment_(additionalComment), bString_(false) {}
     80            inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") : name_(name), value_(value), bString_(bString), additionalComment_(additionalComment) {}
    8081            inline virtual ~ConfigFileEntryValue() {}
    8182
     
    8687                { this->additionalComment_ = comment; }
    8788
    88             inline virtual void setValue(const std::string& value)
    89                 { this->value_ = value; }
    90             inline virtual const std::string& getValue() const
    91                 { return this->value_; }
     89            virtual void setValue(const std::string& value);
     90            virtual std::string getValue() const;
    9291
    9392            inline bool isString() const
     
    101100            std::string name_;
    102101            std::string value_;
     102            bool bString_;
    103103            std::string additionalComment_;
    104             bool bString_;
    105104    };
    106105
     
    112111    {
    113112        public:
    114             inline ConfigFileEntryVectorValue(const std::string& name, unsigned int index, const std::string& value = "", const std::string& additionalComment = "") : ConfigFileEntryValue(name, value, additionalComment), index_(index) {}
     113            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) {}
    115114            inline virtual ~ConfigFileEntryVectorValue() {}
    116115
     
    142141            inline virtual void setValue(const std::string& value)
    143142                {}
    144             inline virtual const std::string& getValue() const
     143            inline virtual std::string getValue() const
    145144                { return this->comment_; }
     145
     146            inline void setString(bool bString) {}
    146147
    147148            inline virtual std::string getFileEntry() const
     
    170171                { this->additionalComment_ = comment; }
    171172
    172             inline void setValue(const std::string& name, const std::string& value)
    173                 { this->getEntry(name, value)->setValue(value); }
    174             inline const std::string& getValue(const std::string& name, const std::string& fallback)
    175                 { return this->getEntry(name, fallback)->getValue(); }
    176 
    177             inline void setValue(const std::string& name, unsigned int index, const std::string& value)
    178                 { this->getEntry(name, index, value)->setValue(value); }
    179             inline const std::string& getValue(const std::string& name, unsigned int index, const std::string& fallback)
    180                 { return this->getEntry(name, index, fallback)->getValue(); }
     173            inline void setValue(const std::string& name, const std::string& value, bool bString)
     174                { this->getEntry(name, value, bString)->setValue(value); }
     175            inline std::string getValue(const std::string& name, const std::string& fallback, bool bString)
     176                { return this->getEntry(name, fallback, bString)->getValue(); }
     177
     178            inline void setValue(const std::string& name, unsigned int index, const std::string& value, bool bString)
     179                { this->getEntry(name, index, value, bString)->setValue(value); }
     180            inline std::string getValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     181                { return this->getEntry(name, index, fallback, bString)->getValue(); }
    181182
    182183            void deleteVectorEntries(const std::string& name, unsigned int startindex = 0);
     
    193194                { return this->entries_.end(); }
    194195
    195             std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, const std::string& fallback = "");
    196             std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback = "");
    197 
    198             inline ConfigFileEntry* getEntry(const std::string& name, const std::string& fallback)
    199                 { return (*this->getEntryIterator(name, fallback)); }
    200             inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index, const std::string& fallback)
    201                 { return (*this->getEntryIterator(name, index, fallback)); }
     196            std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, const std::string& fallback, bool bString);
     197            std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString);
     198
     199            inline ConfigFileEntry* getEntry(const std::string& name, const std::string& fallback, bool bString)
     200                { return (*this->getEntryIterator(name, fallback, bString)); }
     201            inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     202                { return (*this->getEntryIterator(name, index, fallback, bString)); }
    202203
    203204            std::string name_;
     
    221222            void clean(bool bCleanComments = false);
    222223
    223             inline void setValue(const std::string& section, const std::string& name, const std::string& value)
    224                 { this->getSection(section)->setValue(name, value); this->save(); }
    225             inline const std::string& getValue(const std::string& section, const std::string& name, const std::string& fallback)
    226                 { const std::string& output = this->getSection(section)->getValue(name, fallback); this->saveIfUpdated(); return output; }
    227 
    228             inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value)
    229                 { this->getSection(section)->setValue(name, index, value); this->save(); }
    230             inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback)
    231                 { const std::string& output = this->getSection(section)->getValue(name, index, fallback); this->saveIfUpdated(); return output; }
     224            inline void setValue(const std::string& section, const std::string& name, const std::string& value, bool bString)
     225                { this->getSection(section)->setValue(name, value, bString); this->save(); }
     226            inline std::string getValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
     227                { std::string output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; }
     228
     229            inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
     230                { this->getSection(section)->setValue(name, index, value, bString); this->save(); }
     231            inline std::string getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     232                { std::string output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; }
    232233
    233234            inline void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0)
     
    264265            void clean(ConfigFileType type, bool bCleanComments = false);
    265266
    266             inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& value)
    267                 { this->getFile(type)->setValue(section, name, value); }
    268             inline const std::string& getValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& fallback)
    269                 { return this->getFile(type)->getValue(section, name, fallback); }
    270 
    271             inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& value)
    272                 { this->getFile(type)->setValue(section, name, index, value); }
    273             inline const std::string& getValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& fallback)
    274                 { return this->getFile(type)->getValue(section, name, index, fallback); }
     267            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& value, bool bString)
     268                { this->getFile(type)->setValue(section, name, value, bString); }
     269            inline std::string getValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& fallback, bool bString)
     270                { return this->getFile(type)->getValue(section, name, fallback, bString); }
     271
     272            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
     273                { this->getFile(type)->setValue(section, name, index, value, bString); }
     274            inline std::string getValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     275                { return this->getFile(type)->getValue(section, name, index, fallback, bString); }
    275276
    276277            inline void deleteVectorEntries(ConfigFileType type, const std::string& section, const std::string& name, unsigned int startindex = 0)
Note: See TracChangeset for help on using the changeset viewer.