コード例 #1
0
ファイル: propertylist.cpp プロジェクト: Sneedd/penv
//----------------------------------------------------------------
void PropertyList::SetProperty(const wxString& propname, const Property& prop)
/**
 * \brief Sets the property with the given name. If the property does
 * not exists the property will be created. If the property already exists
 * the property will be overridden.
 * \param propname The property name.
 * \param prop The property.
 **/
{
    Property* setprop = GetProperty(propname, true);
    if (setprop->GetType() != prop.GetType())
    {
        setprop->SetType(prop.GetType());
        setprop->SetName(prop.GetName());
    }
    switch (setprop->GetType())
    {
        case penvPT_Boolean:
            setprop->SetBoolean(prop.GetBoolean());
        break;
        case penvPT_Integer:
            setprop->SetInteger(prop.GetInteger());
        break;
        case penvPT_Double:
            setprop->SetDouble(prop.GetDouble());
        break;
        case penvPT_String:
            setprop->SetString(prop.GetString());
        break;
        case penvPT_Properties:
            setprop->SetPropertyList(prop.GetPropertyList());
        break;
        case penvPT_ArrayBoolean:
            NOT_IMPLEMENTED_YET();
        break;
        case penvPT_ArrayInteger:
            NOT_IMPLEMENTED_YET();
        break;
        case penvPT_ArrayDouble:
            NOT_IMPLEMENTED_YET();
        break;
        case penvPT_ArrayString:
            NOT_IMPLEMENTED_YET();
        break;
        default:
            wxString msg = wxString::Format(_T("Unknown type for property %s."), setprop->GetName().c_str());
        break;
    }
}
コード例 #2
0
ファイル: propertylist.cpp プロジェクト: Sneedd/penv
//----------------------------------------------------------------
void PropertyList::Set(const wxString& propname, const wxString& value)
/**
 * \brief Sets the string value of a known property. If the
 * property does not exists it will be created. If the property
 * exists and has the worng type, it will be overridden and a warning
 * will be created.
 * \param propname The property name.
 * \param value Value to set for the property.
 **/
{
    Property* prop = GetProperty(propname, true);
    if (prop->GetType() == penvPT_None) prop->SetType(penvPT_String);
    prop->SetString(value);
}
コード例 #3
0
ファイル: propertylist.cpp プロジェクト: Sneedd/penv
//----------------------------------------------------------------
PropertyType PropertyList::GetType(const wxString& propname)
/**
 * \brief Returns the type of the property. This method will
 * return penvPT_None if the property does not exists and an
 * error will be generated.
 * Use slash to separate one property from another.
 * \param propname The property name.
 * \return Type of the property (see PropertyType enumerator).
 **/
{
    Property* prop = GetProperty(propname, false);
    if (unlikely(prop == NULL)) return (penvPT_None);
    return (prop->GetType());
}
コード例 #4
0
ファイル: propertylist.cpp プロジェクト: Sneedd/penv
//----------------------------------------------------------------
wxArrayString* PropertyList::GetProperties(bool recursive)
/**
 * \brief Returns all property names from this PropertyList.
 * If the parameter 'recursive' is true all properties will be
 * recursively inserted into the returning string array, with
 * a slash who separates every property from one level to another.
 * If 'recursive' is false only the properties from this level
 * are returned.
 * \param recursive True if all properties should be returned.
 * \return String array with property names.
 **/
{
    // Array erzeugen
    wxArrayString* array = new wxArrayString();
    array->Alloc(m_hashmap->size());
    // Durch Hashmap durchschleifen
    PropertiesHashMap::iterator itr;
    //if (m_hashmap->size() <= 0) return (array);
    for (itr = m_hashmap->begin(); itr != m_hashmap->end(); itr++)
    {
        // Properties in Array speichern
        array->Add(itr->first);
        // Überprüfen ob rekursiv die Properties geholt werden müssen
        Property* prop = itr->second;
        if (recursive && prop->GetType() == penvPT_Properties)
        {
            // Rekursiv aufrufen
            wxArrayString* recarray = prop->GetPropertyList()->GetProperties(recursive);
            for (size_t i=0; i<recarray->Count(); ++i)
            {
                wxString strg = itr->first;
                strg.Append('/').Append(recarray->Item(i).c_str());
                array->Add(strg);
            }
            delete recarray;
        }
    }
    return (array);
}