Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 12, 2008, 3:34:55 PM (17 years ago)
Author:
landauf
Message:

extracted all config-value related macros from CoreIncludes.h and moved them to ConfigValueIncludes.h.

ConfigValueContainer can now handle std::vector<x> where 'x' is is any type supported by MultiTypeMath (all primitives, pointer, string, vector2, vector3, quaternion, colourvalue, radian, degree).

the vectors size is currently limited to 256 elements. this is just a practical limit, it can be raised if it's necessary. the reason for the limit is: you can add new elements to a vector by simply typing 'set classname varname index value' into the console or adding a new entry in the config-file. if 'index' is bigger than the vectors size, all elements up to 'index' are inserted. if the user accidentally enters a big number, he could end up with >4*109 elements in his config-file, resulting in 10-100gb on the hdd and a completely filled memory. and that's not exactly what i want ;)

File:
1 edited

Legend:

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

    r1027 r1030  
    107107
    108108    ///////////////////////////////
    109     // ConfigFileEntryArrayValue //
     109    // ConfigFileEntryVectorValue //
    110110    ///////////////////////////////
    111     class _CoreExport ConfigFileEntryArrayValue : public ConfigFileEntryValue
    112     {
    113         public:
    114             inline ConfigFileEntryArrayValue(const std::string& name, unsigned int index, const std::string& value = "", const std::string& additionalComment = "") : ConfigFileEntryValue(name, value, additionalComment), index_(index) {}
    115             inline virtual ~ConfigFileEntryArrayValue() {}
     111    class _CoreExport ConfigFileEntryVectorValue : public ConfigFileEntryValue
     112    {
     113        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) {}
     115            inline virtual ~ConfigFileEntryVectorValue() {}
    116116
    117117            inline virtual unsigned int getIndex() const
     
    179179            inline const std::string& getValue(const std::string& name, unsigned int index, const std::string& fallback)
    180180                { return this->getEntry(name, index, fallback)->getValue(); }
     181
     182            void deleteVectorEntries(const std::string& name, unsigned int startindex = 0);
     183            unsigned int getVectorSize(const std::string& name);
    181184
    182185            std::string getFileEntry() const;
     
    216219            void load(bool bCreateIfNotExisting = true);
    217220            void save() const;
    218             void clean();
     221            void clean(bool bCleanComments = false);
    219222
    220223            inline void setValue(const std::string& section, const std::string& name, const std::string& value)
     
    228231                { const std::string& output = this->getSection(section)->getValue(name, index, fallback); this->saveIfUpdated(); return output; }
    229232
     233            inline void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0)
     234                { this->getSection(section)->deleteVectorEntries(name, startindex); }
     235            inline unsigned int getVectorSize(const std::string& section, const std::string& name)
     236                { return this->getSection(section)->getVectorSize(name); }
     237
    230238        private:
    231239            ConfigFileSection* getSection(const std::string& section);
     
    250258            void load(bool bCreateIfNotExisting = true);
    251259            void save();
    252             void clean();
     260            void clean(bool bCleanComments = false);
    253261
    254262            void load(ConfigFileType type, bool bCreateIfNotExisting = true);
    255263            void save(ConfigFileType type);
    256             void clean(ConfigFileType type);
     264            void clean(ConfigFileType type, bool bCleanComments = false);
    257265
    258266            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& value)
     
    266274                { return this->getFile(type)->getValue(section, name, index, fallback); }
    267275
     276            inline void deleteVectorEntries(ConfigFileType type, const std::string& section, const std::string& name, unsigned int startindex = 0)
     277                { this->getFile(type)->deleteVectorEntries(section, name, startindex); }
     278            inline unsigned int getVectorSize(ConfigFileType type, const std::string& section, const std::string& name)
     279                { return this->getFile(type)->getVectorSize(section, name); }
     280
    268281            void updateConfigValues() const;
    269282            void updateConfigValues(ConfigFileType type) const;
Note: See TracChangeset for help on using the changeset viewer.