1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
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 args(argc, argv);
48 << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
49 << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
54 dictionary dict1(IFstream("testDict")());
55 Info<< "dict1: " << dict1 << nl
56 << "toc: " << dict1.toc() << nl
57 << "keys: " << dict1.keys() << nl
58 << "patterns: " << dict1.keys(true) << endl;
60 dictionary dict2(dict1.xfer());
62 Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << nl
63 << "dict2.toc(): " << dict2.name() << " " << dict2.toc() << endl;
67 Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << endl;
69 dictionary dict3(dict2.subDictPtr("boundaryField"));
70 dictionary dict4(dict2.subDictPtr("NONEXISTENT"));
72 Info<< "dictionary construct from pointer" << nl
73 << "ok = " << dict3.name() << " " << dict3.toc() << nl
74 << "no = " << dict4.name() << " " << dict4.toc() << endl;
78 IOobject::writeDivider(Info);
81 dictionary dict(IFstream("testDictRegex")());
82 dict.add(keyType("fooba[rz]", true), "anything");
84 Info<< "dict:" << dict << nl
85 << "toc: " << dict.toc() << nl
86 << "keys: " << dict.keys() << nl
87 << "patterns: " << dict.keys(true) << endl;
89 Info<< "Pattern find \"abc\" in top directory : "
90 << dict.lookup("abc") << endl;
91 Info<< "Pattern find \"abc\" in sub directory : "
92 << dict.subDict("someDict").lookup("abc")
94 Info<< "Recursive pattern find \"def\" in sub directory : "
95 << dict.subDict("someDict").lookup("def", true)
97 Info<< "Recursive pattern find \"foo\" in sub directory : "
98 << dict.subDict("someDict").lookup("foo", true)
100 Info<< "Recursive pattern find \"fooz\" in sub directory : "
101 << dict.subDict("someDict").lookup("fooz", true)
103 Info<< "Recursive pattern find \"bar\" in sub directory : "
104 << dict.subDict("someDict").lookup("bar", true)
106 Info<< "Recursive pattern find \"xxx\" in sub directory : "
107 << dict.subDict("someDict").lookup("xxx", true)
115 // ************************************************************************* //