69 for (
size_t p=0;
p<
len; ++
p) {
94 if (
lines[
i].length() == 0)
continue;
96 if (
tokens.length() == 0)
continue;
108 if (
line.length() > 0)
line[0] =
'\0';
110 if (
is.eof())
return false;
111 if (
is.getline(
c, 499))
113 line = std::string(
c);
122 unsigned int start = 0;
124 while(start <
str.length())
135 if (start-stop == 0)
return rtn;
146 unsigned int start = 0;
148 while(start <
str.length())
152 if (start-stop == 0)
return rtn;
191 for (
unsigned int i=1;
i<
big.length();
i++)
227 return static_cast<int>(
str.length());
240 return static_cast<int>(
str.length());
250 "mismatched variable tables in varTableSubstitute");
290 std::runtime_error,
"String::before: arg is null pointer");
292 char*
p = std::strstr((
char*)
str.c_str(), (
char*)
sub.c_str());
293 if (
p==0)
return str;
303 std::runtime_error,
"String::after: arg is null pointer");
306 char*
p = std::strstr((
char*)
str.c_str(), (
char*)
sub.c_str()) ;
308 if (
p==0)
return std::string();
310 p+= std::strlen(
sub.c_str());
311 return std::string(
p);
317 char*
p = std::strstr((
char*)
str.c_str(), (
char*)
sub.c_str());
319 return static_cast<int>(
p-
str.c_str());
325 for (
unsigned int i=0;
i<
str.length();
i++)
327 unsigned char c =
str[
i];
328 if (
c >= 33 &&
c <= 126)
340 for (
unsigned int i=0;
i<
rtn.length();
i++)
342 unsigned char c =
rtn[
i];
345 if (
c !=
'\t' &&
c !=
'\n'&&
c !=
'\r' &&
c !=
'\f' &&
c !=
' ')
356 const std::string& end, std::string& front,
368 return std::string(
str.c_str()+begin, end-begin);
375 "StrUtils::readFromStream isn't implemented yet");
392 for (
unsigned int i=0;
i<
rtn.length();
i++)
402 return std::atof(
s.c_str());
408 return std::atoi(
s.c_str());
415 ,
const std::string &
lines
430 std::string::size_type
pos=0;
435 if(
pos != string::npos){
A std::string utilities class for Teuchos.
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
Concrete serial communicator subclass.
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::ostream & printLines(std::ostream &os, const std::string &linePrefix, const std::string &lines)
Print lines with prefix first.
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 std::string readFromStream(std::istream &is)
static Array< std::string > getTokensPlusWhitespace(const std::string &str)
static void splitList(const std::string &bigstring, Array< std::string > &elements)
static std::string subString(const std::string &str, int begin, int end)
Returns the substring between two positions.
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 double atof(const std::string &str)
Returns the double value of a std::string.
static std::string between(const std::string &str, const std::string &begin, const std::string &end, std::string &front, std::string &back)
Returns the std::string between two delimiting strings, and returns by reference the strings before a...
static std::string reassembleFromTokens(const Array< std::string > &tokens, int iStart=0)
static Array< std::string > stringTokenizer(const std::string &str)
static std::string allCaps(const std::string &str)
Converts a std::string to all upper case.
static Array< std::string > readFile(std::istream &is, char comment)
Read a file, putting each line into a std::string.
static std::string removeAllSpaces(std::string stringToClean)
Removes all the spaces in a string.
static bool isWhite(const std::string &str)
Returns true if a std::string consists entirely of whitespace.
static int atoi(const std::string &str)
Returns the int value of a std::string.
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",...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.