diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index f574fde3e6..1f2a60e558 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index da75c4d066..ca00bd2844 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -211,9 +211,19 @@ public: //- Return arguments inline const stringList& args() const; - //- Return additional arguments, - // i.e. those additional to the executable itself - stringList::subList additionalArgs() const; + //- Return the number of arguments + inline label size() const; + + //- Return the argument corresponding to index. + // Index 0 corresponds to the name of the executable. + // Index 1 corresponds to the first argument. + inline const string& operator[](const label index) const; + + //- Read a value from the argument at index. + // Index 0 corresponds to the name of the executable. + // Index 1 corresponds to the first argument. + template + inline T argRead(const label index) const; //- Return options inline const Foam::HashTable& options() const; @@ -264,7 +274,6 @@ public: } - // Edit //- Add to a bool option to validOptions with usage information diff --git a/src/OpenFOAM/global/argList/argListI.H b/src/OpenFOAM/global/argList/argListI.H index 6b9b462de0..9da2149de6 100644 --- a/src/OpenFOAM/global/argList/argListI.H +++ b/src/OpenFOAM/global/argList/argListI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -64,6 +64,12 @@ inline const Foam::stringList& Foam::argList::args() const } +inline Foam::label Foam::argList::size() const +{ + return args_.size(); +} + + inline const Foam::HashTable& Foam::argList::options() const { return options_; @@ -92,6 +98,30 @@ inline Foam::IStringStream Foam::argList::optionLookup(const word& opt) const namespace Foam { + // Template specialization for string + template<> + inline Foam::string + Foam::argList::argRead(const label index) const + { + return args_[index]; + } + + // Template specialization for word + template<> + inline Foam::word + Foam::argList::argRead(const label index) const + { + return args_[index]; + } + + // Template specialization for fileName + template<> + inline Foam::fileName + Foam::argList::argRead(const label index) const + { + return args_[index]; + } + // Template specialization for string template<> inline Foam::string @@ -120,6 +150,16 @@ namespace Foam // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +inline T Foam::argList::argRead(const label index) const +{ + T val; + + IStringStream(args_[index])() >> val; + return val; +} + + template inline T Foam::argList::optionRead(const word& opt) const { @@ -187,4 +227,12 @@ inline T Foam::argList::optionLookupOrDefault } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +inline const Foam::string& Foam::argList::operator[](const label index) const +{ + return args_[index]; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/global/argList/parRun.H b/src/OpenFOAM/global/argList/parRun.H index c1e5b544bc..d2b926d8a4 100644 --- a/src/OpenFOAM/global/argList/parRun.H +++ b/src/OpenFOAM/global/argList/parRun.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License