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
16
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<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
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.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
Provides std::string manipulation utilities that are not provided in the standard C++ std::string cla...
static int findNextNonWhitespace(const std::string &str, int offset)
static int find(const std::string &str, const std::string &sub)
Find the position at which a substring first occurs. For example, find("abcdefghij",...
static Array< std::string > splitIntoLines(const std::string &input)
Split an input std::string that contains newlines into an array of strings, one for each line.
static std::string varSubstitute(const std::string &rawLine, const std::string &varName, const std::string &varValue)
static std::string after(const std::string &str, const std::string &sub)
Find the substring after a specified substring. For example, before("abcdefghij", "gh") returns "ij".
static int findNextWhitespace(const std::string &str, int offset)
static Array< std::string > getTokensPlusWhitespace(const std::string &str)
static void splitList(const std::string &bigstring, Array< std::string > &elements)
static std::string fixUnprintableCharacters(const std::string &str)
Convert unprintable non-null characters to whitespace.
static Array< Array< std::string > > tokenizeFile(std::istream &is, char comment)
Tokenize a file into whitespace-delimited tokens.
static std::string reassembleFromTokens(const Array< std::string > &tokens, int iStart=0)
static Array< std::string > stringTokenizer(const std::string &str)
static Array< std::string > readFile(std::istream &is, char comment)
Read a file, putting each line into a std::string.
static bool isNonWhite(const std::string &str)
Returns true if a std::string has any non-whitespace.
static bool isWhite(const std::string &str)
Returns true if a std::string consists entirely of whitespace.
static bool readLine(std::istream &is, std::string &line)
Read a single line into a std::string.
static std::string varTableSubstitute(const std::string &rawLine, const Array< std::string > &varNames, const Array< std::string > &varValues)
static std::string before(const std::string &str, const std::string &sub)
Find the substring before a specified substring. For example, before("abcdefghij",...
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...