diff --git a/applications/test/argList/Test-argList.C b/applications/test/argList/Test-argList.C index e885ff9fb0..b3394845f5 100644 --- a/applications/test/argList/Test-argList.C +++ b/applications/test/argList/Test-argList.C @@ -58,6 +58,9 @@ int main(int argc, char *argv[]) argList args(argc, argv); + Info<<"have: " + <& optionNames) const +{ + label n = 0; + for (const word& optName : optionNames) + { + if (options_.found(optName)) + { + ++n; + } + } + return n; +} + + +Foam::label Foam::argList::optionCount +( + std::initializer_list optionNames +) const +{ + label n = 0; + for (const word& optName : optionNames) + { + if (options_.found(optName)) + { + ++n; + } + } + return n; +} + + bool Foam::argList::setOption(const word& optionName, const string& param) { // Some options are always protected diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index fe4f5cb724..0e1d3631a5 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -302,6 +302,12 @@ public: //- Return true if the named option is found inline bool optionFound(const word& optionName) const; + //- Return how many of the specified options were used + label optionCount(const UList& optionNames) const; + + //- Return how many of the specified options were used + label optionCount(std::initializer_list optionNames) const; + //- Return an input token stream for the named option inline ITstream optionLookup(const word& optionName) const;