Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Jun 21, 2024
1 parent 39c1332 commit 0a469be
Showing 1 changed file with 143 additions and 2 deletions.
145 changes: 143 additions & 2 deletions src/xtd.core/include/xtd/configuration/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,149 @@ namespace xtd {
/// @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.
/// @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`.
/// @par Examples
/// The following code example demonstrates the use of settings class.
/// @include settings_example.cpp
/// 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).
///
/// • application_Settings.cpp :
/// @include application_settings.cpp
/// • properties/settings.cmake :
/// ```cmake
/// setting_include(xtd/drawing/point)
/// setting_include(xtd/drawing/size)
/// setting_include(xtd/drawing/system_colors)
/// setting(back_color xtd::drawing::color USER "xtd::drawing::system_colors::control()")
/// setting(location xtd::drawing::point USER "{100, 50}")
/// setting(size xtd::drawing::size USER "{335, 45}")
/// setting(text xtd::ustring APPLICATION "\"Settings example\"")
/// ```
/// • The generated properties/settings.h :
/// ```cpp
/// #pragma region xtd generated code
/// // This code was generated by CMake script.
/// //
/// // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
///
/// #pragma once
/// #include <xtd/drawing/point>
/// #include <xtd/drawing/size>
/// #include <xtd/drawing/system_colors>
/// #include <xtd/configuration/settings>
///
/// namespace application_settings::properties {
/// // @brief A strongly typed settings class, for storing user and system settings
/// // @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.
/// // @remarks See [Settings](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/settings) for more informations.
/// class settings : public xtd::object {
/// public:
/// // @name Public Constructors
///
/// // @{
/// // @brief Initializes a new instance of the application_settings::properties::settings class.
/// // @remarks All properties are reloaded with the last saved value.
/// settings() noexcept : settings {true} {}
/// // @brief Initializes a new instance of the application_settings::properties::settings class.
/// // @param load If true all properties are reloaded with the last saved values; otherwise none.
/// explicit settings(bool load) noexcept {
/// if (load) reload();
/// }
/// // @}
///
/// // cond
/// settings(settings&&) noexcept = default;
/// settings(const settings&) noexcept = default;
/// settings& operator =(const settings&) noexcept = default;
/// // endcond
///
/// // @name Public Properties
///
/// // @{
/// // @brief Gets the back_color user setting property.
/// // @return A xtd::drawing::color value.
/// xtd::drawing::color back_color() const noexcept {return back_color_;}
/// // @brief Sets the back_color user setting property.
/// // @param value A xtd::drawing::color value.
/// settings& back_color(xtd::drawing::color value) noexcept {
/// back_color_ = value;
/// return *this;
/// }
///
/// // @brief Gets the location user setting property.
/// // @return A xtd::drawing::point value.
/// xtd::drawing::point location() const noexcept {return location_;}
/// // @brief Sets the location user setting property.
/// // @param value A xtd::drawing::point value.
/// settings& location(xtd::drawing::point value) noexcept {
/// location_ = value;
/// return *this;
/// }
///
/// // @brief Gets the size user setting property.
/// // @return A xtd::drawing::size value.
/// xtd::drawing::size size() const noexcept {return size_;}
/// // @brief Sets the size user setting property.
/// // @param value A xtd::drawing::size value.
/// settings& size(xtd::drawing::size value) noexcept {
/// size_ = value;
/// return *this;
/// }
///
/// // @brief Gets the text system setting property.
/// // @return A xtd::ustring value.
/// xtd::ustring text() const noexcept {return "Settings example";}
///
/// // @}
///
/// // @name Public Methods
///
/// // @{
/// // @brief Reload all properties with the last saved values.
/// // @remarks See [Settings](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/settings) for more informations.
/// void reload() noexcept {
/// back_color_ = settings_.read("back_color", back_color_);
/// location_ = settings_.read("location", location_);
/// size_ = settings_.read("size", size_);
/// }
///
/// // @brief Reset all properties to their default values.
/// // @remarks See [Settings](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/settings) for more informations.
/// void reset() noexcept {
/// settings_.reset();
/// *this = settings {false};
/// }
///
/// // @brief Save all properties.
/// // @remarks See [Settings](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/settings) for more informations.
/// void save() noexcept {
/// settings_.write("back_color", back_color_);
/// settings_.write("location", location_);
/// settings_.write("size", size_);
/// settings_.save();
/// }
/// // @}
///
/// // @name Public Static Properties
///
/// // @{
/// // @brief Gets the default instance of settings.
/// // @return The default instance.
/// // @remarks At the first call all properties are reloaded with the last saved values.
/// static settings& default_settings() noexcept {
/// static auto default_settings = settings {};
/// return default_settings;
/// }
/// // @}
///
/// private:
/// xtd::configuration::settings settings_;
/// xtd::drawing::color back_color_ {xtd::drawing::system_colors::control()};
/// xtd::drawing::point location_ {{100, 50}};
/// xtd::drawing::size size_ {{335, 45}};
/// };
/// }
///
/// #pragma endregion
/// ```
/// 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).
/// @include application_settings2.cpp
class core_export_ settings : public object {
struct data;

Expand Down

0 comments on commit 0a469be

Please sign in to comment.