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) 2011-2016 OpenFOAM Foundation
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 without whitespace, quotes, slashes,
31  semicolons or brace brackets. Words are delimited by whitespace.
32 
33 SourceFiles
34  word.C
35  wordIO.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef word_H
40 #define word_H
41 
42 #include "string.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of friend functions and operators
50 class word;
51 inline word operator&(const word&, const word&);
52 Istream& operator>>(Istream&, word&);
53 Ostream& operator<<(Ostream&, const word&);
54 
55 
56 /*---------------------------------------------------------------------------*\
57  Class word Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class word
61 :
62  public string
63 {
64  // Private Member Functions
65 
66  //- Strip invalid characters from this word
67  inline void stripInvalid();
68 
69 
70 public:
71 
72  // Static data members
73 
74  static const char* const typeName;
75  static int debug;
76 
77  //- An empty word
78  static const word null;
79 
80 
81  // Constructors
82 
83  //- Construct null
84  inline word();
85 
86  //- Construct as copy
87  inline word(const word&);
88 
89  //- Construct as copy of character array
90  inline word(const char*, const bool doStripInvalid=true);
91 
92  //- Construct as copy with a maximum number of characters
93  inline word
94  (
95  const char*,
96  const size_type,
97  const bool doStripInvalid
98  );
99 
100  //- Construct as copy of string
101  inline word(const string&, const bool doStripInvalid=true);
102 
103  //- Construct as copy of std::string
104  inline word(const std::string&, const bool doStripInvalid=true);
105 
106  //- Construct from Istream
107  word(Istream&);
108 
109 
110  // Member functions
111 
112  //- Is this character valid for a word
113  inline static bool valid(char);
114 
115 
116  // Member operators
117 
118  // Assignment
119 
120  inline void operator=(const word&);
121  inline void operator=(const string&);
122  inline void operator=(const std::string&);
123  inline void operator=(const char*);
124 
125 
126  // Friend Operators
127 
128  friend word operator&(const word&, const word&);
129 
130 
131  // IOstream operators
132 
133  friend Istream& operator>>(Istream&, word&);
134  friend Ostream& operator<<(Ostream&, const word&);
135 };
136 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 } // End namespace Foam
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 #include "wordI.H"
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #endif
149 
150 // ************************************************************************* //
static bool valid(char)
Is this character valid for a word.
Definition: wordI.H:117
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void operator=(const word &)
Definition: wordI.H:134
friend Ostream & operator<<(Ostream &, const word &)
word()
Construct null.
Definition: wordI.H:61
A class for handling words, derived from string.
Definition: word.H:59
Istream & operator>>(Istream &, directionInfo &)
static int debug
Definition: word.H:74
static const word null
An empty word.
Definition: word.H:77
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:73
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
friend word operator&(const word &, const word &)
friend Istream & operator>>(Istream &, word &)
tmp< GeometricField< Type, fvPatchField, volMesh > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
Ostream & operator<<(Ostream &, const ensightPart &)
static const char *const typeName
Definition: word.H:73
A class for handling character strings derived from std::string.
Definition: string.H:74
Namespace for OpenFOAM.