Beispiel #1
0
void XMLPrefsParser::AddPrefValue( ContainerRef pref, char* inNewValue)
{
    if (!strcmp(pref->GetTagName(), kPref))     // is this a PREF tag
    {
        if (pref->GetValue() == NULL)
        {
            // easy case, no existing value, so just add a vlue
            pref->SetValue(inNewValue);
            return;
        }
        else
        {
            // it already has a value, so change the pref to be a list pref and go to code below
            char* firstValue = pref->GetValue();
            XMLTag* value = NEW XMLTag(kValue);
            value->SetValue(firstValue);

            pref->SetTagName(kListPref);
            pref->SetValue(NULL);
            pref->AddEmbeddedTag(value);
        }
    }
    
    // we want to fall through from second case above, so this isn't an else
    if (!strcmp(pref->GetTagName(), kListPref))
    {
        XMLTag* value = NEW XMLTag(kValue);
        value->SetValue(inNewValue);
        pref->AddEmbeddedTag(value);
    }
}
Beispiel #2
0
void XMLPrefsParser::SetPrefValue( ContainerRef pref, const UInt32 inValueIndex,
                                        char* inNewValue)
{
    UInt32 numValues = GetNumPrefValues(pref);
    
    if (((numValues == 0) || (numValues == 1)) && (inValueIndex == 0))
    {
        pref->SetValue(inNewValue);
    }
    else if (inValueIndex == numValues) // this is an additional value
        AddPrefValue(pref, inNewValue);
    else
    {
        XMLTag* value = pref->GetEmbeddedTag(inValueIndex);
        if (value != NULL)
            value->SetValue(inNewValue);
    }
}