1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
29 \*---------------------------------------------------------------------------*/
32 #include "IOstreams.H"
35 #include "dictionary.H"
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 int main(int argc, char *argv[])
44 argList::noParallel();
45 argList::validArgs.insert("dict .. dictN");
46 argList args(argc, argv, false, true);
49 << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
50 << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
56 dictionary dict1(IFstream("testDict")());
57 Info<< "dict1: " << dict1 << nl
58 << "toc: " << dict1.toc() << nl
59 << "keys: " << dict1.keys() << nl
60 << "patterns: " << dict1.keys(true) << endl;
62 dictionary dict2(dict1.xfer());
64 Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << nl
65 << "dict2.toc(): " << dict2.name() << " " << dict2.toc()
70 Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc()
73 dictionary dict3(dict2.subDictPtr("boundaryField"));
74 dictionary dict4(dict2.subDictPtr("NONEXISTENT"));
76 Info<< "dictionary construct from pointer" << nl
77 << "ok = " << dict3.name() << " " << dict3.toc() << nl
78 << "no = " << dict4.name() << " " << dict4.toc() << endl;
82 IOobject::writeDivider(Info);
85 dictionary dict(IFstream("testDictRegex")());
86 dict.add(keyType("fooba[rz]", true), "anything");
88 Info<< "dict:" << dict << nl
89 << "toc: " << dict.toc() << nl
90 << "keys: " << dict.keys() << nl
91 << "patterns: " << dict.keys(true) << endl;
93 Info<< "Pattern find \"abc\" in top directory : "
94 << dict.lookup("abc") << endl;
95 Info<< "Pattern find \"abc\" in sub directory : "
96 << dict.subDict("someDict").lookup("abc")
98 Info<< "Recursive pattern find \"def\" in sub directory : "
99 << dict.subDict("someDict").lookup("def", true)
101 Info<< "Recursive pattern find \"foo\" in sub directory : "
102 << dict.subDict("someDict").lookup("foo", true)
104 Info<< "Recursive pattern find \"fooz\" in sub directory : "
105 << dict.subDict("someDict").lookup("fooz", true)
107 Info<< "Recursive pattern find \"bar\" in sub directory : "
108 << dict.subDict("someDict").lookup("bar", true)
110 Info<< "Recursive pattern find \"xxx\" in sub directory : "
111 << dict.subDict("someDict").lookup("xxx", true)
117 IOobject::writeDivider(Info);
118 for (label argI=1; argI < args.size(); ++argI)
120 const string& dictFile = args[argI];
121 IFstream is(dictFile);
133 // ************************************************************************* //