FreeFOAM The Cross-Platform CFD Toolkit
keyType.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::keyType
26 
27 Description
28  A class for handling keywords in dictionaries.
29 
30  A keyType is the keyword of a dictionary.
31  It differs from word in that it accepts patterns (regular expressions).
32 
33 SourceFiles
34  keyType.C
35  keyTypeIO.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef keyType_H
40 #define keyType_H
41 
42 #include <OpenFOAM/word.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of classes
50 class Istream;
51 class Ostream;
52 
53 
54 /*---------------------------------------------------------------------------*\
55  Class keyType Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class keyType
59 :
60  public word
61 {
62  // Private member data
63 
64  //- Is the keyType a pattern (regular expression)
65  bool isPattern_;
66 
67  // Private Member Functions
68 
69  //- Disallow assignments where we cannot determine string/word type
70  void operator=(const std::string&);
71 
72 public:
73 
74 
75  // Constructors
76 
77  //- Construct null
78  inline keyType();
79 
80  //- Construct as copy
81  inline keyType(const keyType&);
82 
83  //- Construct as copy of word
84  inline keyType(const word&);
85 
86  //- Construct as copy of string. Expect it to be regular expression.
87  inline keyType(const string&);
88 
89  //- Construct as copy of character array
90  inline keyType(const char*);
91 
92  //- Construct as copy of std::string
93  inline keyType(const std::string&, const bool isPattern);
94 
95  //- Construct from Istream
96  keyType(Istream&);
97 
98 
99  // Member functions
100 
101  //- Should be treated as a match rather than a literal string
102  inline bool isPattern() const;
103 
104  // Member operators
105 
106  // Assignment
107 
108  inline const keyType& operator=(const keyType&);
109  inline const keyType& operator=(const word&);
110 
111  //- Assign from regular expression.
112  inline const keyType& operator=(const string&);
113  inline const keyType& operator=(const char*);
114 
115 
116  // IOstream operators
117 
118  friend Istream& operator>>(Istream&, keyType&);
119  friend Ostream& operator<<(Ostream&, const keyType&);
120 };
121 
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 } // End namespace Foam
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 #include "keyTypeI.H"
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 #endif
134 
135 // ************************ vim: set sw=4 sts=4 et: ************************ //