Esempio n. 1
0
const AbstractProperty * PropertyGroup::findProperty(const std::vector<std::string> & path) const
{
    // [TODO] Use iterative approach rather than recursion

    // Check if path is valid
    if (path.size() == 0) {
        return nullptr;
    }

    // Check if first element of the path exists in this group
    if (!propertyExists(path.front())) {
        return nullptr;
    }

    // Get the respective property
    AbstractProperty * property = m_propertiesMap.at(path.front());

    // If there are no more sub-paths, return the found property
    if (path.size() == 1) {
        return property;
    }

    // Otherwise, it is an element in the middle of the path, so ensure it is a group
    if (!property->isGroup()) {
        return nullptr;
    }

    // Call recursively on subgroup
    return property->asGroup()->findProperty({ path.begin() + 1, path.end() });
}
Esempio n. 2
0
	void Event::setProperty(const string inName, const string inValue) {
		if ( propertyExists(inName) ) {
			mProperties.find(inName)->second = inValue;
			return;
		}
		
		mProperties.insert( make_pair<string, string>(inName, inValue) );
		nrProperties++;
	}
Esempio n. 3
0
std::string Stage::getFreeName(const std::string & name) const
{
    std::string nameOut = name;
    int i = 2;

    while (propertyExists(nameOut))
    {
        nameOut = name + cppassist::string::toString<int>(i);
        i++;
    }

    return nameOut;
}
Esempio n. 4
0
PropertyGroup * PropertyGroup::ensureGroup(const std::vector<std::string> & path)
{
    // [TODO] Use iterative approach rather than recursion

    // Check if path is valid
    if (path.size() == 0) {
        return nullptr;
    }

    // Check if group exists
    PropertyGroup * group = nullptr;
    if (propertyExists(path.front()))
    {
        // Get property
        AbstractProperty * property = m_propertiesMap.at(path.front());

        // Abort if this is not a group
        if (!property->isGroup()) {
            return nullptr;
        }

        // Get as group
        group = property->asGroup();
    }
    else
    {
        // Add new group
        group = addGroup(path.front());
    }

    // If there are no more sub-paths, return the group
    if (path.size() == 1) {
        return group;
    }

    // Otherwise, call recursively on subgroup
    return group->ensureGroup(std::vector<std::string>(path.begin() + 1, path.end()));
}