xtd 0.2.0
Loading...
Searching...
No Matches
settings.h
Go to the documentation of this file.
1
4#pragma once
5#include "../core_export.h"
6#include "../object.h"
7#include "../string.h"
8#include <memory>
9
11namespace xtd {
13 namespace configuration {
174 class core_export_ settings : public object {
175 struct data;
176
177 public:
179
184
186
197 const xtd::string& file_path() const noexcept;
199
201
207 xtd::string read(const xtd::string& key, const xtd::string& default_value);
213 template<typename type_t>
214 type_t read(const xtd::string& key, const type_t& default_value) {
215 return xtd::parse<type_t>(read_string(key, xtd::string::format("{}", default_value)));
216 }
217
221 void reset();
222
225 void save();
226
231 void write(const xtd::string& key, const xtd::string& value);
237 template<typename type_t>
238 void write(const xtd::string& key, type_t&& value) {
239 write_string(key, xtd::string::format("{}", value));
240 }
242
243 private:
244 xtd::string read_string(const xtd::string& key, const xtd::string& default_value);
245 void write_string(const xtd::string& key, const xtd::string& value);
246
247 xtd::sptr<data> data_;
248 };
249 }
250}
Represents text as a sequence of character units.
Definition basic_string.h:79
Represent settings associate to the application.
Definition settings.h:174
void save()
Save application settings.
void write(const xtd::string &key, const xtd::string &value)
Writes a specified value for specified key.
const xtd::string & file_path() const noexcept
Gets the file path of the application settings.
settings()
Initializes a new instance of settings class.
void write(const xtd::string &key, type_t &&value)
Writes a specified value for specified key.
Definition settings.h:238
void reset()
Reset application settings.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
static basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
#define core_export_
Define shared library export.
Definition core_export.h:13
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.h:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10