Skip to content

Commit 0a469be

Browse files
committed
Add documentation
1 parent 39c1332 commit 0a469be

File tree

1 file changed

+143
-2
lines changed

1 file changed

+143
-2
lines changed

src/xtd.core/include/xtd/configuration/settings.h

Lines changed: 143 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,149 @@ namespace xtd {
2525
/// @remarks The `product_name` is equal to the xtd::reflection::assembly::product() property of the xtd::reflection::assembly::get_executing_assembly() assembly if not empty; otherwise is equal to the filename of the first arguemnt of main.
2626
/// @remarks The `company_name` is equal to the xtd::reflection::assembly::company() property of the xtd::reflection::assembly::get_executing_assembly() assembly if not empty; otherwise is equal to `product_name`.
2727
/// @par Examples
28-
/// The following code example demonstrates the use of settings class.
29-
/// @include settings_example.cpp
28+
/// The following code example demonstrates the use of xtd::configuration::settings class with [CMake setting commands](https://gammasoft71.github.io/xtd/reference_guides/latest/_c_make_commands.html#AddSettingSubSection).
29+
///
30+
/// • application_Settings.cpp :
31+
/// @include application_settings.cpp
32+
/// • properties/settings.cmake :
33+
/// ```cmake
34+
/// setting_include(xtd/drawing/point)
35+
/// setting_include(xtd/drawing/size)
36+
/// setting_include(xtd/drawing/system_colors)
37+
/// setting(back_color xtd::drawing::color USER "xtd::drawing::system_colors::control()")
38+
/// setting(location xtd::drawing::point USER "{100, 50}")
39+
/// setting(size xtd::drawing::size USER "{335, 45}")
40+
/// setting(text xtd::ustring APPLICATION "\"Settings example\"")
41+
/// ```
42+
/// • The generated properties/settings.h :
43+
/// ```cpp
44+
/// #pragma region xtd generated code
45+
/// // This code was generated by CMake script.
46+
/// //
47+
/// // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
48+
///
49+
/// #pragma once
50+
/// #include <xtd/drawing/point>
51+
/// #include <xtd/drawing/size>
52+
/// #include <xtd/drawing/system_colors>
53+
/// #include <xtd/configuration/settings>
54+
///
55+
/// namespace application_settings::properties {
56+
/// // @brief A strongly typed settings class, for storing user and system settings
57+
/// // @details This class was auto-generated by CMake script. To add or remove a member, edit your CMakeList.txt or properties/settings.cmake file then rerun cmake tools.
58+
/// // @remarks See [Settings](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/settings) for more informations.
59+
/// class settings : public xtd::object {
60+
/// public:
61+
/// // @name Public Constructors
62+
///
63+
/// // @{
64+
/// // @brief Initializes a new instance of the application_settings::properties::settings class.
65+
/// // @remarks All properties are reloaded with the last saved value.
66+
/// settings() noexcept : settings {true} {}
67+
/// // @brief Initializes a new instance of the application_settings::properties::settings class.
68+
/// // @param load If true all properties are reloaded with the last saved values; otherwise none.
69+
/// explicit settings(bool load) noexcept {
70+
/// if (load) reload();
71+
/// }
72+
/// // @}
73+
///
74+
/// // cond
75+
/// settings(settings&&) noexcept = default;
76+
/// settings(const settings&) noexcept = default;
77+
/// settings& operator =(const settings&) noexcept = default;
78+
/// // endcond
79+
///
80+
/// // @name Public Properties
81+
///
82+
/// // @{
83+
/// // @brief Gets the back_color user setting property.
84+
/// // @return A xtd::drawing::color value.
85+
/// xtd::drawing::color back_color() const noexcept {return back_color_;}
86+
/// // @brief Sets the back_color user setting property.
87+
/// // @param value A xtd::drawing::color value.
88+
/// settings& back_color(xtd::drawing::color value) noexcept {
89+
/// back_color_ = value;
90+
/// return *this;
91+
/// }
92+
///
93+
/// // @brief Gets the location user setting property.
94+
/// // @return A xtd::drawing::point value.
95+
/// xtd::drawing::point location() const noexcept {return location_;}
96+
/// // @brief Sets the location user setting property.
97+
/// // @param value A xtd::drawing::point value.
98+
/// settings& location(xtd::drawing::point value) noexcept {
99+
/// location_ = value;
100+
/// return *this;
101+
/// }
102+
///
103+
/// // @brief Gets the size user setting property.
104+
/// // @return A xtd::drawing::size value.
105+
/// xtd::drawing::size size() const noexcept {return size_;}
106+
/// // @brief Sets the size user setting property.
107+
/// // @param value A xtd::drawing::size value.
108+
/// settings& size(xtd::drawing::size value) noexcept {
109+
/// size_ = value;
110+
/// return *this;
111+
/// }
112+
///
113+
/// // @brief Gets the text system setting property.
114+
/// // @return A xtd::ustring value.
115+
/// xtd::ustring text() const noexcept {return "Settings example";}
116+
///
117+
/// // @}
118+
///
119+
/// // @name Public Methods
120+
///
121+
/// // @{
122+
/// // @brief Reload all properties with the last saved values.
123+
/// // @remarks See [Settings](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/settings) for more informations.
124+
/// void reload() noexcept {
125+
/// back_color_ = settings_.read("back_color", back_color_);
126+
/// location_ = settings_.read("location", location_);
127+
/// size_ = settings_.read("size", size_);
128+
/// }
129+
///
130+
/// // @brief Reset all properties to their default values.
131+
/// // @remarks See [Settings](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/settings) for more informations.
132+
/// void reset() noexcept {
133+
/// settings_.reset();
134+
/// *this = settings {false};
135+
/// }
136+
///
137+
/// // @brief Save all properties.
138+
/// // @remarks See [Settings](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/settings) for more informations.
139+
/// void save() noexcept {
140+
/// settings_.write("back_color", back_color_);
141+
/// settings_.write("location", location_);
142+
/// settings_.write("size", size_);
143+
/// settings_.save();
144+
/// }
145+
/// // @}
146+
///
147+
/// // @name Public Static Properties
148+
///
149+
/// // @{
150+
/// // @brief Gets the default instance of settings.
151+
/// // @return The default instance.
152+
/// // @remarks At the first call all properties are reloaded with the last saved values.
153+
/// static settings& default_settings() noexcept {
154+
/// static auto default_settings = settings {};
155+
/// return default_settings;
156+
/// }
157+
/// // @}
158+
///
159+
/// private:
160+
/// xtd::configuration::settings settings_;
161+
/// xtd::drawing::color back_color_ {xtd::drawing::system_colors::control()};
162+
/// xtd::drawing::point location_ {{100, 50}};
163+
/// xtd::drawing::size size_ {{335, 45}};
164+
/// };
165+
/// }
166+
///
167+
/// #pragma endregion
168+
/// ```
169+
/// The following code example demonstrates the use of xtd::configuration::settings class without [CMake setting commands](https://gammasoft71.github.io/xtd/reference_guides/latest/_c_make_commands.html#AddSettingSubSection).
170+
/// @include application_settings2.cpp
30171
class core_export_ settings : public object {
31172
struct data;
32173

0 commit comments

Comments
 (0)