Skip to content

Commit df7dc18

Browse files
ChetSimpsonejaquay
authored andcommitted
rename configuration_serializer to persistent_value_store
1 parent 69ed519 commit df7dc18

File tree

9 files changed

+83
-97
lines changed

9 files changed

+83
-97
lines changed

FD502/fd502.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <vcc/devices/rom/rom_image.h>
3232
#include <Windows.h>
3333
#include <array>
34-
#include <vcc/utils/configuration_serializer.h>
34+
#include <vcc/utils/persistent_value_store.h>
3535
#include <vcc/utils/filesystem.h>
3636

3737

@@ -601,20 +601,20 @@ void LoadConfig() // Called on SetIniPath
601601
char DiskRomPath[MAX_PATH];
602602
char RGBRomPath[MAX_PATH];
603603

604-
utils::configuration_serializer serializer(IniFile);
604+
::vcc::utils::persistent_value_store settings(IniFile);
605605

606-
BeckerEnabled = serializer.read(becker_section_name, "DWEnable", false);
607-
BeckerAddr = serializer.read(becker_section_name, "DWServerAddr", "127.0.0.1");
608-
BeckerPort = serializer.read(becker_section_name, "DWServerPort", "65504");
606+
BeckerEnabled = settings.read(becker_section_name, "DWEnable", false);
607+
BeckerAddr = settings.read(becker_section_name, "DWServerAddr", "127.0.0.1");
608+
BeckerPort = settings.read(becker_section_name, "DWServerPort", "65504");
609609
gBecker.sethost(BeckerAddr.c_str(), BeckerPort.c_str());
610610
gBecker.enable(BeckerEnabled);
611611

612-
FloppyPath = serializer.read("DefaultPaths", "FloppyPath");
612+
FloppyPath = settings.read("DefaultPaths", "FloppyPath");
613613
SelectRomIndex = std::min(
614-
serializer.read(fd502_section_name, "DiskRom", default_selected_rom_index),
614+
settings.read(fd502_section_name, "DiskRom", default_selected_rom_index),
615615
RomPointer.size());
616-
RomFileName = utils::find_pak_module_path(serializer.read(fd502_section_name, "RomPath"));
617-
PersistDisks = serializer.read(fd502_section_name, "Persist", true);
616+
RomFileName = utils::find_pak_module_path(settings.read(fd502_section_name, "RomPath"));
617+
PersistDisks = settings.read(fd502_section_name, "Persist", true);
618618

619619
RomFileName = utils::find_pak_module_path(RomFileName);
620620
ExternalRom.load(RomFileName); //JF
@@ -632,7 +632,7 @@ void LoadConfig() // Called on SetIniPath
632632
for (auto Index = 0; Index < 4; Index++)
633633
{
634634
const auto settings_key = "Disk#" + std::to_string(Index);
635-
const auto disk_filename(serializer.read(fd502_section_name, settings_key));
635+
const auto disk_filename(settings.read(fd502_section_name, settings_key));
636636
if (!disk_filename.empty())
637637
{
638638
if (mount_disk_image(disk_filename.c_str(), Index))
@@ -651,7 +651,7 @@ void LoadConfig() // Called on SetIniPath
651651
}
652652
}
653653

654-
ClockEnabled = serializer.read(fd502_section_name, "ClkEnable", true);
654+
ClockEnabled = settings.read(fd502_section_name, "ClkEnable", true);
655655
SetTurboDisk(GetPrivateProfileInt(fd502_section_name, "TurboDisk", 1, IniFile));
656656
}
657657

@@ -660,28 +660,28 @@ void SaveConfig()
660660
unsigned char Index = 0;
661661
char Temp[16] = "";
662662

663-
::vcc::utils::configuration_serializer serializer(IniFile);
663+
::vcc::utils::persistent_value_store settings(IniFile);
664664

