Represents an object for storing and retrieving configuration information using text files in INI format.
Protected Member Functions | |
virtual xtd::string | convert_comment_to_text (const xtd::string &text) const noexcept |
virtual xtd::string | convert_text_to_comment (const xtd::string &text) const noexcept |
Public Aliass | |
using | string_dictionary = xtd::collections::generic::sorted_dictionary< xtd::string, xtd::string > |
Represents a xtd::collections::generic::sorted_dictionary with the key and the value strongly typed to be strings. | |
using | string_collection = xtd::collections::specialized::string_collection |
Represents a collection of strings. | |
Public Constructors | |
file_settings () noexcept=default | |
Initialize an xtd::configuration::file_settings without loading a file. | |
file_settings (const xtd::string &file_path) | |
Initialize an xtd::configuration::file_settings with file path to load and save. | |
file_settings (std::iostream &stream) | |
Initialize an xtd::configuration::file_settings with a stream to load and save. | |
Public Properties | |
bool | auto_save () const noexcept |
Gets whether save should be called on the xtd::configuration::file_settings destructor. | |
void | auto_save (bool value) noexcept |
Sets whether save should be called on the xtd::configuration::file_settings destructor. | |
xtd::string | bottom_file_comment () const noexcept |
Gets bottom file comment text. | |
file_settings & | bottom_file_comment (const xtd::string &value) noexcept |
Sets bottom file comment text. | |
const xtd::string & | file_path () const noexcept |
Gets the file path of the current instance. | |
string_dictionary | key_values () const noexcept |
Gets all key-value pairs from global section. | |
string_dictionary | key_values (const xtd::string §ion) const noexcept |
Gets all key-value pairs from a specified section. | |
string_collection | keys () const noexcept |
Gets all keys from global section. | |
string_collection | keys (const xtd::string §ion) const noexcept |
Gets all keys from a specified section. | |
string_collection | sections () const noexcept |
Gets all sections. | |
std::optional< std::reference_wrapper< std::iostream > > | stream () const noexcept |
Gets the stream of the current instance. | |
xtd::string | top_file_comment () const noexcept |
Gets top file comment text. | |
file_settings & | top_file_comment (const xtd::string &value) noexcept |
Sets top file comment text. | |
Public Methods | |
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. | |
Public Operators | |
const string_dictionary & | operator[] (const xtd::string §ion) const noexcept |
Gets key-value pairs of the specified section. | |
string_dictionary & | operator[] (const xtd::string §ion) noexcept |
Gets key-value pairs of the specified section. | |
Additional Inherited Members | |
Public Member Functions inherited from xtd::object | |
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. | |
Public Member Functions inherited from xtd::iequatable< file_settings > | |
virtual bool | equals (const file_settings &) const noexcept=0 |
Indicates whether the current object is equal to another object of the same type. | |
Static Public Member Functions inherited from xtd::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. | |
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. | |
using xtd::configuration::file_settings::string_dictionary = xtd::collections::generic::sorted_dictionary<xtd::string, xtd::string> |
Represents a xtd::collections::generic::sorted_dictionary with the key and the value strongly typed to be strings.
using xtd::configuration::file_settings::string_collection = xtd::collections::specialized::string_collection |
Represents a collection of strings.
|
defaultnoexcept |
Initialize an xtd::configuration::file_settings without loading a file.
|
explicit |
Initialize an xtd::configuration::file_settings with file path to load and save.
file_path | the file path to load and save. |
|
explicit |
Initialize an xtd::configuration::file_settings with a stream to load and save.
stream | the stream to load and save. |
|
noexcept |
Gets whether save should be called on the xtd::configuration::file_settings destructor.
|
noexcept |
Sets whether save should be called on the xtd::configuration::file_settings destructor.
value | true if xtd::configuration::file_settings::save is called on the xtd::configuration::file_settings destructor; otherwise, false. |
|
noexcept |
Gets bottom file comment text.
|
noexcept |
Sets bottom file comment text.
value | Bottom file comment text. |
|
noexcept |
Gets the file path of the current instance.
|
noexcept |
Gets all key-value pairs from global section.
|
noexcept |
Gets all key-value pairs from a specified section.
section | The section to get key-value pairs. |
|
noexcept |
Gets all keys from global section.
|
noexcept |
Gets all keys from a specified section.
section | The section to get keys. |
|
noexcept |
Gets all sections.
|
noexcept |
Gets the stream of the current instance.
|
noexcept |
Gets top file comment text.
|
noexcept |
Sets top file comment text.
value | Top file comment textr. |
|
overridenoexcept |
Indicates whether the current object is equal to another object of the same type.
obj | An object to compare with this object. |
|
virtual |
Sets the current settings with parsing the xtd::string in INI format.
text | A text to set the current setting. |
void xtd::configuration::file_settings::load | ( | const xtd::string & | file_path | ) |
Loads settings from specified file.
file_path | The file path to load settings. |
void xtd::configuration::file_settings::load | ( | std::istream & | stream | ) |
Loads settings from specified stream.
stream | The stream to load settings. |
|
noexcept |
Reads a value for specified key in the global section. If not found default value is used.
key | The key used to read a value. |
default_value | A string used if value not found. |
|
inline |
Reads a value for specified key in the global section. If not found default value is used.
key | The key used to read a value. |
default_value | A string used if value not found. |
|
noexcept |
Reads a value for specified key in the specified section. If not found default value is used.
section | The section where the key is read. |
key | The key used to read a value. |
default_value | A string used if value not found. |
|
inline |
Reads a value for specified key in the specified section. If not found default value is used.
section | The section where the key is read. |
key | The key used to read a value. |
default_value | A string used if value not found. |
|
noexcept |
Removes the specified key from the global section.
key | The key to remove from the global section. |
Removes the specified key from the specified section.
section | The section where the key is removed. |
key | The key to remove from the specified section. |
|
noexcept |
Removes the specified key from the specified section.
section | The section where the key is removed. |
key | The key to remove from the specified section. |
|
noexcept |
Removes all keys from the global section.
|
noexcept |
Removes all key from the specified section.
section | The section where all keys are removed. |
void xtd::configuration::file_settings::reset | ( | ) |
Reset current settings.
void xtd::configuration::file_settings::save | ( | ) |
Save current settings.
void xtd::configuration::file_settings::save_as | ( | const xtd::string & | file_path | ) |
Save current settings in the specified file path.
file_path | The file to save the current settings. |
void xtd::configuration::file_settings::save_as | ( | std::ostream & | stream | ) |
Save current settings in the specified stream.
stream | The stream to save the current settings. |
|
overridevirtualnoexcept |
Returns a xtd::string that represents the current setting in INI format.
Reimplemented from xtd::object.
|
noexcept |
Writes a specified value for specified key in the global section.
key | The key used to write a value. |
value | A string to write. |
|
inline |
Writes a specified value for specified key in the global section.
key | The key used to write a value. |
value | A string to write. |
|
noexcept |
Writes a specified value for specified key in the specified section.
section | The section where the key is write. |
key | The key used to write a value. |
value | A string to write. |
|
inline |
Writes a specified value for specified key in the specified section.
section | The section where the key is write. |
key | The key used to write a value. |
value | A string to write. |
|
noexcept |
Gets key-value pairs of the specified section.
secion | The section to get the key-value pairs |
|
noexcept |
Gets key-value pairs of the specified section.
secion | The section to get the key-value pairs |
|
virtualnoexcept |
Determines whether the specified object is equal to the current object.
obj | The object to compare with the current object. |
Reimplemented from xtd::object.
|
inlinestaticnoexcept |
Determines whether the specified object instances are considered equal.
object_a | The first object to compare. |
object_b | The second object to compare. |