1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 \*---------------------------------------------------------------------------*/
33 #include "IOstreams.H"
36 #include "dictionary.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 int main(int argc, char *argv[])
45 argList::noParallel();
46 argList args(argc, argv);
49 << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
50 << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
55 dictionary dict1(IFstream("testDict")());
56 Info<< "dict1: " << dict1 << nl
57 << "toc: " << dict1.toc() << nl
58 << "keys: " << dict1.keys() << nl
59 << "patterns: " << dict1.keys(true) << endl;
61 dictionary dict2(dict1.xfer());
63 Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << nl
64 << "dict2.toc(): " << dict2.name() << " " << dict2.toc() << endl;
68 Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << endl;
70 dictionary dict3(dict2.subDictPtr("boundaryField"));
71 dictionary dict4(dict2.subDictPtr("NONEXISTENT"));
73 Info<< "dictionary construct from pointer" << nl
74 << "ok = " << dict3.name() << " " << dict3.toc() << nl
75 << "no = " << dict4.name() << " " << dict4.toc() << endl;
79 IOobject::writeDivider(Info);
82 dictionary dict(IFstream("testDictRegex")());
83 dict.add(keyType("fooba[rz]", true), "anything");
85 Info<< "dict:" << dict << nl
86 << "toc: " << dict.toc() << nl
87 << "keys: " << dict.keys() << nl
88 << "patterns: " << dict.keys(true) << endl;
90 Info<< "Pattern find \"abc\" in top directory : "
91 << dict.lookup("abc") << endl;
92 Info<< "Pattern find \"abc\" in sub directory : "
93 << dict.subDict("someDict").lookup("abc")
95 Info<< "Recursive pattern find \"def\" in sub directory : "
96 << dict.subDict("someDict").lookup("def", true)
98 Info<< "Recursive pattern find \"foo\" in sub directory : "
99 << dict.subDict("someDict").lookup("foo", true)
101 Info<< "Recursive pattern find \"fooz\" in sub directory : "
102 << dict.subDict("someDict").lookup("fooz", true)
104 Info<< "Recursive pattern find \"bar\" in sub directory : "
105 << dict.subDict("someDict").lookup("bar", true)
107 Info<< "Recursive pattern find \"xxx\" in sub directory : "
108 << dict.subDict("someDict").lookup("xxx", true)
116 // ************************************************************************* //