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 "ConfigFileEntry.h" |
---|
40 | |
---|
41 | namespace orxonox |
---|
42 | { |
---|
43 | ////////////////////////// |
---|
44 | // ConfigFileEntryValue // |
---|
45 | ////////////////////////// |
---|
46 | /** |
---|
47 | @brief This class represents a normal value in the config file. |
---|
48 | */ |
---|
49 | class _CoreExport ConfigFileEntryValue : public ConfigFileEntry |
---|
50 | { |
---|
51 | public: |
---|
52 | /** |
---|
53 | @brief Constructor: Initializes the entry. |
---|
54 | |
---|
55 | @param name The name of the entry |
---|
56 | @param value The value of the entry |
---|
57 | @param bString If true, the value is treated as string which means some special treatment of special characters. |
---|
58 | @param additionalComment An optional comment that will be placed behind the value in the config file |
---|
59 | */ |
---|
60 | inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") |
---|
61 | : name_(name) |
---|
62 | , value_(value) |
---|
63 | , additionalComment_(additionalComment) |
---|
64 | , bString_(bString) |
---|
65 | { this->update(); } |
---|
66 | |
---|
67 | /// Destructor |
---|
68 | inline virtual ~ConfigFileEntryValue() {} |
---|
69 | |
---|
70 | inline virtual const std::string& getName() const |
---|
71 | { return this->name_; } |
---|
72 | |
---|
73 | inline virtual void setComment(const std::string& comment) |
---|
74 | { this->additionalComment_ = comment; this->update(); } |
---|
75 | |
---|
76 | inline virtual void setValue(const std::string& value) |
---|
77 | { this->value_ = value; this->update(); } |
---|
78 | inline virtual const std::string& getValue() const |
---|
79 | { return this->value_; } |
---|
80 | |
---|
81 | inline void virtual setString(bool bString) |
---|
82 | { this->bString_ = bString; this->update(); } |
---|
83 | |
---|
84 | inline virtual const std::string& getFileEntry() const |
---|
85 | { return this->fileEntry_; } |
---|
86 | |
---|
87 | /// Returns the "key" of the value (in this case it's just the name of the entry, but for vectors it's different) |
---|
88 | inline virtual const std::string& getKeyString() const |
---|
89 | { return this->name_; } |
---|
90 | |
---|
91 | protected: |
---|
92 | virtual void update(); |
---|
93 | |
---|
94 | const std::string name_; ///< The name of the value |
---|
95 | std::string value_; ///< The value |
---|
96 | std::string additionalComment_; ///< The additional comment |
---|
97 | std::string fileEntry_; ///< The string as it will be stored in the config file |
---|
98 | bool bString_; ///< If true, the value is treated as string which means some special treatment of special characters. |
---|
99 | }; |
---|
100 | } |
---|
101 | |
---|
102 | #endif /* _ConfigFileEntryValue_H__ */ |
---|