コード例 #1
0
ファイル: dmzRuntimeConfig.cpp プロジェクト: ben-sangster/dmz
/*!

\brief Removes config contexts found at the specified scope path.
\param[in] Scope String containing scope to use when overwriting.
\return Returns dmz::True if config context was successfully removed.

*/
dmz::Boolean
dmz::Config::remove_config (const String &Scope) {

   Boolean result = False;

   if (Scope) {

      result = True;

      String value, remainder;

      if (pop_last_config_scope_element (Scope, value, remainder)) {

         Config list;

         lookup_all_config (remainder, list);

         ConfigIterator it;
         Config cd;

         while (list.get_next_config (it, cd)) {

            ConfigContext *context (cd.get_config_context ());

            if (context) { context->remove_config (value); }
         }
      }
      else if (_state.context) { _state.context->remove_config (Scope); }
   }

   return result;
}
コード例 #2
0
ファイル: dmzRuntimeConfig.cpp プロジェクト: ben-sangster/dmz
/*!

\brief Overwrites config contexts found at the specified scope path.
\param[in] Scope String containing scope to use when overwriting.
\param[in] Data Config containing config context to use in the over write.
\return Returns dmz::True if config context was successfully overwritten.

*/
dmz::Boolean
dmz::Config::overwrite_config (const String &Scope, const Config &Data) {

   if (!Scope) {

      if (_state.context) { _state.context->remove_config (Data.get_name ()); }
   }
   else {

      Config list;

      lookup_all_config (Scope, list);

      ConfigIterator it;
      Config cd;

      while (list.get_next_config (it, cd)) {

         ConfigContext *context (cd.get_config_context ());

         if (context) { context->remove_config (Data.get_name ()); }
      }
   }

   return add_config (Scope, Data);
}
コード例 #3
0
ファイル: dmzRuntimeConfig.cpp プロジェクト: ben-sangster/dmz
/*!

\brief Looks up all config contexts with the given name and returns their children.
\details All children of config context found with a matching name are stored as
children of \a data. Also all attributes of the found config contexts are stored in
\a data.  If the same attributes are defined in multiple found config contexts, the
value of the last one found is used.
\param[in] Name String containing name of config contexts to lookup.
\param[out] data Config to store the children of found config contexts.
\return Returns dmz::True if any config contexts were found.

*/
dmz::Boolean
dmz::Config::lookup_all_config_merged (const String &Name, Config &data) const {

   Boolean result (False);

   Config foundData;

   if (lookup_all_config (Name, foundData)) {

      Boolean first = True;
      ConfigIterator it;
      Config tmp;

      while (foundData.get_next_config (it, tmp)) {

         if (first) { 

            Config newName (tmp.get_name ());
            data = newName;
            first = False;
            result = True;
         }

         data.copy_attributes (tmp);
         data.add_children (tmp);
      }
   }

   return result;
}
コード例 #4
0
ファイル: dmzRuntimeConfig.cpp プロジェクト: ben-sangster/dmz
/*!

\brief Looks up a config context by name.
\details If there are multiple config context with the same same name, the last
config context that was stored with the given name is returned. The \a Name parameter
may be scoped like other functions. For example, the following is valid:
\code
dmz::Config result;
global.lookup_config ("dmz.types.foo", result);
\endcode
\param[in] Name String containing name of config context to lookup.
\param[out] data Config to store the found config context.
\return Returns dmz::True if the config context was found.

*/
dmz::Boolean
dmz::Config::lookup_config (const String &Name, Config &data) const {

   Boolean result (False);
   Config tmp;

   if (lookup_all_config (Name, tmp)) {

      result = True;

      ConfigIterator it;
      tmp.get_last_config (it, data);
   }

   return result;
}
コード例 #5
0
ファイル: dmzRuntimeConfig.cpp プロジェクト: ashok/dmz
/*!

\brief Looks up all config contexts with the given name and returns their children.
\details All children of config context found with a matching name are stored as
children of \a data. Also all attributes of the found config contexts are stored in
\a data.  If the same attributes are defined in multiple found config contexts, the
value of the last one found is used.
\param[in] Name String containing name of config contexts to lookup.
\param[out] data Config to store the children of found config contexts.
\return Returns dmz::True if any config contexts were found.

*/
dmz::Boolean
dmz::Config::lookup_all_config_merged (const String &Name, Config &data) const {

    Boolean result (False);

    Config foundData;

    if (lookup_all_config (Name, foundData)) {

        ConfigIterator it;
        Config tmp;

        Boolean found (foundData.get_first_config (it, tmp));

        result = found;

        if (result) {

            Config newName (tmp.get_name ());

            data = newName;
        }

        while (found) {

            ConfigIterator attrIt;

            String name, value;

            Boolean attrFound = tmp.get_first_attribute (attrIt, name, value);

            while (attrFound) {

                data.store_attribute (name, value);

                attrFound = tmp.get_next_attribute (attrIt, name, value);
            }

            data.add_children (tmp);

            found = foundData.get_next_config (it, tmp);
        }
    }

    return result;
}