1515// You should have received a copy of the GNU General Public License along with
1616// VCC (Virtual Color Computer). If not, see <http://www.gnu.org/licenses/>.
1717// //////////////////////////////////////////////////////////////////////////////
18-
1918#pragma once
2019#include < vcc/core/detail/exports.h>
2120#include < string>
2221
23- // The configuration_serializer class reads or writes VCC settings kept in the
24- // VCC initialization file (typically vcc.ini)
25- //
26- // In programming, a serializer is a mechanism or tool used to convert a complex
27- // data structure or object into a format that can be easily stored, transmitted,
28- // or reconstructed later. This class barely meets that definition. It might be
29- // better named "settings_manager" or just "Settings".
3022
3123namespace vcc ::utils
3224{
3325
3426 // / @brief Provides facilities to save and restore values.
3527 // /
36- // / The Configuration Serializer provides facilities for saving values to and loading
28+ // / The Persistent Value Store provides facilities for saving values to and loading
3729 // / values from a file that persists between sessions. Values are stored grouped in
3830 // / sections and are accessed using a textual key.
39- class configuration_serializer
31+ class persistent_value_store
4032 {
4133 public:
4234
@@ -47,12 +39,13 @@ namespace vcc::utils
4739 // / @brief The type used to represent a size or length.
4840 using size_type = ::std::size_t ;
4941
42+
5043 public:
5144
52- // / @brief Constructs a Configuration Serializer .
45+ // / @brief Constructs a Persistent Value Store .
5346 // /
5447 // / @param path The path to the file where the values are stored.
55- LIBCOMMON_EXPORT explicit configuration_serializer (path_type path);
48+ LIBCOMMON_EXPORT explicit persistent_value_store (path_type path);
5649
5750 // / @brief Save a signed integer value.
5851 // /
@@ -76,79 +69,74 @@ namespace vcc::utils
7669
7770 // / @brief Retrieve a boolean value.
7871 // /
79- // / Retrieves a boolean value from the configuration . If the value is not present in
80- // / the configuration , a default value is returned.
72+ // / Retrieves a boolean value from the value store . If the value is not present in the
73+ // / value store , a default value is returned.
8174 // /
8275 // / @param section The section the value is stored in.
8376 // / @param key The key the value is saved as.
84- // / @param default_value The value to return if it does not exist in the configuration .
77+ // / @param default_value The value to return if it does not exist in the value store .
8578 // /
86- // / @return The value stored in the configuration if it exists; otherwise the specified
87- // / default value.
79+ // / @return The stored value if it exists; otherwise the specified default value.
8880 LIBCOMMON_EXPORT [[nodiscard]] bool read (
8981 const string_type& section,
9082 const string_type& key,
9183 bool default_value) const ;
9284
9385 // / @brief Retrieve a signed integer value.
9486 // /
95- // / Retrieves a signed integer value from the configuration . If the value is not present
96- // / in the configuration , a default value is returned.
87+ // / Retrieves a signed integer value from the value store . If the value is not present
88+ // / in the value store , a default value is returned.
9789 // /
9890 // / @param section The section the value is stored in.
9991 // / @param key The key the value is saved as.
100- // / @param default_value The value to return if it does not exist in the configuration .
92+ // / @param default_value The value to return if it does not exist in the value store .
10193 // /
102- // / @return The value stored in the configuration if it exists; otherwise the specified
103- // / default value.
94+ // / @return The stored value if it exists; otherwise the specified default value.
10495 LIBCOMMON_EXPORT [[nodiscard]] int read (
10596 const string_type& section,
10697 const string_type& key,
10798 const int & default_value) const ;
10899
109100 // / @brief Retrieve an unsigned integer value.
110101 // /
111- // / Retrieves an unsigned integer value from the configuration . If the value is not present
112- // / in the configuration , a default value is returned.
102+ // / Retrieves an unsigned integer value from the value store . If the value is not present
103+ // / in the value store , a default value is returned.
113104 // /
114105 // / @param section The section the value is stored in.
115106 // / @param key The key the value is saved as.
116- // / @param default_value The value to return if it does not exist in the configuration .
107+ // / @param default_value The value to return if it does not exist in the value store .
117108 // /
118- // / @return The value stored in the configuration if it exists; otherwise the specified
119- // / default value.
109+ // / @return The stored value if it exists; otherwise the specified default value.
120110 LIBCOMMON_EXPORT [[nodiscard]] size_type read (
121111 const string_type& section,
122112 const string_type& key,
123113 const size_type& default_value) const ;
124114
125115 // / @brief Retrieve a string value.
126116 // /
127- // / Retrieves a string value from the configuration . If the value is not present in the
128- // / configuration , a default value is returned.
117+ // / Retrieves a string value from the value store . If the value is not present in the
118+ // / value store , a default value is returned.
129119 // /
130120 // / @param section The section the value is stored in.
131121 // / @param key The key the value is saved as.
132- // / @param default_value The value to return if it does not exist in the configuration .
122+ // / @param default_value The value to return if it does not exist in the value store .
133123 // /
134- // / @return The value stored in the configuration if it exists; otherwise the specified
135- // / default value.
124+ // / @return The stored value if it exists; otherwise the specified default value.
136125 LIBCOMMON_EXPORT [[nodiscard]] string_type read (
137126 const string_type& section,
138127 const string_type& key,
139128 const string_type& default_value = {}) const ;
140129
141130 // / @brief Retrieve a string value.
142131 // /
143- // / Retrieves a string value from the configuration . If the value is not present in the
144- // / configuration , a default value is returned.
132+ // / Retrieves a string value from the value store . If the value is not present in the
133+ // / value store , a default value is returned.
145134 // /
146135 // / @param section The section the value is stored in.
147136 // / @param key The key the value is saved as.
148- // / @param default_value The value to return if it does not exist in the configuration .
137+ // / @param default_value The value to return if it does not exist in the value store .
149138 // /
150- // / @return The value stored in the configuration if it exists; otherwise the specified
151- // / default value.
139+ // / @return The stored value if it exists; otherwise the specified default value.
152140 LIBCOMMON_EXPORT [[nodiscard]] string_type read (
153141 const string_type& section,
154142 const string_type& key,
0 commit comments