665665
RomFileName = ::vcc::utils::strip_application_path(RomFileName);
666-
serializer.write(fd502_section_name, "DiskRom", SelectRomIndex);
667-
serializer.write(fd502_section_name, "RomPath", RomFileName);
668-
serializer.write(fd502_section_name, "Persist", PersistDisks);
666+
settings.write(fd502_section_name, "DiskRom", SelectRomIndex);
667+
settings.write(fd502_section_name, "RomPath", RomFileName);
668+
settings.write(fd502_section_name, "Persist", PersistDisks);
669669
if (PersistDisks)
670670
{
671671
for (auto disk_id = 0; disk_id < 4; disk_id++)
672672
{
673673
sprintf(Temp, "Disk#%i", disk_id);
674-
serializer.write(fd502_section_name, Temp, get_mounted_disk_filename(disk_id));
674+
settings.write(fd502_section_name, Temp, get_mounted_disk_filename(disk_id));
675675
}
676676
}
677-
serializer.write(fd502_section_name, "ClkEnable", ClockEnabled);
678-
serializer.write(fd502_section_name, "TurboDisk", SetTurboDisk(QUERY));
677+
settings.write(fd502_section_name, "ClkEnable", ClockEnabled);
678+
settings.write(fd502_section_name, "TurboDisk", SetTurboDisk(QUERY));
679679
if (!FloppyPath.empty())
680680
{
681-
serializer.write("DefaultPaths", "FloppyPath", FloppyPath);
681+
settings.write("DefaultPaths", "FloppyPath", FloppyPath);
682682
}
683683

684-
serializer.write(becker_section_name, "DWEnable", BeckerEnabled);
685-
serializer.write(becker_section_name, "DWServerAddr", BeckerAddr);
686-
serializer.write(becker_section_name, "DWServerPort", BeckerPort);
684+
settings.write(becker_section_name, "DWEnable", BeckerEnabled);
685+
settings.write(becker_section_name, "DWServerAddr", BeckerAddr);
686+
settings.write(becker_section_name, "DWServerPort", BeckerPort);
687687
}

GMC/gmc_cartridge.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "gmc_cartridge.h"
22
#include "resource.h"
33
#include <vcc/common/DialogOps.h>
4-
#include <vcc/utils/configuration_serializer.h>
4+
#include <vcc/utils/persistent_value_store.h>
55
#include <vcc/utils/winapi.h>
66
#include <vcc/utils/filesystem.h>
77
#include "../CartridgeMenu.h"
@@ -54,8 +54,8 @@ gmc_cartridge::description_type gmc_cartridge::description() const
5454

5555
void gmc_cartridge::start()
5656
{
57-
::vcc::utils::configuration_serializer serializer(context_->configuration_path());
58-
const auto selected_file(serializer.read(configuration_section_id_, configuration_rom_key_id_));
57+
::vcc::utils::persistent_value_store settings(context_->configuration_path());
58+
const auto selected_file(settings.read(configuration_section_id_, configuration_rom_key_id_));
5959

6060
load_rom(selected_file, false);
6161
build_menu();
@@ -143,8 +143,8 @@ void gmc_cartridge::menu_item_clicked(unsigned char menuId)
143143
return;
144144
}
145145

