src/components/config.cpp
/**
 * Look for sections set up to inherit from a base section
 * and copy the missing parameters
 *
 * Multiple sections can be specified, separated by a space.
 *
 *   [sub/section]
 *   inherit = section1 section2
 */
Look for sections set up to inherit from a base section
and copy the missing parameters

Multiple sections can be specified, separated by a space.

[sub/section]
inherit = section1 section2
Look for sections set up to inherit from a base section and copy the missing parameters Multiple sections can be specified separated by a space . [ sub / section ] inherit = section1 section2
void config::copy_inherited() {
  for (auto&& section : m_sections) {
    std::vector<string> inherit_sections;
    for (auto&& param : section.second) {
      string key_name = param.first;
      if (key_name == "inherit") {
        auto inherit = param.second;
        inherit = dereference<string>(section.first, key_name, inherit, inherit);
        std::vector<string> sections = string_util::split(std::move(inherit), ' ');
        inherit_sections.insert(inherit_sections.end(), sections.begin(), sections.end());
      } else if (key_name.find("inherit") == 0) {
        m_log.warn(
            "\"%s.%s\": Using anything other than 'inherit' for inheriting section keys is deprecated. "
            "The 'inherit' key supports multiple section names separated by a space.",
            section.first, key_name);
        auto inherit = param.second;
        inherit = dereference<string>(section.first, key_name, inherit, inherit);
        if (inherit.empty() || m_sections.find(inherit) == m_sections.end()) {
          throw value_error(
              "Invalid section \"" + inherit + "\" defined for \"" + section.first + "." + key_name + "\"");
        }
        inherit_sections.push_back(std::move(inherit));
      }
    }
    for (const auto& base_name : inherit_sections) {
      const auto base_section = m_sections.find(base_name);
      if (base_section == m_sections.end()) {
        throw value_error("Invalid section \"" + base_name + "\" defined for \"" + section.first + ".inherit\"");
      }
      m_log.trace("config: Inheriting keys from \"%s\" in \"%s\"", base_name, section.first);
      for (auto&& base_param : base_section->second) {
        section.second.emplace(base_param.first, base_param.second);
      }
    }
  }
}
void config :: copy_inherited ( ) { for ( auto && section : m_sections ) { std :: vector < string > inherit_sections ; for ( auto && param : section . second ) { string key_name = param . first ; if ( key_name == " " ) { auto inherit = param . second ; inherit = dereference < string > ( section . first , key_name , inherit , inherit ) ; std :: vector < string > sections = string_util :: split ( std :: move ( inherit ) , ' ' ) ; inherit_sections . insert ( inherit_sections . end ( ) , sections . begin ( ) , sections . end ( ) ) ; } else if ( key_name . find ( " " ) == 0 ) { m_log . warn ( " \" \" " " " , section . first , key_name ) ; auto inherit = param . second ; inherit = dereference < string > ( section . first , key_name , inherit , inherit ) ; if ( inherit . empty ( ) || m_sections . find ( inherit ) == m_sections . end ( ) ) { throw value_error ( " \" " + inherit + " \" \" " + section . first + " " + key_name + " \" " ) ; } inherit_sections . push_back ( std :: move ( inherit ) ) ; } } for ( const auto & base_name : inherit_sections ) { const auto base_section = m_sections . find ( base_name ) ; if ( base_section == m_sections . end ( ) ) { throw value_error ( " \" " + base_name + " \" \" " + section . first + " \" " ) ; } m_log . trace ( " \" \" \" \" " , base_name , section . first ) ; for ( auto && base_param : base_section -> second ) { section . second . emplace ( base_param . first , base_param . second ) ; } } } }
Look for sections set up to inherit from a base section
 and copy the missing parameters
Look for sections set up to inherit from a base section and copy the missing parameters
// Collect all sections to be inherited // Legacy support for keys that just start with 'inherit' /*
       * Iterate the base and copy the parameters that haven't been defined
       * yet.
       */