xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Go to the documentation of this file.
1 #pragma once
5 #include <memory>
6 #include <xtd/object.h>
7 #include <xtd/ustring.h>
8 #include "../forms_export.h"
11 namespace xtd {
13  namespace forms {
26  class forms_export_ settings : public object {
27  public:
29  settings();
31  ~settings();
38  xtd::ustring read(const xtd::ustring& key, const xtd::ustring& default_value) {return read_string(key, default_value);}
44  template<typename type_t>
45  type_t read(const xtd::ustring& key, const type_t& default_value) {
46  return xtd::parse<type_t>(read_string(key, xtd::ustring::format("{}", default_value)));
47  }
50  void reset();
53  void save();
58  void write(const xtd::ustring& key, const xtd::ustring& value) {write_string(key, value);}
64  template<typename type_t>
65  void write(const xtd::ustring& key, type_t&& value) {
66  write_string(key, xtd::ustring::format("{}", value));
67  }
69  private:
70  xtd::ustring read_string(const xtd::ustring& key, const xtd::ustring& default_value);
71  void write_string(const xtd::ustring& key, const xtd::ustring& value);
72  struct data {
73  intptr_t settings_;
74  };
76  std::shared_ptr<data> data_ = std::make_shared<data>();
77  };
78  }
79 }
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represent settings associate to the application.
Definition: settings.h:26
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Contains xtd::ustring class.
void write(const xtd::ustring &key, const xtd::ustring &value)
Writes a specified value for specified key.
Definition: settings.h:58
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:38
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:26
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:45
void write(const xtd::ustring &key, type_t &&value)
Writes a specified value for specified key.
Definition: settings.h:65
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:689
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13