![]() |
NDEVR
API Documentation
|
Contains methods for easily reading and writing to an INI file including efficient casting, callback, and variable storage methods. More...
Public Member Functions | |
| INIFactory () | |
| Constructs a default INIFactory with default delimiter and comment settings. | |
| INIFactory (const INIFactory &reader)=delete | |
| Deleted copy constructor to prevent unintended duplication of option ownership. | |
| INIFactory (INIFactory &&reader) noexcept | |
| Move constructor that transfers ownership of all options and state. | |
| virtual | ~INIFactory () |
| Virtual destructor that cleans up all owned INIOption instances. | |
| void | addINIOption (const StringView &label, INIOption *option) |
| Registers an INIOption under the given label. | |
| bool | addManagedOption (const StringView &option_label, const StringView &option, bool replace=true) |
| Adds or updates a managed string option that is stored internally by the factory. | |
| template<class t_type, uint01 t_row_dims, uint01 t_col_dims> | |
| void | addOption (const String &label, Resource< Matrix< t_type, t_row_dims, t_col_dims > > &mem_loc) |
| Registers a Matrix Resource option that will be read/written by the factory. | |
| template<class t_type> | |
| void | addOption (const StringView &label, const Resource< t_type > &mem_loc)=delete |
| Deleted overload to prevent binding to const Resource references. | |
| template<class t_type> | |
| void | addOption (const StringView &label, const t_type &mem_loc)=delete |
| Deleted overload to prevent binding to const references. | |
| template<class t_type> | |
| void | addOption (const StringView &label, Resource< t_type > &mem_loc) |
| Registers a Resource option that will be read/written by the factory. | |
| template<uint01 t_dims, class t_type> | |
| void | addOption (const StringView &label, Resource< Vector< t_dims, t_type > > &mem_loc) |
| Registers a Vector Resource option that will be read/written by the factory. | |
| template<class t_type> | |
| void | addOption (const StringView &label, t_type &mem_loc) |
| Registers a raw typed option that will be read/written by the factory. | |
| template<uint01 t_dims, class t_type> | |
| void | addOption (const StringView &label, Vector< t_dims, t_type > &mem_loc) |
| Registers a raw Vector option that will be read/written by the factory. | |
| void | clear () |
| Removes all registered options and frees their memory. | |
| Dictionary< String, String > | extraOptions () const |
| Returns a copy of all extra (unregistered) options as key-value pairs. | |
| Dictionary< String, String * > & | extraOptionsRef () |
| Returns a mutable reference to the extra options dictionary. | |
| String | getOption (const StringView &option, const StringView &default_value=StringView()) const |
| Retrieves the string value of a registered or extra option by label. | |
| bool | hasOption (const StringView &option) const |
| Checks whether an option with the given label has been registered. | |
| bool | hasOption (uint08 hash_option) const |
| Checks whether an option with the given hash exists. | |
| bool | preserveOrder () const |
| Returns whether the factory preserves option ordering. | |
| void | read (Scanner &file) |
| Reads option values from a Scanner stream, applying them to registered options. | |
| void | readAsciiFile (File &file) |
| Reads all options from an ASCII-formatted INI file. | |
| void | readBinaryFile (File &file) |
| Reads all options from a binary-formatted INI file. | |
| void | setComment (char comment) |
| Sets the comment character used to identify comment lines in the INI file. | |
| void | setDelimiter (char delimiter) |
| Sets the delimiter character used to separate keys from values. | |
| void | setPreserveOrder (bool preserve_order) |
| Sets whether to preserve the order in which options appear in the file. | |
| void | setUseHashLabels (bool use_hash_labels) |
| Enables or disables using hashed labels for option lookup. | |
| void | writeToAsciiFile (File &file, bool include_end_comment=false) |
| Writes all registered options to an ASCII-formatted INI file. | |
| void | writeToBinaryFile (File &file) |
| Writes all registered options to a binary-formatted INI file. | |
| void | writeToLog (const StringView &title, LogPtr &log, uint01 log_level=2) |
| Writes all registered options to a log with the given title and level. | |
Static Public Member Functions | |
| static void | ConvertFromINIString (String &s) |
| Converts INI escape sequences in a string back to their original characters. | |
| static void | ConvertToINIString (String &s) |
| Converts special characters in a string to INI-safe escape sequences. | |
| template<class t_type> | |
| static INIOption * | ToOption (Resource< t_type > &value) |
| Creates an INIOption wrapper for a Resource variable. | |
| template<class t_type> | |
| static INIOption * | ToOption (t_type &mem_loc) |
| Creates an INIOption wrapper for a raw typed variable. | |
Contains methods for easily reading and writing to an INI file including efficient casting, callback, and variable storage methods.
addOption functions take a REFERENCE to an object and will modify that reference when option is read in.
Definition at line 106 of file INIReader.h.
|
noexcept |
Move constructor that transfers ownership of all options and state.
| [in] | reader | The INIFactory to move from. |
References INIFactory().
| void INIFactory::addINIOption | ( | const StringView & | label, |
| INIOption * | option ) |
Registers an INIOption under the given label.
Takes ownership of the option pointer.
| [in] | label | The key name for this option in the INI file. |
| [in] | option | The INIOption to register. Ownership is transferred to the factory. |
Referenced by addOption(), addOption(), addOption(), addOption(), and addOption().
| bool INIFactory::addManagedOption | ( | const StringView & | option_label, |
| const StringView & | option, | ||
| bool | replace = true ) |
Adds or updates a managed string option that is stored internally by the factory.
| [in] | option_label | The key name for this option. |
| [in] | option | The string value to store. |
| [in] | replace | Whether to replace the value if the label already exists. |
Referenced by TranslationTools::addOption().
|
inline |
Registers a Matrix Resource option that will be read/written by the factory.
| [in] | label | The key name for this option in the INI file. |
| [in] | mem_loc | Reference to the Resource<Matrix> that will be updated when the option is read. |
Definition at line 193 of file INIReader.h.
References addINIOption().
|
inline |
Registers a Resource option that will be read/written by the factory.
| [in] | label | The key name for this option in the INI file. |
| [in] | mem_loc | Reference to the Resource that will be updated when the option is read. |
Definition at line 167 of file INIReader.h.
References addINIOption().
|
inline |
Registers a Vector Resource option that will be read/written by the factory.
| [in] | label | The key name for this option in the INI file. |
| [in] | mem_loc | Reference to the Resource<Vector> that will be updated when the option is read. |
Definition at line 141 of file INIReader.h.
References addINIOption().
Referenced by RasterInfo::getINI().
|
inline |
Registers a raw typed option that will be read/written by the factory.
| [in] | label | The key name for this option in the INI file. |
| [in] | mem_loc | Reference to the variable that will be updated when the option is read. |
Definition at line 182 of file INIReader.h.
References addINIOption().
|
inline |
Registers a raw Vector option that will be read/written by the factory.
| [in] | label | The key name for this option in the INI file. |
| [in] | mem_loc | Reference to the Vector that will be updated when the option is read. |
Definition at line 152 of file INIReader.h.
References addINIOption().
|
static |
Converts INI escape sequences in a string back to their original characters.
| [in] | s | The string to convert in-place. |
|
static |
Converts special characters in a string to INI-safe escape sequences.
| [in] | s | The string to convert in-place. |
| Dictionary< String, String > INIFactory::extraOptions | ( | ) | const |
Returns a copy of all extra (unregistered) options as key-value pairs.
Referenced by TranslationTools::convertFromBrackets().
|
inline |
Returns a mutable reference to the extra options dictionary.
Definition at line 305 of file INIReader.h.
Referenced by TranslationTools::convertBrackets(), and TranslationTools::convertFromBrackets().
| String INIFactory::getOption | ( | const StringView & | option, |
| const StringView & | default_value = StringView() ) const |
Retrieves the string value of a registered or extra option by label.
| [in] | option | The label of the option to retrieve. |
| [in] | default_value | The value to return if the option is not found. |
Referenced by TranslationTools::addOption().
| bool INIFactory::hasOption | ( | const StringView & | option | ) | const |
Checks whether an option with the given label has been registered.
| [in] | option | The label to search for. |
Referenced by TranslationTools::addOption().
| bool INIFactory::hasOption | ( | uint08 | hash_option | ) | const |
Checks whether an option with the given hash exists.
| [in] | hash_option | The hash of the label to search for. |
|
inline |
Returns whether the factory preserves option ordering.
Definition at line 266 of file INIReader.h.
| void INIFactory::read | ( | Scanner & | file | ) |
Reads option values from a Scanner stream, applying them to registered options.
| [in] | file | The scanner to read from. |
| void INIFactory::readAsciiFile | ( | File & | file | ) |
Reads all options from an ASCII-formatted INI file.
| [in] | file | The file to read from. |
Referenced by IMUNoiseSimulator::loadAccelerometerSettings(), IMUNoiseSimulator::loadGyroSettings(), and TranslationTools::makeTranslation().
| void INIFactory::readBinaryFile | ( | File & | file | ) |
Reads all options from a binary-formatted INI file.
| [in] | file | The file to read from. |
|
inline |
Sets the comment character used to identify comment lines in the INI file.
| [in] | comment | The comment character (e.g., '#' or ';'). |
Definition at line 236 of file INIReader.h.
| void INIFactory::setDelimiter | ( | char | delimiter | ) |
Sets the delimiter character used to separate keys from values.
| [in] | delimiter | The delimiter character (e.g., '=' or ':'). |
|
inline |
Sets whether to preserve the order in which options appear in the file.
| [in] | preserve_order | True to maintain insertion order during writes. |
Definition at line 260 of file INIReader.h.
Referenced by IMUNoiseSimulator::loadAccelerometerSettings(), IMUNoiseSimulator::loadGyroSettings(), TranslationTools::makeTranslation(), IMUNoiseSimulator::saveAccelerometerSettings(), and IMUNoiseSimulator::saveGyroSettings().
| void INIFactory::setUseHashLabels | ( | bool | use_hash_labels | ) |
Enables or disables using hashed labels for option lookup.
| [in] | use_hash_labels | True to use hash-based label lookup. |
Referenced by TranslationTools::makeTranslation().
|
inlinestatic |
Creates an INIOption wrapper for a raw typed variable.
| [in] | mem_loc | Reference to the variable to wrap. |
Definition at line 333 of file INIReader.h.
Referenced by ApplicationOption< t_type >::iniOption().
| void INIFactory::writeToAsciiFile | ( | File & | file, |
| bool | include_end_comment = false ) |
Writes all registered options to an ASCII-formatted INI file.
| [in] | file | The file to write to. |
| [in] | include_end_comment | Whether to append a trailing comment marker. |
Referenced by TranslationTools::makeTranslation(), IMUNoiseSimulator::saveAccelerometerSettings(), and IMUNoiseSimulator::saveGyroSettings().
| void INIFactory::writeToBinaryFile | ( | File & | file | ) |
Writes all registered options to a binary-formatted INI file.
| [in] | file | The file to write to. |
| void INIFactory::writeToLog | ( | const StringView & | title, |
| LogPtr & | log, | ||
| uint01 | log_level = 2 ) |
Writes all registered options to a log with the given title and level.
| [in] | title | The title to display in the log entry. |
| [in] | log | The log to write to. |
| [in] | log_level | The verbosity level for the log entry. |