39inline Foam::word validateVariableName(
const std::string& str)
41 return Foam::stringOps::validate<Foam::word>
58 const std::string& str,
88 std::vector<rangeType> unnamed;
91 std::vector<rangeType> named;
94 rangeType argName(0, 0);
102 const auto strLen = str.length();
106 for (std::string::size_type
pos = 0, beg = 0;
pos < strLen; ++
pos)
108 const bool penultimate = ((
pos + 1) == strLen);
109 const char c = str[
pos];
119 argName = rangeType(beg,
pos);
127 else if (penultimate || (c ==
','))
129 if (penultimate && (c !=
','))
138 named.push_back(argName);
139 named.push_back(rangeType(beg,
pos));
143 unnamed.push_back(rangeType(beg,
pos));
157 const label nInputArgs =
static_cast<label
>(unnamed.size());
158 args.resize(nInputArgs);
161 for (label i = 0; i < nInputArgs; ++i)
163 const auto& arg = unnamed[i];
169 str.substr(arg.first(), (arg.second()-arg.first()))
174 if (!
args[ngood].empty())
185 const label nInputArgs =
static_cast<label
>(named.size());
186 namedArgs.resize(nInputArgs/2);
189 for (label i = 0; i < nInputArgs; i += 2)
191 const auto&
name = named[i];
192 const auto& arg = named[i+1];
194 namedArgs[ngood].first() =
200 namedArgs[ngood].second() =
203 str.substr(arg.first(), (arg.second()-arg.first()))
207 if (!namedArgs[ngood].first().empty())
213 namedArgs.resize(ngood);
217 return (
args.
size() + namedArgs.size());
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An ordered pair of two objects of type <T> with first() and second() elements.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
label size() const noexcept
The number of arguments.
bool valid() const
True if all internal ids are non-negative.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
label splitFunctionArgs(const std::string &str, wordRes &args, List< Tuple2< word, string > > &namedArgs)
Split out arguments (named or unnamed) from an input string.
dimensionedScalar pos(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Foam::argList args(argc, argv)