Beispiel #1
0
/*!

\brief Appends a string to the current config context value.
\param[in] Value String containing value to be appended.
\param[in] IsFormatted If set to dmz::True the config context will be marked as
containing formatted data.
\return Returns dmz::True if the value was appended successfully.

*/
dmz::Boolean
dmz::Config::append_value (const String &Value, const Boolean IsFormatted) {

    Boolean result (False);

    if (_state.context) {

        if (!_state.context->Name) {

            if (IsFormatted) {
                _state.context->isFormatted = True;
            }

            ConfigAttributeContext *ac (_state.context->attrTable.lookup (""));

            if (!ac) {

                ac = new ConfigAttributeContext (Value);
                if (ac && _state.context->attrTable.store ("", ac)) {
                    result = True;
                }
                else if (ac) {
                    delete ac;
                    ac = 0;
                }
            }
            else {

                result = True;

                ac->lock.lock ();
                ac->value << Value;
                ac->lock.unlock ();
            }
        }
        else {

            ConfigContext *cd (new ConfigContext (""));

            if (cd) {

                cd->isFormatted = IsFormatted;
                ConfigAttributeContext *ptr = new ConfigAttributeContext (Value);
                if (ptr && !cd->attrTable.store ("", ptr)) {
                    delete ptr;
                    ptr = 0;
                }
                _state.context->add_config (cd);
                result = True;
                cd->unref ();
                cd = 0;
            }
        }
    }

    return result;
}
Beispiel #2
0
 ~State () { if (context) { context->unref (); context = 0; } }