StringUtility Namespace Reference


New C++ string functions

C++ string style support.

Supporting functions for string operations common within ROSE.

For internal use only.

Uses C++ string interface.



std::string copyEdit (const std::string &inputString, const std::string &oldToken, const std::string &newToken)
 Substring replacement function.
std::string numberToString (long long x)
 Convert a number to a string.
std::string numberToString (unsigned long long x)
 Substring replacement function.
std::string numberToString (long x)
 Substring replacement function.
std::string numberToString (unsigned long x)
 Substring replacement function.
std::string numberToString (int x)
 Substring replacement function.
std::string numberToString (unsigned int x)
 Substring replacement function.
std::string intToHex (uint64_t i)
 Convert an integer to a Hex string.
std::string numberToString (const void *x)
 Convert a pointer value to a string.
std::string numberToString (double x)
 Convert a number to a string.
std::string addrToString (uint64_t x)
 Convert an address to a string, preferring a hexadecimal representation with at least 8 digits.
std::string indentMultilineString (const std::string &inputString, int statementColumnNumber)
 Formatting support for generated code strings.
std::string listToString (const std::list< int > &X, bool separateStrings=false)
 Generate a string from a list of ints.
std::string listToString (const std::list< std::string > &X, bool separateStrings=false)
 Generate a string from a list of strings.
std::list< std::string > stringToList (const std::string &X)
 Generate a list of strings from a string (list elements are delimited by "\n").
std::string listToString (const std::vector< std::string > &X, bool separateStrings=false)
 Generate a string from a vector of strings.
