Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Static Public Member Functions | List of all members
Teuchos::StrUtils Class Reference

Provides std::string manipulation utilities that are not provided in the standard C++ std::string class. More...

#include <Teuchos_StrUtils.hpp>

Static Public Member Functions

static Array< std::string > readFile (std::istream &is, char comment)
 Read a file, putting each line into a std::string. More...
 
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. More...
 
static Array< Array
< std::string > > 
tokenizeFile (std::istream &is, char comment)
 Tokenize a file into whitespace-delimited tokens. More...
 
static bool readLine (std::istream &is, std::string &line)
 Read a single line into a std::string. More...
 
static Array< std::string > stringTokenizer (const std::string &str)
 
static Array< std::string > getTokensPlusWhitespace (const std::string &str)
 
static std::string reassembleFromTokens (const Array< std::string > &tokens, int iStart=0)
 
static void splitList (const std::string &bigstring, Array< std::string > &elements)
 
static int findNextWhitespace (const std::string &str, int offset)
 
static int findNextNonWhitespace (const std::string &str, int offset)
 
static std::string varSubstitute (const std::string &rawLine, const std::string &varName, const std::string &varValue)
 
static std::string varTableSubstitute (const std::string &rawLine, const Array< std::string > &varNames, const Array< std::string > &varValues)
 
static std::string envSubstitute (const std::string &line)
 
static std::string before (const std::string &str, const std::string &sub)
 Find the substring before a specified substring. For example, before("abcdefghij", "gh") returns "abcdef". More...
 
static std::string before (const std::string &str, char sub)
 Find the substring before a specified character. For example, before("abcdefghij", 'g') returns "abcdef". More...
 
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". More...
 
static int find (const std::string &str, const std::string &sub)
 Find the position at which a substring first occurs. For example, find("abcdefghij", "gh") returns 6. More...
 
static bool isWhite (const std::string &str)
 Returns true if a std::string consists entirely of whitespace. More...
 
static std::string fixUnprintableCharacters (const std::string &str)
 Convert unprintable non-null characters to whitespace. More...
 
static bool isNonWhite (const std::string &str)
 Returns true if a std::string has any non-whitespace. More...
 
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 and after the delimiters. More...
 
static std::string subString (const std::string &str, int begin, int end)
 Returns the substring between two positions. More...
 
static std::string allCaps (const std::string &str)
 Converts a std::string to all upper case. More...
 
static double atof (const std::string &str)
 Returns the double value of a std::string. More...
 
static int atoi (const std::string &str)
 Returns the int value of a std::string. More...
 
static std::ostream & printLines (std::ostream &os, const std::string &linePrefix, const std::string &lines)
 Print lines with prefix first. More...
 
static std::string removeAllSpaces (std::string stringToClean)
 Removes all the spaces in a string. More...
 

Detailed Description

Provides std::string manipulation utilities that are not provided in the standard C++ std::string class.

Definition at line 61 of file Teuchos_StrUtils.hpp.

Member Function Documentation

Array< std::string > Teuchos::StrUtils::readFile ( std::istream &  is,
char  comment 
)
static

Read a file, putting each line into a std::string.

Definition at line 49 of file Teuchos_StrUtils.cpp.

Array< std::string > Teuchos::StrUtils::splitIntoLines ( const std::string &  input)
static

Split an input std::string that contains newlines into an array of strings, one for each line.

Definition at line 64 of file Teuchos_StrUtils.cpp.

Array< Array< std::string > > Teuchos::StrUtils::tokenizeFile ( std::istream &  is,
char  comment 
)
static

Tokenize a file into whitespace-delimited tokens.

Definition at line 84 of file Teuchos_StrUtils.cpp.

bool Teuchos::StrUtils::readLine ( std::istream &  is,
std::string &  line 
)
static

Read a single line into a std::string.

Definition at line 105 of file Teuchos_StrUtils.cpp.

Array< std::string > Teuchos::StrUtils::stringTokenizer ( const std::string &  str)
static

Definition at line 144 of file Teuchos_StrUtils.cpp.

Array< std::string > Teuchos::StrUtils::getTokensPlusWhitespace ( const std::string &  str)
static

Definition at line 120 of file Teuchos_StrUtils.cpp.

std::string Teuchos::StrUtils::reassembleFromTokens ( const Array< std::string > &  tokens,
int  iStart = 0 
)
static

Definition at line 161 of file Teuchos_StrUtils.cpp.

