With this change typedefs have two TokenLocations, one for the TypeName and one for the UnderlyingType. When the typedef is used with a variable the typedef is referenced now and not the underlying type.
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
#ifndef UTILITY_STRING_H
|
|
#define UTILITY_STRING_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace utility
|
|
{
|
|
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);
|
|
|
|
std::string substrAfter(const std::string& str, char 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
|