Represents an object for storing and retrieving configuration information using text files in INI format.
- Header
#include <xtd/configuration/file_settings>
- Namespace
- xtd
- Library
- xtd.core
- Examples
- The following code example demonstrates the use of xtd::configuration::file_settings class.
#include <xtd/configuration/file_settings>
#include <xtd/console>
auto write_file_settings() {
file.
top_file_comment(
"Settings file used by file_settings example.\nCopyright (c) 2024 Gammasoft. All rights reserved.");
file.write("auto_close", true);
file.write("caption", "file_settings example");
file.write("Thread \"Process\"", "timeout", 100_ms);
file.save();
}
auto reset_file_settings() {
}
auto read_file_settings() {
}
auto main() -> int {
write_file_settings();
read_file_settings();
}
xtd::string top_file_comment() const noexcept
Gets top file comment text.
void reset()
Reset current settings.
Represents an object for storing and retrieving configuration information using text files in INI for...
Definition file_settings.h:32
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Contains the types that provide the programming model for handling configuration data.
Definition file_settings.h:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
- Examples
- file_settings.cpp.
|
bool | equals (const file_settings &obj) const noexcept override |
| Indicates whether the current object is equal to another object of the same type.
|
|
virtual void | from_string (const xtd::string &text) |
| Sets the current settings with parsing the xtd::string in INI format.
|
|
void | load (const xtd::string &file_path) |
| Loads settings from specified file.
|
|
void | load (std::istream &stream) |
| Loads settings from specified stream.
|
|
xtd::string | read (const xtd::string &key, const xtd::string &default_value) noexcept |
| Reads a value for specified key in the global section. If not found default value is used.
|
|
template<typename type_t > |
type_t | read (const xtd::string &key, const type_t &default_value) |
| Reads a value for specified key in the global section. If not found default value is used.
|
|
xtd::string | read (const xtd::string §ion, const xtd::string &key, const xtd::string &default_value) noexcept |
| Reads a value for specified key in the specified section. If not found default value is used.
|
|
template<typename type_t > |
type_t | read (const xtd::string §ion, const xtd::string &key, const type_t &default_value) |
| Reads a value for specified key in the specified section. If not found default value is used.
|
|
void | remove (const xtd::string &key) noexcept |
| Removes the specified key from the global section.
|
|
void | remove (const xtd::string §ion, const xtd::string &key) noexcept |
| Removes the specified key from the specified section.
|
|
void | remove_all_keys () noexcept |
| Removes all keys from the global section.
|
|
void | remove_all_keys (const xtd::string §ion) noexcept |
| Removes all key from the specified section.
|
|
void | reset () |
| Reset current settings.
|
|
void | save () |
| Save current settings.
|
|
void | save_as (const xtd::string &file_path) |
| Save current settings in the specified file path.
|
|
void | save_as (std::ostream &stream) |
| Save current settings in the specified stream.
|
|
xtd::string | to_string () const noexcept override |
| Returns a xtd::string that represents the current setting in INI format.
|
|
void | write (const xtd::string &key, const xtd::string &value) noexcept |
| Writes a specified value for specified key in the global section.
|
|
template<typename type_t > |
void | write (const xtd::string &key, type_t &&value) |
| Writes a specified value for specified key in the global section.
|
|
void | write (const xtd::string §ion, const xtd::string &key, const xtd::string &value) noexcept |
| Writes a specified value for specified key in the specified section.
|
|
template<typename type_t > |
void | write (const xtd::string §ion, const xtd::string &key, type_t &&value) |
| Writes a specified value for specified key in the specified section.
|
|
virtual bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object.
|
|
template<typename object_a_t , typename object_b_t > |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are considered equal.
|
|
|
| object ()=default |
| Create a new instance of the ultimate base class object.
|
|
virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type.
|
|
virtual type_object | get_type () const noexcept |
| Gets the type of the current instance.
|
|
template<typename object_t > |
xtd::uptr< object_t > | memberwise_clone () const |
| Creates a shallow copy of the current object.
|
|
virtual bool | equals (const file_settings &) const noexcept=0 |
| Indicates wheth er the current object is equal to another object of the same type.
|
|
template<typename object_a_t , typename object_b_t > |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are considered equal.
|
|
template<typename object_a_t , typename object_b_t > |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are the same instance.
|
|