tetengo 1.8.2
A multipurpose library set
Loading...
Searching...
No Matches
property_set.hpp
Go to the documentation of this file.
1
7#if !defined(TETENGO_PROPERTY_PROPERTYSET_HPP)
8#define TETENGO_PROPERTY_PROPERTYSET_HPP
9
10#include <cstdint>
11#include <filesystem>
12#include <memory>
13#include <optional>
14#include <string>
15
16#include <boost/core/noncopyable.hpp>
17
18
19namespace tetengo::property
20{
21 class storage_loader;
22
23
27 class property_set : private boost::noncopyable
28 {
29 public:
30 // constructors and destructor
31
38 property_set(std::unique_ptr<storage_loader>&& p_storage_loader, const std::filesystem::path& path);
39
43 virtual ~property_set();
44
45
46 // functions
47
55 [[nodiscard]] std::optional<bool> get_bool(const std::filesystem::path& key) const;
56
63 void set_bool(const std::filesystem::path& key, bool value);
64
72 [[nodiscard]] std::optional<std::uint32_t> get_uint32(const std::filesystem::path& key) const;
73
80 void set_uint32(const std::filesystem::path& key, std::uint32_t value);
81
89 [[nodiscard]] std::optional<std::string> get_string(const std::filesystem::path& key) const;
90
97 void set_string(const std::filesystem::path& key, const std::string& value);
98
102 void update();
103
107 void commit() const;
108
109
110 private:
111 // types
112
113 class impl;
114
115
116 // variables
117
118 const std::unique_ptr<impl> m_p_impl;
119
120
121 // virtual functions
122 };
123
124
125}
126
127
128#endif
A property set.
Definition property_set.hpp:28
property_set(std::unique_ptr< storage_loader > &&p_storage_loader, const std::filesystem::path &path)
Creates a property set.
std::optional< std::uint32_t > get_uint32(const std::filesystem::path &key) const
Returns the value in an unsigned 32-bit integer.
void set_bool(const std::filesystem::path &key, bool value)
Sets a value in a boolean.
void update()
Updates the property values to the latest state in the storage.
std::optional< std::string > get_string(const std::filesystem::path &key) const
Returns the value in a string.
void set_string(const std::filesystem::path &key, const std::string &value)
Sets a value in a string.
virtual ~property_set()
Destroys the property set.
void commit() const
Commits the property value changes to the storage.
void set_uint32(const std::filesystem::path &key, std::uint32_t value)
Sets a value in an unsigned 32-bit integer.
std::optional< bool > get_bool(const std::filesystem::path &key) const
Returns the value in a boolean.
A property set library.