1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 inline Foam::string::string()
35 inline Foam::string::string(const std::string& stdStr)
41 // Copy character array
42 inline Foam::string::string(const char* str)
48 // Construct from a given number of characters in a character array
49 inline Foam::string::string(const char* str, const size_type len)
55 // Construct from a single character
56 inline Foam::string::string(const char c)
62 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 template<class String>
65 inline bool Foam::string::valid(const string& s)
69 for (const_iterator iter = s.begin(); iter != s.end(); iter++)
71 if (!String::valid(*iter))
82 template<class String>
83 inline bool Foam::string::stripInvalid(string& s)
85 if (!valid<String>(s))
87 register size_type nValid=0;
88 iterator iter2 = s.begin();
92 const_iterator iter1 = iter2;
93 iter1 != const_cast<const string&>(s).end();
97 register char c = *iter1;
116 template<class String>
117 inline String Foam::string::validate(const string& s)
120 stripInvalid<String>(ss);
125 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
127 inline Foam::string Foam::string::operator()
137 inline Foam::string Foam::string::operator()(const size_type n) const
143 inline Foam::string::hash::hash()
147 inline Foam::string::size_type Foam::string::hash::operator()
152 register size_type hashVal = 0;
154 for (string::const_iterator iter=key.begin(); iter!=key.end(); ++iter)
156 hashVal = hashVal<<1 ^ *iter;
163 inline Foam::string::size_type Foam::string::hash::operator()
166 const size_type tableSize
169 return ::abs(operator()(key)) % tableSize;
173 // ************************************************************************* //