NamedItemPtr NameManager::registerName(NamedItemPtr namedItem)
{
	if (checkUniqueName(namedItem->name()))
	{
		names_.insert(std::pair<std::string,NamedItemPtr>(namedItem->name(), namedItem));
		return namedItem;
	}
	else
	{
		return NamedItemPtr();
	}
}
std::string NameManager::uniqueName(const std::string & name) const
{
	std::string tempName = name;
	// Search a free name
	int i = 1;
	while (!checkUniqueName(tempName))
	{
		std::stringstream ss(name, std::ios_base::out | std::ios_base::app);
		ss << i;
		tempName = ss.str();
		i++;
	}
	return tempName;
}
Example #3
0
	std::string DataUtility::getUniqueName(DataPtr _parent, const std::string& _pattern)
	{
		std::string result = _pattern;

		for (size_t index = 1; index < (std::numeric_limits<size_t>::max)(); index ++)
		{
			std::string name = MyGUI::utility::toString(_pattern, index);
			bool unique = checkUniqueName(_parent, name);
			if (unique)
			{
				result = name;
				break;
			}
		}

		return result;
	}