xtd 0.2.0
Loading...
Searching...
No Matches
settings.h
Go to the documentation of this file.
1
4#pragma once
5#include "../forms_export.h"
6#include <xtd/object>
7#include <xtd/ustring>
8#include <memory>
9
11namespace xtd {
13 namespace forms {
28 class forms_export_ settings : public object {
29 struct data;
30
31 public:
33
38
40 ~settings();
42
44
50 xtd::ustring read(const xtd::ustring& key, const xtd::ustring& default_value) {return read_string(key, default_value);}
56 template<typename type_t>
57 type_t read(const xtd::ustring& key, const type_t& default_value) {
58 return xtd::parse<type_t>(read_string(key, xtd::ustring::format("{}", default_value)));
59 }
60
62 void reset();
63
65 void save();
66
70 void write(const xtd::ustring& key, const xtd::ustring& value) {write_string(key, value);}
71
76 template<typename type_t>
77 void write(const xtd::ustring& key, type_t&& value) {
78 write_string(key, xtd::ustring::format("{}", value));
79 }
81
82 private:
83 xtd::ustring read_string(const xtd::ustring& key, const xtd::ustring& default_value);
84 void write_string(const xtd::ustring& key, const xtd::ustring& value);
85
86 std::shared_ptr<data> data_;
87 };
88 }
89}
Represent settings associate to the application.
Definition settings.h:28
type_t read(const xtd::ustring &key, const type_t &default_value)
Reads a value for specified key. If not found default value is used.
Definition settings.h:57
void reset()
Reset application settings.
void write(const xtd::ustring &key, const xtd::ustring &value)
Writes a specified value for specified key.
Definition settings.h:70
void save()
Save application settings.
xtd::ustring read(const xtd::ustring &key, const xtd::ustring &default_value)
Reads a value for specified key. If not found default value is used.
Definition settings.h:50
void write(const xtd::ustring &key, type_t &&value)
Writes a specified value for specified key.
Definition settings.h:77
settings()
Initializes a new instance of settings class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition ustring.h:1131
#define forms_export_
Define shared library export.
Definition forms_export.h:13
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10