| 
    autotier
    
   Automatic Tiering Fuse Filesystem 
   | 
 
Main configuration parser class to inherit from in your code. More...
#include <ConfigParser.hpp>

Public Member Functions | |
| ConfigParser (std::string path) | |
| Construct a new Config Parser object.  More... | |
| std::string | dump_str (void) const | 
| Dump config to stdout as a string.  More... | |
| template<class T > | |
| T | get (const std::string &key) const | 
| Get value from config map using ffd::get(). This can throw. Use this in a try...catch block.  More... | |
| template<class T > | |
| T | get (const std::string &key, const T &fallback) const noexcept | 
| Try to get value from config, default to fallback if fails. Guaranteed no-throw.  More... | |
| template<class T > | |
| T | get (const std::string &key, bool *fail_flag) const noexcept | 
| Try to get value from config. If ffd::get fails, return T() or 0 and set fail_flag. Guaranteed no-throw. Prints message to std::cerr to explain error.  More... | |
| template<class T > | |
| T | get_from (const std::string §ion, const std::string &key) | 
| Adapter for ffd::get(). Sets config_map_ptr_ to address of sub config with name section. This can throw.  More... | |
| template<class T > | |
| T | get_from (const std::string §ion, const std::string &key, const T &fallback) noexcept | 
| Get value from config subsection using ConfigParser::get(const std::string&,const T&) const noexcept, return fallback if the subsection DNE.  More... | |
| template<class T > | |
| T | get_from (const std::string §ion, const std::string &key, bool *fail_flag) noexcept | 
| Get value from config subsection using ConfigParser::get(const std::string&,bool*) const noexcept, set fail_flag if the subsection DNE.  More... | |
| Quota | get_quota (const std::string &key, const Bytes &max) const | 
| Get quota from config map using ffd::get(). This can throw. Use this in a try...catch block.  More... | |
| Quota | get_quota (const std::string &key, const Bytes &max, const Quota &fallback) const noexcept | 
| Try to get Quota from config, default to fallback if fails. Guaranteed no-throw.  More... | |
| Quota | get_quota (const std::string &key, const Bytes &max, bool *fail_flag) const noexcept | 
| Try to get Quota from config. If ffd::get fails, return Quota(void) and set fail_flag. Guaranteed no-throw. Prints message to std::cerr to explain error.  More... | |
| Quota | get_quota_from (const std::string §ion, const std::string &key, const Bytes &max) | 
| Adapter for ffd::get(). Sets config_map_ptr_ to address of sub config with name section. This can throw.  More... | |
| Quota | get_quota_from (const std::string §ion, const std::string &key, const Bytes &max, const Quota &fallback) noexcept | 
| Get value from config subsection using ConfigParser::get(const std::string&,const T&) const noexcept, return fallback if the subsection DNE.  More... | |
| Quota | get_quota_from (const std::string §ion, const std::string &key, const Bytes &max, bool *fail_flag) noexcept | 
| Get value from config subsection using ConfigParser::get(const std::string&,bool*) const noexcept, set fail_flag if the subsection DNE.  More... | |
Protected Attributes | |
| std::vector< ConfigNode * > | sub_confs_ | 
| Vector of config subsections.  | |
| std::string | current_section_ | 
| Name of current section, set by set_subsection()  | |
Private Member Functions | |
| void | parse (std::ifstream &file) | 
| Iterate each line of config file and determine how to parse with l::check_record_type()  More... | |
| void | parse_entry (const std::string &line) | 
| Extract value from config line and insert ConfigNode into config_map_.  More... | |
| void | parse_heading (const std::string &line) | 
| Create new subconfig.  More... | |
| void | set_subsection (const std::string §ion) | 
| Update config_map_ptr_ to the subconfig map for section.  More... | |
| void | reset_subsection (void) noexcept | 
| Set config_map_ptr_ back to the address of config_map_.  More... | |
| void | report_error (const std::string &message) const noexcept | 
| Print error message to stderr, conditionally prepended with current subsection name.  More... | |
Private Attributes | |
| bool | guarded_ | 
| true if a ConfigSubsectionGuard is in scope Set in ConfigSubsectionGuard::ConfigSubsectionGuard() Cleared in ConfigSubsectionGuard::~ConfigSubsectionGuard()  | |
| std::unordered_map< std::string, ConfigNode > * | config_map_ptr_ | 
| Pointer to current config map.  | |
| std::string | path_ | 
| Path to config file.  | |
| std::unordered_map< std::string, ConfigNode > | config_map_ | 
| Map of config keys (std::string) to values (ConfigNode)  | |
Friends | |
| class | ConfigSubsectionGuard | 
| Guard to change config subsection within a scope: ConfigSubsectionGuard.  | |
Main configuration parser class to inherit from in your code.
Example usage:
| ffd::ConfigParser::ConfigParser | ( | std::string | path | ) | 
Construct a new Config Parser object.
Opens file at path as an std::ifstream and calls ConfigParser::parse()
| path | Path to config file | 
| std::string ffd::ConfigParser::dump_str | ( | void | ) | const | 
Dump config to stdout as a string.
      
  | 
  inline | 