void Teuchos::StrUtils::splitList ( const std::string &  bigstring,
Array< std::string > &  elements 
)
static

Definition at line 175 of file Teuchos_StrUtils.cpp.

int Teuchos::StrUtils::findNextWhitespace ( const std::string &  str,
int  offset 
)
static

Definition at line 218 of file Teuchos_StrUtils.cpp.

int Teuchos::StrUtils::findNextNonWhitespace ( const std::string &  str,
int  offset 
)
static

Definition at line 231 of file Teuchos_StrUtils.cpp.

std::string Teuchos::StrUtils::varSubstitute ( const std::string &  rawLine,
const std::string &  varName,
const std::string &  varValue 
)
static

Definition at line 261 of file Teuchos_StrUtils.cpp.

std::string Teuchos::StrUtils::varTableSubstitute ( const std::string &  rawLine,
const Array< std::string > &  varNames,
const Array< std::string > &  varValues 
)
static

Definition at line 244 of file Teuchos_StrUtils.cpp.

static std::string Teuchos::StrUtils::envSubstitute ( const std::string &  line)
static

std::string Teuchos::StrUtils::before ( const std::string &  str,
const std::string &  sub 
)
static

Find the substring before a specified substring. For example, before("abcdefghij", "gh") returns "abcdef".

Definition at line 287 of file Teuchos_StrUtils.cpp.

std::string Teuchos::StrUtils::before ( const std::string &  str,
char  sub 
)
static

Find the substring before a specified character. For example, before("abcdefghij", 'g') returns "abcdef".

Definition at line 278 of file Teuchos_StrUtils.cpp.

std::string Teuchos::StrUtils::after ( const std::string &  str,
const std::string &  sub 
)
static

Find the substring after a specified substring. For example, before("abcdefghij", "gh") returns "ij".

Definition at line 300 of file Teuchos_StrUtils.cpp.

int Teuchos::StrUtils::find ( const std::string &  str,
const std::string &  sub 
)
static

Find the position at which a substring first occurs. For example, find("abcdefghij", "gh") returns 6.

Definition at line 315 of file Teuchos_StrUtils.cpp.

bool Teuchos::StrUtils::isWhite ( const std::string &  str)
static

Returns true if a std::string consists entirely of whitespace.

Definition at line 323 of file Teuchos_StrUtils.cpp.

std::string Teuchos::StrUtils::fixUnprintableCharacters ( const std::string &  str)
static

Convert unprintable non-null characters to whitespace.

Definition at line 337 of file Teuchos_StrUtils.cpp.

static bool Teuchos::StrUtils::isNonWhite ( const std::string &  str)
inlinestatic

Returns true if a std::string has any non-whitespace.

Definition at line 131 of file Teuchos_StrUtils.hpp.

std::string Teuchos::StrUtils::between ( const std::string &  str,
const std::string &  begin,
const std::string &  end,
std::string &  front,
std::string &  back 
)
static

Returns the std::string between two delimiting strings, and returns by reference the strings before and after the delimiters.

For example, between("abcdefghij", "c", "g", front, back) returns "def" and sets front to "ab", back to "hij".

Definition at line 355 of file Teuchos_StrUtils.cpp.

std::string Teuchos::StrUtils::subString ( const std::string &  str,
int  begin,
int  end 
)
static

Returns the substring between two positions.

For example, subString("abcdefghij", 2, 5) returns "cde".

Definition at line 366 of file Teuchos_StrUtils.cpp.

std::string Teuchos::StrUtils::allCaps ( const std::string &  str)
static

Converts a std::string to all upper case.

Definition at line 389 of file Teuchos_StrUtils.cpp.

double Teuchos::StrUtils::atof ( const std::string &  str)
static

Returns the double value of a std::string.

Definition at line 400 of file Teuchos_StrUtils.cpp.

int Teuchos::StrUtils::atoi ( const std::string &  str)
static

Returns the int value of a std::string.

Definition at line 406 of file Teuchos_StrUtils.cpp.

std::ostream & Teuchos::StrUtils::printLines ( std::ostream &  os,
const std::string &  linePrefix,
const std::string &  lines 
)
static

Print lines with prefix first.

Definition at line 412 of file Teuchos_StrUtils.cpp.

std::string Teuchos::StrUtils::removeAllSpaces ( std::string  stringToClean)
static

Removes all the spaces in a string.

Definition at line 428 of file Teuchos_StrUtils.cpp.


The documentation for this class was generated from the following files: