FreeFOAM The Cross-Platform CFD Toolkit
word.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::word
26 
27 Description
28  A class for handling words, derived from string.
29 
30  A word is a string of characters containing no whitespace and may be
31  constructed from a string by removing whitespace. Words are delimited
32  by whitespace.
33 
34 SourceFiles
35  word.C
36  wordIO.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef word_H
41 #define word_H
42 
43 #include <OpenFOAM/string.H>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of friend functions and operators
51 class word;
52 inline word operator&(const word&, const word&);
53 Istream& operator>>(Istream&, word&);
54 Ostream& operator<<(Ostream&, const word&);
55 
56 
57 /*---------------------------------------------------------------------------*\
58  Class word Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class word
62 :
63  public string
64 {
65  // Private member functions
66 
67  //- Strip invalid characters from this word
68  inline void stripInvalid();
69 
70 
71 public:
72 
73  // Static data members
74 
75  static const char* const typeName;
76  static int debug;
77  static const word null;
78 
79 
80  // Constructors
81 
82  //- Construct null
83  inline word();
84 
85  //- Construct as copy
86  inline word(const word&);
87 
88  //- Construct as copy of character array
89  inline word(const char*, const bool doStripInvalid=true);
90 
91  //- Construct as copy with a maximum number of characters
92  inline word
93  (
94  const char*,
95  const size_type,
96  const bool doStripInvalid
97  );
98 
99  //- Construct as copy of string
100  inline word(const string&, const bool doStripInvalid=true);
101 
102  //- Construct as copy of std::string
103  inline word(const std::string&, const bool doStripInvalid=true);
104 
105  //- Construct from Istream
106  word(Istream&);
107 
108 
109  // Member functions
110 
111  //- Is this character valid for a word
112  inline static bool valid(char);
113 
114 
115  // Member operators
116 
117  // Assignment
118 
119  inline const word& operator=(const word&);
120  inline const word& operator=(const string&);
121  inline const word& operator=(const std::string&);
122  inline const word& operator=(const char*);
123 
124 
125  // Friend Operators
126 
127  friend word operator&(const word&, const word&);
128 
129 
130  // IOstream operators
131 
132  friend Istream& operator>>(Istream&, word&);
133  friend Ostream& operator<<(Ostream&, const word&);
134 };
135 
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 } // End namespace Foam
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 #include <OpenFOAM/wordI.H>
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #endif
148 
149 // ************************ vim: set sw=4 sts=4 et: ************************ //