wordI.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <cctype>
00028
00029
00030
00031
00032
00033 inline void Foam::word::stripInvalid()
00034 {
00035
00036
00037 if (debug && string::stripInvalid<word>(*this))
00038 {
00039 std::cerr
00040 << "word::stripInvalid() called for word "
00041 << this->c_str() << std::endl;
00042
00043 if (debug > 1)
00044 {
00045 std::cerr
00046 << " For debug level (= " << debug
00047 << ") > 1 this is considered fatal" << std::endl;
00048 std::abort();
00049 }
00050 }
00051 }
00052
00053
00054
00055
00056 inline Foam::word::word(const word& w)
00057 :
00058 string(w)
00059 {}
00060
00061
00062 inline Foam::word::word()
00063 :
00064 string()
00065 {}
00066
00067
00068 inline Foam::word::word(const string& s, const bool doStripInvalid)
00069 :
00070 string(s)
00071 {
00072 if (doStripInvalid)
00073 {
00074 stripInvalid();
00075 }
00076 }
00077
00078
00079 inline Foam::word::word(const std::string& s, const bool doStripInvalid)
00080 :
00081 string(s)
00082 {
00083 if (doStripInvalid)
00084 {
00085 stripInvalid();
00086 }
00087 }
00088
00089
00090 inline Foam::word::word(const char* s, const bool doStripInvalid)
00091 :
00092 string(s)
00093 {
00094 if (doStripInvalid)
00095 {
00096 stripInvalid();
00097 }
00098 }
00099
00100 inline Foam::word::word
00101 (
00102 const char* s,
00103 const size_type n,
00104 const bool doStripInvalid
00105 )
00106 :
00107 string(s, n)
00108 {
00109 if (doStripInvalid)
00110 {
00111 stripInvalid();
00112 }
00113 }
00114
00115
00116
00117
00118 inline bool Foam::word::valid(char c)
00119 {
00120 return
00121 (
00122 !isspace(c)
00123 && c != '"'
00124 && c != '\''
00125 && c != '/'
00126 && c != ';'
00127 && c != '{'
00128 && c != '}'
00129 );
00130 }
00131
00132
00133
00134
00135 inline const Foam::word& Foam::word::operator=(const word& q)
00136 {
00137 string::operator=(q);
00138 return *this;
00139 }
00140
00141
00142 inline const Foam::word& Foam::word::operator=(const string& q)
00143 {
00144 string::operator=(q);
00145 stripInvalid();
00146 return *this;
00147 }
00148
00149
00150 inline const Foam::word& Foam::word::operator=(const std::string& q)
00151 {
00152 string::operator=(q);
00153 stripInvalid();
00154 return *this;
00155 }
00156
00157
00158 inline const Foam::word& Foam::word::operator=(const char* q)
00159 {
00160 string::operator=(q);
00161 stripInvalid();
00162 return *this;
00163 }
00164
00165
00166
00167
00168 inline Foam::word Foam::operator&(const word& a, const word& b)
00169 {
00170 if (b.size())
00171 {
00172 string ub = b;
00173 ub.string::operator[](0) = char(toupper(ub.string::operator[](0)));
00174
00175 return a + ub;
00176 }
00177 else
00178 {
00179 return a;
00180 }
00181 }
00182
00183
00184
00185
Copyright © 2000-2009 OpenCFD Ltd