|
Fcitx
|
A raw configuration tree that stores key-value pairs in a hierarchical structure. More...
#include <fcitx-config/rawconfig.h>
Public Member Functions | |
| RawConfig () | |
| Construct a RawConfig with an empty name. More... | |
| std::shared_ptr< RawConfig > | get (const std::string &path, bool create=false) |
| Get a sub-item by path. More... | |
| std::shared_ptr< const RawConfig > | get (const std::string &path) const |
| bool | remove (const std::string &path) |
| Remove a sub-item by path. More... | |
| void | removeAll () |
| Remove all sub-items. More... | |
| void | setValue (std::string value) |
| Set the value of this node. More... | |
| void | setComment (std::string comment) |
| Set the comment for this node. More... | |
| void | setLineNumber (unsigned int lineNumber) |
| Set the line number where this node was parsed from. More... | |
| void | setImplicit (bool implicit) |
| Mark this config node as implicit (default value that won't be written to INI). More... | |
| const std::string & | name () const |
| Get the name of this node. More... | |
| const std::string & | comment () const |
| Get the comment for this node. More... | |
| const std::string & | value () const |
| Get the value of this node. More... | |
| unsigned int | lineNumber () const |
| Get the line number where this node was parsed from. More... | |
| bool | isImplicitSelf () const |
| Check if this node itself is marked as implicit. More... | |
| bool | isImplicit () const |
| Check if this node or any of its ancestors is marked as implicit. More... | |
| bool | hasSubItems () const |
| Check if this node has any sub-items. More... | |
| size_t | subItemsSize () const |
| Get the number of sub-items. More... | |
| std::vector< std::string > | subItems () const |
| Get a list of sub-item names. More... | |
| void | setValueByPath (const std::string &path, std::string value) |
| Set a value by path, creating intermediate nodes if needed. More... | |
| const std::string * | valueByPath (const std::string &path) const |
| Get a value by path. More... | |
| RawConfig & | operator[] (const std::string &path) |
| Get or create a sub-item by path. More... | |
| RawConfig & | operator= (std::string value) |
| Assign a string value to this node. More... | |
| bool | operator== (const RawConfig &other) const |
| Check if two RawConfig trees are equal. More... | |
| bool | operator!= (const RawConfig &config) const |
| Check if two RawConfig trees are not equal. More... | |
| RawConfig * | parent () const |
| Get the parent node. More... | |
| std::shared_ptr< RawConfig > | detach () |
| Detach this node from its parent. More... | |
| bool | visitSubItems (std::function< bool(RawConfig &, const std::string &path)> callback, const std::string &path="", bool recursive=false, const std::string &pathPrefix="") |
| Visit all sub-items. More... | |
| bool | visitSubItems (std::function< bool(const RawConfig &, const std::string &path)> callback, const std::string &path="", bool recursive=false, const std::string &pathPrefix="") const |
| void | visitItemsOnPath (std::function< void(RawConfig &, const std::string &path)> callback, const std::string &path) |
| Visit all items on a path. More... | |
| void | visitItemsOnPath (std::function< void(const RawConfig &, const std::string &path)> callback, const std::string &path) const |
Friends | |
| class | RawConfigPrivate |
A raw configuration tree that stores key-value pairs in a hierarchical structure.
RawConfig represents a configuration as a tree of nodes, where each node can have a value and sub-items. For example, It supports reading from and writing to INI format, and can represent configuration with implicit (default) values.
Definition at line 37 of file rawconfig.h.
| fcitx::RawConfig::RawConfig | ( | ) |
Construct a RawConfig with an empty name.
Definition at line 132 of file rawconfig.cpp.
| const std::string & fcitx::RawConfig::comment | ( | ) | const |
Get the comment for this node.
Definition at line 212 of file rawconfig.cpp.
| std::shared_ptr< RawConfig > fcitx::RawConfig::detach | ( | ) |
Detach this node from its parent.
Definition at line 268 of file rawconfig.cpp.
| std::shared_ptr< RawConfig > fcitx::RawConfig::get | ( | const std::string & | path, |
| bool | create = false |
||
| ) |
Get a sub-item by path.
| path | path to the sub-item, using '/' as separator |
| create | if true, create intermediate nodes if they don't exist |
Definition at line 153 of file rawconfig.cpp.
| std::shared_ptr< const RawConfig > fcitx::RawConfig::get | ( | const std::string & | path | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 164 of file rawconfig.cpp.
| bool fcitx::RawConfig::hasSubItems | ( | ) | const |
Check if this node has any sub-items.
Definition at line 243 of file rawconfig.cpp.
| bool fcitx::RawConfig::isImplicit | ( | ) | const |
Check if this node or any of its ancestors is marked as implicit.
Definition at line 232 of file rawconfig.cpp.
| bool fcitx::RawConfig::isImplicitSelf | ( | ) | const |
Check if this node itself is marked as implicit.
Definition at line 227 of file rawconfig.cpp.
| unsigned int fcitx::RawConfig::lineNumber | ( | ) | const |
Get the line number where this node was parsed from.
Definition at line 222 of file rawconfig.cpp.
| const std::string & fcitx::RawConfig::name | ( | ) | const |
Get the name of this node.
Definition at line 207 of file rawconfig.cpp.
|
inline |
Check if two RawConfig trees are not equal.
| config | the other RawConfig to compare with |
Definition at line 218 of file rawconfig.h.
|
inline |
Assign a string value to this node.
| value | the value to assign |
Definition at line 184 of file rawconfig.h.
|
inline |
Check if two RawConfig trees are equal.
| other | the other RawConfig to compare with |
Definition at line 195 of file rawconfig.h.
|
inline |
Get or create a sub-item by path.
| path | path to the sub-item, using '/' as separator |
Definition at line 176 of file rawconfig.h.
| RawConfig * fcitx::RawConfig::parent | ( | ) | const |
Get the parent node.
Definition at line 263 of file rawconfig.cpp.
| bool fcitx::RawConfig::remove | ( | const std::string & | path | ) |
Remove a sub-item by path.
| path | path to the item to remove |
Definition at line 169 of file rawconfig.cpp.
| void fcitx::RawConfig::removeAll | ( | ) |
Remove all sub-items.
Definition at line 182 of file rawconfig.cpp.
| void fcitx::RawConfig::setComment | ( | std::string | comment | ) |
Set the comment for this node.
| comment | the comment to set |
Definition at line 192 of file rawconfig.cpp.
| void fcitx::RawConfig::setImplicit | ( | bool | implicit | ) |
Mark this config node as implicit (default value that won't be written to INI).
| implicit | true to mark as implicit, false otherwise |
Definition at line 202 of file rawconfig.cpp.
| void fcitx::RawConfig::setLineNumber | ( | unsigned int | lineNumber | ) |
Set the line number where this node was parsed from.
| lineNumber | the line number |
Definition at line 197 of file rawconfig.cpp.
| void fcitx::RawConfig::setValue | ( | std::string | value | ) |
Set the value of this node.
| value | the value to set |
Definition at line 187 of file rawconfig.cpp.
|
inline |
Set a value by path, creating intermediate nodes if needed.
| path | path to the value, using '/' as separator |
| value | the value to set |
Definition at line 155 of file rawconfig.h.
| std::vector< std::string > fcitx::RawConfig::subItems | ( | ) | const |
Get a list of sub-item names.
Definition at line 253 of file rawconfig.cpp.
| size_t fcitx::RawConfig::subItemsSize | ( | ) | const |
Get the number of sub-items.
Definition at line 248 of file rawconfig.cpp.
| const std::string & fcitx::RawConfig::value | ( | ) | const |
Get the value of this node.
Definition at line 217 of file rawconfig.cpp.
|
inline |
Get a value by path.
| path | path to the value, using '/' as separator |
Definition at line 165 of file rawconfig.h.
| void fcitx::RawConfig::visitItemsOnPath | ( | std::function< void(RawConfig &, const std::string &path)> | callback, |
| const std::string & | path | ||
| ) |
Visit all items on a path.
| callback | function to call for each item on the path |
| path | the path to visit |
Definition at line 316 of file rawconfig.cpp.
| void fcitx::RawConfig::visitItemsOnPath | ( | std::function< void(const RawConfig &, const std::string &path)> | callback, |
| const std::string & | path | ||
| ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 321 of file rawconfig.cpp.
| bool fcitx::RawConfig::visitSubItems | ( | std::function< bool(RawConfig &, const std::string &path)> | callback, |
| const std::string & | path = "", |
||
| bool | recursive = false, |
||
| const std::string & | pathPrefix = "" |
||
| ) |
Visit all sub-items.
| callback | function to call for each sub-item, return false to stop |
| path | path to start visiting from, empty for root |
| recursive | if true, visit sub-items recursively |
| pathPrefix | prefix to prepend to paths in callback |
Definition at line 279 of file rawconfig.cpp.
| bool fcitx::RawConfig::visitSubItems | ( | std::function< bool(const RawConfig &, const std::string &path)> | callback, |
| const std::string & | path = "", |
||
| bool | recursive = false, |
||
| const std::string & | pathPrefix = "" |
||
| ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 297 of file rawconfig.cpp.
1.8.13