data: saving graph nodes with short name only

This change saves only the short names in the node, getName() no only gives the short version. The fullName is assembled
from the parent nodes on demand using the getFullName() method.
This commit is contained in:
Eberhard Graether
2014-07-26 14:58:06 +02:00
parent 641acc2bde
commit 68c6ede244
9 changed files with 268 additions and 75 deletions
+29 -2
View File
@@ -6,10 +6,37 @@
namespace utility
{
std::vector<std::string> split(const std::string& str, char delimiter);
std::vector<std::string> split(const std::string& str, const std::string& delimiter);
template<typename ContainerType = std::vector<std::string>>
ContainerType split(const std::string& str, char delimiter);
template<typename ContainerType = std::vector<std::string>>
ContainerType split(const std::string& str, const std::string& delimiter);
bool isPrefix(const std::string& prefix, const std::string& text);
}
template<typename ContainerType>
ContainerType utility::split(const std::string& str, char delimiter)
{
return split<ContainerType>(str, std::string(1, delimiter));
}
template<typename ContainerType>
ContainerType utility::split(const std::string& str, const std::string& delimiter)
{
size_t pos = 0;
size_t oldPos = 0;
ContainerType c;
do
{
pos = str.find(delimiter, oldPos);
c.push_back(str.substr(oldPos, pos - oldPos));
oldPos = pos + delimiter.size();
}
while (pos != std::string::npos);
return c;
}
#endif // UTILITY_STRING_H