39 inline 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();
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());
label splitFunctionArgs(const std::string &str, wordRes &args, List< Tuple2< word, string >> &namedArgs)
Split out arguments (named or unnamed) from an input string.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
StringType validate(const std::string &str, const UnaryPredicate &accept, const bool invert=false)
Return a copy of the input string with validated characters.
dimensionedScalar pos(const dimensionedScalar &ds)
An ordered pair of two objects of type <T> with first() and second() elements.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
label size() const noexcept
The number of arguments.
A List of wordRe with additional matching capabilities.
string trim(const std::string &s)
Return string trimmed of leading and trailing whitespace.
graph_traits< Graph >::vertices_size_type size_type
static bool valid(char c)
Is this character valid for a word?
const dimensionedScalar c
Speed of light in a vacuum.
Foam::argList args(argc, argv)