Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_StrUtils.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_STRUTILS_H
11 #define TEUCHOS_STRUTILS_H
12 
17 #include "Teuchos_ConfigDefs.hpp"
18 
19 #include "Teuchos_Utils.hpp"
20 #include "Teuchos_Array.hpp"
21 
22 namespace Teuchos {
23 
24 
30 {
31 public:
33  static Array<std::string> readFile(std::istream& is, char comment);
34 
37  static Array<std::string> splitIntoLines(const std::string& input);
38 
40  static Array<Array<std::string> > tokenizeFile(std::istream& is, char comment);
41 
43  static bool readLine(std::istream& is, std::string& line);
44 
46  static Array<std::string> stringTokenizer(const std::string& str);
47 
49  static Array<std::string> getTokensPlusWhitespace(const std::string& str);
50 
52  static std::string reassembleFromTokens(const Array<std::string>& tokens, int iStart=0);
53 
55  static void splitList(const std::string& bigstring, Array<std::string>& elements);
56 
58  static int findNextWhitespace(const std::string& str, int offset);
59 
61  static int findNextNonWhitespace(const std::string& str, int offset);
62 
64  static std::string varSubstitute(const std::string& rawLine,
65  const std::string& varName,
66  const std::string& varValue);
67 
69  static std::string varTableSubstitute(const std::string& rawLine,
70  const Array<std::string>& varNames,
71  const Array<std::string>& varValues);
72 
75  static std::string before(const std::string& str, const std::string& sub);
76 
79  static std::string before(const std::string& str, char sub);
80 
83  static std::string after(const std::string& str, const std::string& sub);
84 
87  static int find(const std::string& str, const std::string& sub);
88 
90  static bool isWhite(const std::string& str);
91 
93  static std::string fixUnprintableCharacters(const std::string& str);
94 
96  static bool isNonWhite(const std::string& str) {return !isWhite(str);}
97 
103  static std::string between(const std::string& str, const std::string& begin,
104  const std::string& end, std::string& front, std::string& back);
105 
109  static std::string subString(const std::string& str, int begin, int end);
110 
111  static std::string readFromStream(std::istream& is);
112 
114  static std::string allCaps(const std::string& str);
115 
117  static double atof(const std::string& str);
118 
120  static int atoi(const std::string& str);
121 
123  static std::ostream& printLines(
124  std::ostream &os
125  ,const std::string &linePrefix
126  ,const std::string &lines
127  );
128 
130  static std::string removeAllSpaces(std::string stringToClean);
131 
132 };
133 
134 
135 } // namespace Teuchos
136 
137 
138 #endif
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
#define TEUCHOSCORE_LIB_DLL_EXPORT
Provides std::string manipulation utilities that are not provided in the standard C++ std::string cla...
Templated array class derived from the STL std::vector.
static bool isNonWhite(const std::string &str)
Returns true if a std::string has any non-whitespace.
A utilities class for Teuchos.