Пример #1
0
bool CSettingList::fromValues(const std::vector<std::string> &strValues, SettingPtrList &values) const
{
    if ((int)strValues.size() < m_minimumItems ||
            (m_maximumItems > 0 && (int)strValues.size() > m_maximumItems))
        return false;

    bool ret = true;
    int index = 0;
    for (std::vector<std::string>::const_iterator itValue = strValues.begin(); itValue != strValues.end(); ++itValue)
    {
        CSetting *settingValue = m_definition->Clone(StringUtils::Format("%s.%d", m_id.c_str(), index++));
        if (settingValue == NULL ||
                !settingValue->FromString(*itValue))
        {
            delete settingValue;
            ret = false;
            break;
        }

        values.push_back(SettingPtr(settingValue));
    }

    if (!ret)
        values.clear();

    return ret;
}
Пример #2
0
void CSettingList::copy(const SettingPtrList &srcValues, SettingPtrList &dstValues)
{
    dstValues.clear();

    for (SettingPtrList::const_iterator itValue = srcValues.begin(); itValue != srcValues.end(); ++itValue)
    {
        if (*itValue == NULL)
            continue;

        CSetting *valueCopy = (*itValue)->Clone((*itValue)->GetId());
        if (valueCopy == NULL)
            continue;

        dstValues.push_back(SettingPtr(valueCopy));
    }
}