Get value from config map using ffd::get(). This can throw. Use this in a try...catch block.
| T | Type of variable to get | 
| key | Key to index config_map_ | 
      
  | 
  inlinenoexcept | 
Try to get value from config. If ffd::get fails, return T() or 0 and set fail_flag. Guaranteed no-throw. Prints message to std::cerr to explain error.
Example:
| T | Type of variable to return | 
| key | Key to index config_map_ | 
| fail_flag | Pointer to flag to set if ffd::get() fails | 
      
  | 
  inlinenoexcept | 
Try to get value from config, default to fallback if fails. Guaranteed no-throw.
Example:
| T | Type of variable to return | 
| key | Key to index config_map_ | 
| fallback | Default value to return if ffd::get() fails. | 
      
  | 
  inline | 
Adapter for ffd::get(). Sets config_map_ptr_ to address of sub config with name section. This can throw.
| T | Type of variable to get | 
| section | Subsection heading from config | 
| key | Key to index config_map_ | 
      
  | 
  inlinenoexcept | 
Get value from config subsection using ConfigParser::get(const std::string&,bool*) const noexcept, set fail_flag if the subsection DNE.
| T | Type to return | 
| section | Config section name to get value from | 
| key | Key identifying value in config | 
| fail_flag | Pointer to flag to be set if error or DNE | 
      
  | 
  inlinenoexcept | 
Get value from config subsection using ConfigParser::get(const std::string&,const T&) const noexcept, return fallback if the subsection DNE.
Example:
| T | Type to return | 
| section | Config section name to get value from | 
| key | Key identifying value in config | 
| fallback | Returned if error or DNE | 
Get quota from config map using ffd::get(). This can throw. Use this in a try...catch block.
| key | Key to index config_map_ | 
| max | Maximum number of bytes | 
      
  | 
  inlinenoexcept | 
Try to get Quota from config. If ffd::get fails, return Quota(void) and set fail_flag. Guaranteed no-throw. Prints message to std::cerr to explain error.
| key | Key to index config_map_ | 
| max | Maximum number of bytes | 
| fail_flag | Pointer to flag to set if ffd::get() fails | 
      
  | 
  inlinenoexcept | 
Try to get Quota from config, default to fallback if fails. Guaranteed no-throw.
| key | Key to index config_map_ | 
| max | Maximum number of bytes | 
| fallback | Default value to return if ffd::get() fails. | 
      
  | 
  inline | 
Adapter for ffd::get(). Sets config_map_ptr_ to address of sub config with name section. This can throw.
| section | Subsection heading from config | 
| key | Key to index config_map_ | 
| max | Maximum number of bytes | 
      
  | 
  inlinenoexcept | 
Get value from config subsection using ConfigParser::get(const std::string&,bool*) const noexcept, set fail_flag if the subsection DNE.
| section | Config section name to get value from | 
| key | Key identifying value in config | 
| max | Maximum number of bytes | 
| fail_flag | Pointer to flag to be set if error or DNE | 
      
  | 
  inlinenoexcept | 
Get value from config subsection using ConfigParser::get(const std::string&,const T&) const noexcept, return fallback if the subsection DNE.
Example:
| section | Config section name to get value from | 
| key | Key identifying value in config | 
| max | Maximum number of bytes | 
| fallback | Returned if error or DNE | 
      
  | 
  private | 
Iterate each line of config file and determine how to parse with l::check_record_type()
| Case | Function Called | 
|---|---|
| l::RecordType::UNK | prints error message and continues | 
| l::RecordType::ENTRY | ConfigParser::parse_entry() | 
| l::RecordType::HEADING | ConfigParser::parse_heading() | 
| l::RecordType::EMPTY | continues | 
| file | Opened file stream for config file | 
      
  | 
  private | 
Extract value from config line and insert ConfigNode into config_map_.
| line | String containing some form of "key = value" | 
      
  | 
  private | 
Create new subconfig.
construct new ConfigNode containing name and new config map, assign config_map_ptr_ to address of new config map, place into global config_map_, push address of new ConfigNode into sub_confs_
| line | String containing some form of "[Section Name]" | 
      
  | 
  inlineprivatenoexcept | 
Print error message to stderr, conditionally prepended with current subsection name.
| message | 
      
  | 
  inlineprivatenoexcept | 
Set config_map_ptr_ back to the address of config_map_.
      
  | 
  inlineprivate | 
Update config_map_ptr_ to the subconfig map for section.
| section | The config section to set to | 
 1.8.17