Example #1
0
dmz::Config
dmz::QtCanvasViewSession::get_config () {

   String val;
   Config session ("canvasView");

   val.flush () << _canvas.get_scale ();
   session.store_attribute ("scale", val);

   val.flush () << _canvas.width ();
   session.store_attribute ("width", val);

   val.flush () << _canvas.height ();
   session.store_attribute ("height", val);

   Config scrollBars ("scrollBars");

   val.flush () << _canvas.verticalScrollBar ()->value ();
   scrollBars.store_attribute ("vertical", val);

   val.flush () << _canvas.horizontalScrollBar ()->value ();
   scrollBars.store_attribute ("horizontal", val);

   session.add_config (scrollBars);

   return session;
}
Example #2
0
/*!

\brief Gets the current value store in the config context.
\param[out] value String used to store the config context value.
\return Returns dmz::True if the config context value was stored in \a value.

*/
dmz::Boolean
dmz::Config::get_value (String &value) const {

    Boolean result (False);

    if (_state.context) {

        if (!_state.context->Name) {

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

            if (at) {

                result = True;

                at->lock.lock ();
                value.flush () << at->value;
                at->lock.unlock ();
            }
        }
        else {

            ConfigContext::DataList *dl (_state.context->configTable.lookup (""));

            if (dl) {

                result = True;

                value.flush ();
                dl->lock.lock ();
                ConfigContext::DataStruct *ds (dl->head);
                while (ds) {

                    if (ds->handle && ds->context) {

                        ConfigAttributeContext *at (ds->context->attrTable.lookup (""));

                        if (at) {

                            at->lock.lock ();
                            value << at->value;
                            at->lock.unlock ();
                        }
                    }

                    ds = ds->next;
                }
                dl->lock.unlock ();
            }
        }
    }

    return result;
}
   Boolean zip_error (const int Err) {

      Boolean result (Err == ZIP_OK ? True : False);

      if (!result) {

         if (Err == ZIP_ERRNO) { error.flush () << strerror (errno); }
         else if (Err == ZIP_PARAMERROR) { error.flush () << "Parameter Error."; }
         else if (Err == ZIP_BADZIPFILE) { error.flush () << "Bad Zip File."; }
         else if (Err == ZIP_INTERNALERROR) { error.flush () << "Internal Zip Error."; }
         else { error.flush () << "Unknown Zip Error."; }
      }

      return result;
   }
Example #4
0
/*!

\brief Splits a path into the directory, file name, and file extension.
\ingroup System
\details Defined in dmzSystemFile.h.
The \a FullPath is formatted before processing. The file extension is returned with
the leading period. If either a path or extension is not found in the \a FullPath,
the corresponding return value is an empty string.
\param[in] FullPath String containing full path to be split up.
\param[out] path String containing the directory component of the \a FullPath.
\param[out] file String containing the file component of the \a FullPath.
\param[out] ext String containing the extension of the \a FullPath.

*/
void
dmz::split_path_file_ext (
    const String &FullPath,
    String &path,
    String &file,
    String &ext) {

    path = format_path (FullPath);
    file.flush ();
    ext.flush ();

    const Int32 Length = path.get_length ();

    Int32 slashFound = -1;
    Int32 index = Length - 1;

    Boolean done (False);

    while (!done) {

        if (path.get_char (index) == '/') {
            slashFound = index;
            done = True;
        }
        else {
            index--;
            if (index < 0) {
                done = True;
            }
        }
    }

    if (slashFound >= 0) {

        file = path.get_sub (slashFound + 1);
        path = path.get_sub (0, slashFound);
    }
    else {

        file = path;
        path.flush ();
    }

    if (file) {

        const Int32 FileLength = file.get_length ();
        Int32 dotFound = -1;

        index = FileLength - 1;
        done = False;

        while (!done) {

            if (file.get_char (index) == '.') {
                dotFound = index;
                done = True;
            }
            else {
                index--;
                if (index < 0) {
                    done = True;
                }
            }
        }

        if (dotFound > 0) {

            ext = file.get_sub (dotFound);
            file = file.get_sub (0, dotFound - 1);
        }
    }
}
Example #5
0
   void clear () {

      index = -1;
      key.flush ();
      growCount = 0;
   }