initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / test / List / ListTest.C
blob0fee9a9e3b5bd907a611dbad46e91ccd8984a321
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Application
27 Description
29 \*---------------------------------------------------------------------------*/
31 #include "OSspecific.H"
32 #include "argList.H"
33 #include "wordReList.H"
35 #include "IOstreams.H"
36 #include "IStringStream.H"
37 #include "scalar.H"
38 #include "vector.H"
39 #include "ListOps.H"
41 using namespace Foam;
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 //  Main program:
47 int main(int argc, char *argv[])
49     argList::noParallel();
50     argList::validOptions.insert("reList", "reList");
51     argList::validOptions.insert("wordList", "wordList");
52     argList::validOptions.insert("stringList", "stringList");
53     argList::validOptions.insert("float", "xx");
54     argList::validOptions.insert("flag", "");
56 #   include "setRootCase.H"
58     List<vector> list1(IStringStream("1 ((0 1 2))")());
59     Info<< "list1: " << list1 << endl;
61     List<vector> list2(IStringStream("((0 1 2) (3 4 5) (6 7 8))")());
62     Info<< "list2: " << list2 << endl;
64     list1.append(list2);
65     Info<< "list1.append(list2): " << list1 << endl;
67     Info<< findIndex(list2, vector(3, 4, 5)) << endl;
69     list2.setSize(10, vector(1, 2, 3));
70     Info<< "list2: " << list2 << endl;
72     List<vector> list3(list2.xfer());
73     Info<< "Transferred via the xfer() method" << endl;
74     Info<< "list2: " << list2 << nl
75         << "list3: " << list3 << endl;
78     // Subset
79     const labelList map(IStringStream("2 (0 2)")());
80     List<vector> subList3(list3, map);
81     Info<< "Elements " << map << " out of " << list3
82         << " => " << subList3 << endl;
84     wordReList reLst;
85     wordList wLst;
86     stringList sLst;
89     scalar xxx(-1);
91     if (args.optionFound("flag"))
92     {
93         Info<<"-flag:" << args.option("flag") << endl;
94     }
96     if (args.optionReadIfPresent<scalar>("float", xxx))
97     {
98         Info<<"read float " << xxx << endl;
99     }
101     if (args.optionFound("reList"))
102     {
103         reLst = args.optionReadList<wordRe>("reList");
104     }
106     if (args.optionFound("wordList"))
107     {
108         wLst = args.optionReadList<word>("wordList");
109     }
111     if (args.optionFound("stringList"))
112     {
113         sLst = args.optionReadList<string>("stringList");
114     }
116     Info<< nl
117         << "-reList: " << reLst << nl
118         << "-wordList: " << wLst << nl
119         << "-stringList: " << sLst << endl;
121     return 0;
124 // ************************************************************************* //