|
Teuchos - Trilinos Tools Package
Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Teuchos: Common Tools Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 // @HEADER 00041 00042 #ifndef TEUCHOS_STRUTILS_H 00043 #define TEUCHOS_STRUTILS_H 00044 00049 #include "Teuchos_ConfigDefs.hpp" 00050 00051 #include "Teuchos_Utils.hpp" 00052 #include "Teuchos_Array.hpp" 00053 00054 namespace Teuchos { 00055 00056 00061 class TEUCHOSCORE_LIB_DLL_EXPORT StrUtils 00062 { 00063 public: 00065 static Array<std::string> readFile(std::istream& is, char comment); 00066 00069 static Array<std::string> splitIntoLines(const std::string& input); 00070 00072 static Array<Array<std::string> > tokenizeFile(std::istream& is, char comment); 00073 00075 static bool readLine(std::istream& is, std::string& line); 00076 00078 static Array<std::string> stringTokenizer(const std::string& str); 00079 00081 static Array<std::string> getTokensPlusWhitespace(const std::string& str); 00082 00084 static std::string reassembleFromTokens(const Array<std::string>& tokens, int iStart=0); 00085 00087 static void splitList(const std::string& bigstring, Array<std::string>& elements); 00088 00090 static int findNextWhitespace(const std::string& str, int offset); 00091 00093 static int findNextNonWhitespace(const std::string& str, int offset); 00094 00096 static std::string varSubstitute(const std::string& rawLine, 00097 const std::string& varName, 00098 const std::string& varValue); 00099 00101 static std::string varTableSubstitute(const std::string& rawLine, 00102 const Array<std::string>& varNames, 00103 const Array<std::string>& varValues); 00104 00106 static std::string envSubstitute(const std::string& line); 00107 00110 static std::string before(const std::string& str, const std::string& sub); 00111 00114 static std::string before(const std::string& str, char sub); 00115 00118 static std::string after(const std::string& str, const std::string& sub); 00119 00122 static int find(const std::string& str, const std::string& sub); 00123 00125 static bool isWhite(const std::string& str); 00126 00128 static std::string fixUnprintableCharacters(const std::string& str); 00129 00131 static bool isNonWhite(const std::string& str) {return !isWhite(str);} 00132 00138 static std::string between(const std::string& str, const std::string& begin, 00139 const std::string& end, std::string& front, std::string& back); 00140 00144 static std::string subString(const std::string& str, int begin, int end); 00145 00146 static std::string readFromStream(std::istream& is); 00147 00149 static std::string allCaps(const std::string& str); 00150 00152 static double atof(const std::string& str); 00153 00155 static int atoi(const std::string& str); 00156 00158 static std::ostream& printLines( 00159 std::ostream &os 00160 ,const std::string &linePrefix 00161 ,const std::string &lines 00162 ); 00163 00165 static std::string removeAllSpaces(std::string stringToClean); 00166 00167 }; 00168 00169 00170 } // namespace Teuchos 00171 00172 00173 #endif
1.7.6.1