std::string removeRedundentSubstrings (std::string X)
 Remove redundent lines (substrings must be separated by "\n".
std::string removePseudoRedundentSubstrings (std::string X)
 Remove redundent lines containing special substrings of form string#.

Old C style string support functions

C style string support.

Deprecated:
These functions will be removed after we have converted all source code to use the C++ string class.
This function was used before moving to C++ strings. It remains in use in some places where the code still uses the older C style strings.

FileWithLineNumbers copyEdit (const FileWithLineNumbers &inputString, const std::string &oldToken, const std::string &newToken)
FileWithLineNumbers copyEdit (const FileWithLineNumbers &inputString, const std::string &oldToken, const FileWithLineNumbers &newToken)
bool isContainedIn (const std::string &longString, const std::string &shortString)
void splitStringIntoStrings (const std::string &inputString, char separator, std::vector< std::string > &stringList)
 Support for commandline construction used for building argv and argc (I think) (written by Bobby Philip).

File name strings

Handling for /path/name.suffix. Namespace CommandlineProcessing also has some file name handling functions.

std::string stripPathFromFileName (const std::string &fileNameWithPath)
 Get name.suffix from /path/name.suffix.
std::string getPathFromFileName (const std::string &fileNameWithPath)
 Get the path from the full file name: /path/name.suffix.
std::string stripFileSuffixFromFileName (const std::string &fileNameWithSuffix)
 Get the file name without the ".suffix".
std::string fileNameSuffix (const std::string &fileName)
 Get the file name suffix (extension), fileName could be either base name or name with full path.

Functions

std::string getAbsolutePathFromRelativePath (const std::string &relativePath, bool printErrorIfAny)
 Get the absolute path from the relative path.
std::ostream & operator<< (std::ostream &os, const StringWithLineNumber &s)
std::string toString (const FileWithLineNumbers &strings, const std::string &filename="<unknown>", int line=1)
FileWithLineNumbersoperator+= (FileWithLineNumbers &a, const FileWithLineNumbers &b)
FileWithLineNumbers operator+ (const FileWithLineNumbers &a, const FileWithLineNumbers &b)
FileWithLineNumbersoperator<< (FileWithLineNumbers &f, const std::string &str)
FileWithLineNumbersoperator<< (FileWithLineNumbers &f, const char *str)
void writeFile (const std::string &outputString, const std::string &fileNameString, const std::string &directoryName)
 Generate a file.
std::string readFile (const std::string &fileName)
 Read an existing file.
FileWithLineNumbers readFileWithPos (const std::string &fileName)
 Read a file, keeping source line number information.
unsigned long generate_checksum (std::string s)
 Simple function to generate checksum for string (can be used with get_mangled_name() to provide simpler names).
std::string convertToLowerCase (const std::string &inputString)
 Convert string to lower case (e.g. for module file name generation).
bool popen_wrapper (const std::string &command, std::vector< std::string > &result)
 Popen wrapper to support demangling mangled functions.
std::string demangledName (std::string s)
 Support for demangling mangled functions.
std::list< std::string > findfile (std::string patternString, std::string pathString)
std::string escapeNewLineCharaters (const std::string &X)
 Translates newline characters to linefeeds and escapes quotes (used to generate text for DOT nodes containing source code).
OSType getOSType ()
void homeDir (std::string &homeDir)
FileNameClassification classifyFileName (const std::string &fileName, const std::string &appPath)
FileNameClassification classifyFileName (const std::string &fileName, const std::string &appPath, OSType os)
FileNameClassification classifyFileName (const std::string &fileName, const std::string &appPath, const std::map< std::string, std::string > &libPathCollection)
FileNameClassification classifyFileName (const std::string &fileName, const std::string &appPath, const std::map< std::string, std::string > &libPathCollection, OSType os)
const std::string stripDotsFromHeaderFileName (const std::string &name)
int directoryDistance (const std::string &left, const std::string &right)
std::string htmlEscape (const std::string &s)
std::vector< std::string > readWordsInFile (std::string filename)


Function Documentation

std::string StringUtility::getAbsolutePathFromRelativePath ( const std::string &  relativePath,
bool  printErrorIfAny = false 
)

Get the absolute path from the relative path.

std::ostream& StringUtility::operator<< ( std::ostream &  os,
const StringWithLineNumber &  s 
) [inline]

std::string StringUtility::toString ( const FileWithLineNumbers &  strings,
const std::string &  filename = "<unknown>",
int  line = 1 
)

FileWithLineNumbers& StringUtility::operator+= ( FileWithLineNumbers &  a,
const FileWithLineNumbers &  b 
) [inline]

FileWithLineNumbers StringUtility::operator+ ( const FileWithLineNumbers &  a,
const FileWithLineNumbers &  b 
) [inline]

FileWithLineNumbers& StringUtility::operator<< ( FileWithLineNumbers &  f,
const std::string &  str 
) [inline]

FileWithLineNumbers& StringUtility::operator<< ( FileWithLineNumbers &  f,
const char *  str 
) [inline]

void StringUtility::writeFile ( const std::string &  outputString,
const std::string &  fileNameString,
const std::string &  directoryName 
)

Generate a file.

std::string StringUtility::readFile ( const std::string &  fileName  ) 

Read an existing file.

FileWithLineNumbers StringUtility::readFileWithPos ( const std::string &  fileName  ) 

Read a file, keeping source line number information.

std::string StringUtility::copyEdit ( const std::string &  inputString,
const std::string &  oldToken,
const std::string &  newToken 
)

Substring replacement function.

std::string StringUtility::numberToString ( long long  x  ) 

Convert a number to a string.

std::string StringUtility::numberToString ( unsigned long long  x  ) 

Substring replacement function.

std::string StringUtility::numberToString ( long  x  ) 

Substring replacement function.

std::string StringUtility::numberToString ( unsigned long  x  ) 

Substring replacement function.

std::string StringUtility::numberToString ( int  x  ) 

Substring replacement function.

std::string StringUtility::numberToString ( unsigned int  x  ) 

Substring replacement function.

std::string StringUtility::intToHex ( uint64_t  i  ) 

Convert an integer to a Hex string.

std::string StringUtility::numberToString ( const void *  x  ) 

Convert a pointer value to a string.

std::string StringUtility::numberToString ( double  x  ) 

Convert a number to a string.

std::string StringUtility::addrToString ( uint64_t  x  ) 

Convert an address to a string, preferring a hexadecimal representation with at least 8 digits.

std::string StringUtility::indentMultilineString ( const std::string &  inputString,
int  statementColumnNumber 
)

Formatting support for generated code strings.

std::string StringUtility::listToString ( const std::list< int > &  X,
bool  separateStrings = false 
)

Generate a string from a list of ints.

std::string StringUtility::listToString ( const std::list< std::string > &  X,
bool  separateStrings = false 
)

Generate a string from a list of strings.

std::list<std::string> StringUtility::stringToList ( const std::string &  X  ) 

Generate a list of strings from a string (list elements are delimited by "\n").

std::string StringUtility::listToString ( const std::vector< std::string > &  X,
bool  separateStrings = false 
)

Generate a string from a vector of strings.

std::string StringUtility::removeRedundentSubstrings ( std::string  X  ) 

Remove redundent lines (substrings must be separated by "\n".

std::string StringUtility::removePseudoRedundentSubstrings ( std::string  X  ) 

Remove redundent lines containing special substrings of form string#.

FileWithLineNumbers StringUtility::copyEdit ( const FileWithLineNumbers &  inputString,
const std::string &  oldToken,
const std::string &  newToken 
)

FileWithLineNumbers StringUtility::copyEdit ( const FileWithLineNumbers &  inputString,
const std::string &  oldToken,
const FileWithLineNumbers &  newToken 
)

bool StringUtility::isContainedIn ( const std::string &  longString,
const std::string &  shortString 
) [inline]

void StringUtility::splitStringIntoStrings ( const std::string &  inputString,
char  separator,
std::vector< std::string > &  stringList 
)

Support for commandline construction used for building argv and argc (I think) (written by Bobby Philip).

unsigned long StringUtility::generate_checksum ( std::string  s  ) 

Simple function to generate checksum for string (can be used with get_mangled_name() to provide simpler names).

std::string StringUtility::convertToLowerCase ( const std::string &  inputString  ) 

Convert string to lower case (e.g. for module file name generation).

bool StringUtility::popen_wrapper ( const std::string &  command,
std::vector< std::string > &  result 
)

Popen wrapper to support demangling mangled functions.

std::string StringUtility::demangledName ( std::string  s  ) 

Support for demangling mangled functions.

std::string StringUtility::stripPathFromFileName ( const std::string &  fileNameWithPath  ) 

Get name.suffix from /path/name.suffix.

std::string StringUtility::getPathFromFileName ( const std::string &  fileNameWithPath  ) 

Get the path from the full file name: /path/name.suffix.

std::string StringUtility::stripFileSuffixFromFileName ( const std::string &  fileNameWithSuffix  ) 

Get the file name without the ".suffix".

std::string StringUtility::fileNameSuffix ( const std::string &  fileName  ) 

Get the file name suffix (extension), fileName could be either base name or name with full path.

std::list<std::string> StringUtility::findfile ( std::string  patternString,
std::string  pathString 
)

std::string StringUtility::escapeNewLineCharaters ( const std::string &  X  ) 

Translates newline characters to linefeeds and escapes quotes (used to generate text for DOT nodes containing source code).

OSType StringUtility::getOSType (  ) 

void StringUtility::homeDir ( std::string &  homeDir  ) 

FileNameClassification StringUtility::classifyFileName ( const std::string &  fileName,
const std::string &  appPath 
)

FileNameClassification StringUtility::classifyFileName ( const std::string &  fileName,
const std::string &  appPath,
OSType  os 
)

FileNameClassification StringUtility::classifyFileName ( const std::string &  fileName,
const std::string &  appPath,
const std::map< std::string, std::string > &  libPathCollection 
)

FileNameClassification StringUtility::classifyFileName ( const std::string &  fileName,
const std::string &  appPath,
const std::map< std::string, std::string > &  libPathCollection,
OSType  os 
)

const std::string StringUtility::stripDotsFromHeaderFileName ( const std::string &  name  ) 

int StringUtility::directoryDistance ( const std::string &  left,
const std::string &  right 
)

std::string StringUtility::htmlEscape ( const std::string &  s  ) 

std::vector<std::string> StringUtility::readWordsInFile ( std::string  filename  ) 


Generated on Tue Jan 31 05:46:29 2012 for ROSE by  doxygen 1.4.7