Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
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
18
19#include "Teuchos_Utils.hpp"
20#include "Teuchos_Array.hpp"
21
22namespace Teuchos {
23
24
29class TEUCHOSCORE_LIB_DLL_EXPORT StrUtils
30{
31public:
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<std::string> splitString(const std::string_view s, const char sep = ',');
41
43 static Array<Array<std::string> > tokenizeFile(std::istream& is, char comment);
44
46 static bool readLine(std::istream& is, std::string& line);
47
49 static Array<std::string> stringTokenizer(const std::string& str);
50
52 static Array<std::string> getTokensPlusWhitespace(const std::string& str);
53
55 static std::string reassembleFromTokens(const Array<std::string>& tokens, int iStart=0);
56
58 static void splitList(const std::string& bigstring, Array<std::string>& elements);
59
61 static int findNextWhitespace(const std::string& str, int offset);
62
64 static int findNextNonWhitespace(const std::string& str, int offset);
65
67 static std::string varSubstitute(const std::string& rawLine,
68 const std::string& varName,
69 const std::string& varValue);
70
72 static std::string varTableSubstitute(const std::string& rawLine,
75
78 static std::string before(const std::string& str, const std::string& sub);
79
82 static std::string before(const std::string& str, char sub);
83
86 static std::string after(const std::string& str, const std::string& sub);
87
90 static int find(const std::string& str, const std::string& sub);
91
93 static bool isWhite(const std::string& str);
94
96 static std::string fixUnprintableCharacters(const std::string& str);
97
99 static bool isNonWhite(const std::string& str) {return !isWhite(str);}
100
106 static std::string between(const std::string& str, const std::string& begin,
107 const std::string& end, std::string& front, std::string& back);
108
112 static std::string subString(const std::string& str, int begin, int end);
113
114 static std::string readFromStream(std::istream& is);
115
117 static std::string allCaps(const std::string& str);
118
120 static double atof(const std::string& str);
121
123 static int atoi(const std::string& str);
124
126 static std::ostream& printLines(
127 std::ostream &os
128 ,const std::string &linePrefix
129 ,const std::string &lines
130 );
131
133 static std::string removeAllSpaces(std::string stringToClean);
134
135};
136
137
138} // namespace Teuchos
139
140
141#endif
Templated array class derived from the STL std::vector.
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
A utilities class for Teuchos.
Smart reference counting pointer class for automatic garbage collection.
Provides std::string manipulation utilities that are not provided in the standard C++ std::string cla...
static bool isNonWhite(const std::string &str)
Returns true if a std::string has any non-whitespace.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...