mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
small changes to dictionaryTest to test regexs
This commit is contained in:
@ -30,6 +30,7 @@ Description
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
#include "IOobject.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
|
|
||||||
@ -40,18 +41,12 @@ using namespace Foam;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
IFstream dictStream("testDict");
|
Info<< dictionary(IFstream("testDict")()) << endl;
|
||||||
dictionary testDict(dictStream);
|
|
||||||
|
|
||||||
Info<< testDict << endl;
|
IOobject::writeDivider(Info);
|
||||||
|
|
||||||
{
|
{
|
||||||
dictionary someDict;
|
dictionary dict(IFstream("testDictRegex")());
|
||||||
someDict.add(keyType("a.*", true), "subdictValue");
|
|
||||||
|
|
||||||
dictionary dict;
|
|
||||||
dict.add("someDict", someDict);
|
|
||||||
dict.add(keyType(".*", true), "parentValue");
|
|
||||||
|
|
||||||
Info<< "dict:" << dict << endl;
|
Info<< "dict:" << dict << endl;
|
||||||
|
|
||||||
@ -64,6 +59,18 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Recursive wildcard find \"def\" in sub directory : "
|
Info<< "Recursive wildcard find \"def\" in sub directory : "
|
||||||
<< dict.subDict("someDict").lookup("def", true)
|
<< dict.subDict("someDict").lookup("def", true)
|
||||||
<< endl;
|
<< endl;
|
||||||
|
Info<< "Recursive wildcard find \"foo\" in sub directory : "
|
||||||
|
<< dict.subDict("someDict").lookup("foo", true)
|
||||||
|
<< endl;
|
||||||
|
Info<< "Recursive wildcard find \"fooz\" in sub directory : "
|
||||||
|
<< dict.subDict("someDict").lookup("fooz", true)
|
||||||
|
<< endl;
|
||||||
|
Info<< "Recursive wildcard find \"bar\" in sub directory : "
|
||||||
|
<< dict.subDict("someDict").lookup("bar", true)
|
||||||
|
<< endl;
|
||||||
|
Info<< "Recursive wildcard find \"xxx\" in sub directory : "
|
||||||
|
<< dict.subDict("someDict").lookup("xxx", true)
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
34
applications/test/dictionary/testDictRegex
Normal file
34
applications/test/dictionary/testDictRegex
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*-------------------------------*- C++ -*---------------------------------*\
|
||||||
|
| ========= |
|
||||||
|
| \\ / OpenFOAM |
|
||||||
|
| \\ / |
|
||||||
|
| \\ / The Open Source CFD Toolbox |
|
||||||
|
| \\/ http://www.OpenFOAM.org |
|
||||||
|
\*-------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object testDictRegex;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
#inputMode merge
|
||||||
|
|
||||||
|
".*" parentValue1;
|
||||||
|
"[n-z].*" parentValue2;
|
||||||
|
"f.*" parentValue3;
|
||||||
|
|
||||||
|
someDict
|
||||||
|
{
|
||||||
|
foo subdictValue0;
|
||||||
|
bar $f.*; // should this really match 'foo'?
|
||||||
|
|
||||||
|
// result is dependent on insert order!
|
||||||
|
"a.*c" subdictValue3;
|
||||||
|
"ab.*" subdictValue2;
|
||||||
|
"a.*" subdictValue1;
|
||||||
|
abcd subdictValue4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -697,7 +697,7 @@ bool Foam::dictionary::changeKeyword
|
|||||||
IDLList<entry>::replace(iter2(), iter());
|
IDLList<entry>::replace(iter2(), iter());
|
||||||
delete iter2();
|
delete iter2();
|
||||||
hashedEntries_.erase(iter2);
|
hashedEntries_.erase(iter2);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -163,16 +163,16 @@ public:
|
|||||||
dictionary(Istream&);
|
dictionary(Istream&);
|
||||||
|
|
||||||
//- Construct as copy given the parent dictionary
|
//- Construct as copy given the parent dictionary
|
||||||
dictionary(const dictionary& parentDict, const dictionary& dict);
|
dictionary(const dictionary& parentDict, const dictionary&);
|
||||||
|
|
||||||
//- Construct top-level dictionary as copy
|
//- Construct top-level dictionary as copy
|
||||||
dictionary(const dictionary& dict);
|
dictionary(const dictionary&);
|
||||||
|
|
||||||
//- Construct and return clone
|
//- Construct and return clone
|
||||||
Foam::autoPtr<dictionary> clone() const;
|
Foam::autoPtr<dictionary> clone() const;
|
||||||
|
|
||||||
//- Construct top-level dictionary on freestore from Istream
|
//- Construct top-level dictionary on freestore from Istream
|
||||||
static Foam::autoPtr<dictionary> New(Istream& is);
|
static Foam::autoPtr<dictionary> New(Istream&);
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@ -211,12 +211,12 @@ public:
|
|||||||
|
|
||||||
//- Search dictionary for given keyword
|
//- Search dictionary for given keyword
|
||||||
// If recursive search parent dictionaries
|
// If recursive search parent dictionaries
|
||||||
bool found(const word& keyword, bool recursive=false) const;
|
bool found(const word&, bool recursive=false) const;
|
||||||
|
|
||||||
//- Find and return an entry data stream pointer if present
|
//- Find and return an entry data stream pointer if present
|
||||||
// otherwise return NULL.
|
// otherwise return NULL.
|
||||||
// If recursive search parent dictionaries. If wildCardMatch
|
// If recursive search parent dictionaries.
|
||||||
// use wildcards.
|
// If wildCardMatch use wildcards.
|
||||||
const entry* lookupEntryPtr
|
const entry* lookupEntryPtr
|
||||||
(
|
(
|
||||||
const word&,
|
const word&,
|
||||||
@ -226,8 +226,8 @@ public:
|
|||||||
|
|
||||||
//- Find and return an entry data stream pointer for manipulation
|
//- Find and return an entry data stream pointer for manipulation
|
||||||
// if present otherwise return NULL.
|
// if present otherwise return NULL.
|
||||||
// If recursive search parent dictionaries. If wildCardMatch
|
// If recursive search parent dictionaries.
|
||||||
// use wildcards.
|
// If wildCardMatch use wildcards.
|
||||||
entry* lookupEntryPtr
|
entry* lookupEntryPtr
|
||||||
(
|
(
|
||||||
const word&,
|
const word&,
|
||||||
@ -236,8 +236,8 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Find and return an entry data stream if present otherwise error.
|
//- Find and return an entry data stream if present otherwise error.
|
||||||
// If recursive search parent dictionaries. If wildCardMatch
|
// If recursive search parent dictionaries.
|
||||||
// use wildcards.
|
// If wildCardMatch use wildcards.
|
||||||
const entry& lookupEntry
|
const entry& lookupEntry
|
||||||
(
|
(
|
||||||
const word&,
|
const word&,
|
||||||
@ -331,13 +331,13 @@ public:
|
|||||||
|
|
||||||
//- Add a scalar entry
|
//- Add a scalar entry
|
||||||
// optionally overwrite an existing entry
|
// optionally overwrite an existing entry
|
||||||
void add (const keyType&, const scalar, bool overwrite=false);
|
void add(const keyType&, const scalar, bool overwrite=false);
|
||||||
|
|
||||||
//- Add a dictionary entry
|
//- Add a dictionary entry
|
||||||
// optionally merge with an existing sub-dictionary
|
// optionally merge with an existing sub-dictionary
|
||||||
void add
|
void add
|
||||||
(
|
(
|
||||||
const keyType& keyword,
|
const keyType&,
|
||||||
const dictionary&,
|
const dictionary&,
|
||||||
bool mergeEntry=false
|
bool mergeEntry=false
|
||||||
);
|
);
|
||||||
@ -345,7 +345,7 @@ public:
|
|||||||
//- Add a T entry
|
//- Add a T entry
|
||||||
// optionally overwrite an existing entry
|
// optionally overwrite an existing entry
|
||||||
template<class T>
|
template<class T>
|
||||||
void add(const keyType& keyword, const T&, bool overwrite=false);
|
void add(const keyType&, const T&, bool overwrite=false);
|
||||||
|
|
||||||
//- Assign a new entry, overwrite any existing entry
|
//- Assign a new entry, overwrite any existing entry
|
||||||
void set(entry*);
|
void set(entry*);
|
||||||
@ -354,14 +354,14 @@ public:
|
|||||||
void set(const entry&);
|
void set(const entry&);
|
||||||
|
|
||||||
//- Assign a dictionary entry, overwrite any existing entry
|
//- Assign a dictionary entry, overwrite any existing entry
|
||||||
void set(const keyType& keyword, const dictionary&);
|
void set(const keyType&, const dictionary&);
|
||||||
|
|
||||||
//- Assign a T entry, overwrite any existing entry
|
//- Assign a T entry, overwrite any existing entry
|
||||||
template<class T>
|
template<class T>
|
||||||
void set(const keyType& keyword, const T&);
|
void set(const keyType&, const T&);
|
||||||
|
|
||||||
//- Remove an entry specified by keyword
|
//- Remove an entry specified by keyword
|
||||||
bool remove(const word& keyword);
|
bool remove(const word&);
|
||||||
|
|
||||||
//- Change the keyword for an entry,
|
//- Change the keyword for an entry,
|
||||||
// optionally forcing overwrite of an existing entry
|
// optionally forcing overwrite of an existing entry
|
||||||
@ -369,7 +369,7 @@ public:
|
|||||||
(
|
(
|
||||||
const keyType& oldKeyword,
|
const keyType& oldKeyword,
|
||||||
const keyType& newKeyword,
|
const keyType& newKeyword,
|
||||||
bool forceOverwrite = false
|
bool forceOverwrite=false
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Merge entries from the given dictionary.
|
//- Merge entries from the given dictionary.
|
||||||
@ -382,7 +382,7 @@ public:
|
|||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
void write(Ostream& os, bool subDict = true) const;
|
void write(Ostream&, bool subDict=true) const;
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|||||||
Reference in New Issue
Block a user