Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/plehmannFS16/src/libraries/core/config/ConfigFileEntryValue.h @ 11479

Last change on this file since 11479 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @ingroup Config ConfigFile
32*/
33
34#ifndef _ConfigFileEntryValue_H__
35#define _ConfigFileEntryValue_H__
36
37#include "core/CorePrereqs.h"
38
39#include <string>
40#include "ConfigFileEntry.h"
41
42namespace orxonox
43{
44    //////////////////////////
45    // ConfigFileEntryValue //
46    //////////////////////////
47    /**
48        @brief This class represents a normal value in the config file.
49    */
50    class _CoreExport ConfigFileEntryValue : public ConfigFileEntry
51    {
52        public:
53            /**
54                @brief Constructor: Initializes the entry.
55
56                @param name                 The name of the entry
57                @param value                The value of the entry
58                @param bString              If true, the value is treated as string which means some special treatment of special characters.
59                @param additionalComment    An optional comment that will be placed behind the value in the config file
60            */
61            inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "")
62                : name_(name)
63                , value_(value)
64                , additionalComment_(additionalComment)
65                , bString_(bString)
66                { this->update(); }
67
68            /// Destructor
69            virtual inline ~ConfigFileEntryValue() = default;
70
71            virtual inline const std::string& getName() const override
72                { return this->name_; }
73
74            virtual inline void setComment(const std::string& comment) override
75                { this->additionalComment_ = comment; this->update(); }
76
77            virtual inline void setValue(const std::string& value) override
78                { this->value_ = value; this->update(); }
79            virtual inline const std::string& getValue() const override
80                { return this->value_; }
81
82            virtual inline void setString(bool bString) override
83                { this->bString_ = bString; this->update(); }
84
85            virtual inline const std::string& getFileEntry() const override
86                { return this->fileEntry_; }
87
88            /// Returns the "key" of the value (in this case it's just the name of the entry, but for vectors it's different)
89            virtual inline const std::string& getKeyString() const
90                { return this->name_; }
91
92        protected:
93            virtual void update();
94
95            const std::string name_;            ///< The name of the value
96            std::string value_;                 ///< The value
97            std::string additionalComment_;     ///< The additional comment
98            std::string fileEntry_;             ///< The string as it will be stored in the config file
99            bool bString_;                      ///< If true, the value is treated as string which means some special treatment of special characters.
100    };
101}
102
103#endif /* _ConfigFileEntryValue_H__ */
Note: See TracBrowser for help on using the repository browser.