Added String<T, N>.ParseArgs().
This commit is contained in:
@@ -1110,6 +1110,54 @@ namespace ehs
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector<Str> ParseArgs() const
|
||||
{
|
||||
Vector<Str> args;
|
||||
T *quoteStart = nullptr;
|
||||
T *spaceStart = nullptr;
|
||||
|
||||
for (T *i = data; i <= data + size; ++i)
|
||||
{
|
||||
if (*i == '\"' && !spaceStart)
|
||||
{
|
||||
if (quoteStart)
|
||||
{
|
||||
args.Push(Str(quoteStart, i - quoteStart));
|
||||
quoteStart = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i + 1 < &data[size - 1])
|
||||
quoteStart = i + 1;
|
||||
else
|
||||
args.Push({});
|
||||
}
|
||||
}
|
||||
else if (*i == ' ' && !quoteStart)
|
||||
{
|
||||
if (spaceStart)
|
||||
{
|
||||
args.Push(Str(spaceStart, i - spaceStart));
|
||||
spaceStart = i + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i + 1 < &data[size - 1])
|
||||
spaceStart = i + 1;
|
||||
else
|
||||
args.Push({});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (quoteStart)
|
||||
args.Push(Str(quoteStart, &data[size - 1] - (quoteStart - 1)));
|
||||
else if (spaceStart)
|
||||
args.Push(Str(spaceStart, &data[size - 1] - (spaceStart - 1)));
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
/// Checks if the string represents a number. Must not have any alphabetical characters.
|
||||
/// @returns The result.
|
||||
bool IsNum() const
|
||||
|
Reference in New Issue
Block a user