146-
::vcc::utils::configuration_serializer serializer(context_->configuration_path());
147-
serializer.write(
146+
::vcc::utils::persistent_value_store settings(context_->configuration_path());
147+
settings.write(
148148
configuration_section_id_,
149149
configuration_rom_key_id_,
150150
selected_file);

becker/becker_cartridge.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "becker_cartridge.h"
1919
#include "resource.h"
2020
#include <vcc/utils/winapi.h>
21-
#include <vcc/utils/configuration_serializer.h>
21+
#include <vcc/utils/persistent_value_store.h>
2222
#include "../CartridgeMenu.h"
2323

2424
// Contains Becker cart exports
@@ -51,11 +51,11 @@ void becker_cartridge::start()
5151
{
5252

5353
// Load becker config
54-
::vcc::utils::configuration_serializer serializer(context_->configuration_path());
54+
::vcc::utils::persistent_value_store settings(context_->configuration_path());
5555

5656
gBecker.sethost(
57-
serializer.read(configuration_section_id_, "DWServerAddr", "127.0.0.1").c_str(),
58-
serializer.read(configuration_section_id_, "DWServerPort", "65504").c_str());
57+
settings.read(configuration_section_id_, "DWServerAddr", "127.0.0.1").c_str(),
58+
settings.read(configuration_section_id_, "DWServerPort", "65504").c_str());
5959
gBecker.enable(true);
6060

6161
// Create dynamic menu
@@ -131,8 +131,8 @@ void becker_cartridge::configure_server(string_type server_address, string_type
131131
{
132132
gBecker.sethost(server_address.c_str(), server_port.c_str());
133133

134-
::vcc::utils::configuration_serializer serializer(context_->configuration_path());
134+
::vcc::utils::persistent_value_store settings(context_->configuration_path());
135135

136-
serializer.write(configuration_section_id_, "DWServerAddr", server_address);
137-
serializer.write(configuration_section_id_, "DWServerPort", server_port);
136+
settings.write(configuration_section_id_, "DWServerAddr", server_address);
137+
settings.write(configuration_section_id_, "DWServerPort", server_port);
138138
}

libcommon/include/vcc/utils/configuration_serializer.h renamed to libcommon/include/vcc/utils/persistent_value_store.h

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,20 @@
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

3123
namespace 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,

libcommon/libcommon.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
<ClCompile Include="src\logger.cpp" />
119119
<ClCompile Include="src\main.cpp" />
120120
<ClCompile Include="src\utils\cartridge_loader.cpp" />
121-
<ClCompile Include="src\utils\configuration_serializer.cpp" />
121+
<ClCompile Include="src\utils\persistent_value_store.cpp" />
122122
<ClCompile Include="src\utils\filesystem.cpp" />
123123
<ClCompile Include="src\utils\winapi.cpp" />
124124
</ItemGroup>
@@ -141,7 +141,7 @@
141141
<ClInclude Include="include\vcc\devices\rtc\oki_m6242b.h" />
142142
<ClInclude Include="include\vcc\devices\becker\beckerport.h" />
143143
<ClInclude Include="include\vcc\utils\cartridge_loader.h" />
144-
<ClInclude Include="include\vcc\utils\configuration_serializer.h" />
144+
<ClInclude Include="include\vcc\utils\persistent_value_store.h" />
145145
<ClInclude Include="include\vcc\utils\critical_section.h" />
146146
<ClInclude Include="include\vcc\utils\dll_deleter.h" />
147147
<ClInclude Include="include\vcc\utils\filesystem.h" />

libcommon/libcommon.vcxproj.filters

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
<ClCompile Include="src\cartridges\rom_cartridge.cpp">
8888
<Filter>Source Files\cartridges</Filter>
8989
</ClCompile>
90-
<ClCompile Include="src\utils\configuration_serializer.cpp">
90+
<ClCompile Include="src\utils\persistent_value_store.cpp">
9191
<Filter>Source Files\utils</Filter>
9292
</ClCompile>
9393
<ClCompile Include="src\utils\filesystem.cpp">
@@ -158,7 +158,7 @@
158158
<ClInclude Include="include\vcc\cartridges\rom_cartridge.h">
159159
<Filter>Header Files\cartridges</Filter>
160160
</ClInclude>
161-
<ClInclude Include="include\vcc\utils\configuration_serializer.h">
161+
<ClInclude Include="include\vcc\utils\persistent_value_store.h">
162162
<Filter>Header Files\utils</Filter>
163163
</ClInclude>
164164
<ClInclude Include="include\vcc\utils\critical_section.h">

0 commit comments

Comments
 (0)