ROSE
0.9.6a
|
#include "commandline_processing.h"
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <stdint.h>
Go to the source code of this file.
Classes | |
struct | StringUtility::StringWithLineNumber |
class | StringUtility::FileNameClassification |
Namespaces | |
StringUtility | |
Constant Groups | |
StringUtility | |
Functions | |
ROSE_UTIL_API std::string | StringUtility::getAbsolutePathFromRelativePath (const std::string &relativePath, bool printErrorIfAny) |
Get the absolute path from the relative path. More... | |
std::ostream & | StringUtility::operator<< (std::ostream &os, const StringWithLineNumber &s) |
ROSE_UTIL_API std::string | StringUtility::toString (const FileWithLineNumbers &strings, const std::string &filename="<unknown>", int line=1) |
FileWithLineNumbers & | StringUtility::operator+= (FileWithLineNumbers &a, const FileWithLineNumbers &b) |
FileWithLineNumbers | StringUtility::operator+ (const FileWithLineNumbers &a, const FileWithLineNumbers &b) |
FileWithLineNumbers & | StringUtility::operator<< (FileWithLineNumbers &f, const std::string &str) |
FileWithLineNumbers & | StringUtility::operator<< (FileWithLineNumbers &f, const char *str) |
ROSE_UTIL_API void | StringUtility::writeFile (const std::string &outputString, const std::string &fileNameString, const std::string &directoryName) |
Generate a file. More... | |
ROSE_UTIL_API std::string | StringUtility::readFile (const std::string &fileName) |
Read an existing file. More... | |
ROSE_UTIL_API FileWithLineNumbers | StringUtility::readFileWithPos (const std::string &fileName) |
Read a file, keeping source line number information. More... | |
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) More... | |
ROSE_UTIL_API std::string | StringUtility::convertToLowerCase (const std::string &inputString) |
Convert string to lower case (e.g. for module file name generation). More... | |
bool | StringUtility::popen_wrapper (const std::string &command, std::vector< std::string > &result) |
Popen wrapper to support demangling mangled functions. More... | |
std::string | StringUtility::demangledName (std::string s) |
Support for demangling mangled functions. More... | |
std::list< std::string > | StringUtility::findfile (std::string patternString, std::string pathString) |
ROSE_UTIL_API 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). More... | |
ROSE_UTIL_API OSType | StringUtility::getOSType () |
void | StringUtility::homeDir (std::string &homeDir) |
ROSE_UTIL_API FileNameClassification | StringUtility::classifyFileName (const std::string &fileName, const std::string &appPath) |
ROSE_UTIL_API FileNameClassification | StringUtility::classifyFileName (const std::string &fileName, const std::string &appPath, OSType os) |
ROSE_UTIL_API FileNameClassification | StringUtility::classifyFileName (const std::string &fileName, const std::string &appPath, const std::map< std::string, std::string > &libPathCollection) |
ROSE_UTIL_API FileNameClassification | StringUtility::classifyFileName (const std::string &fileName, const std::string &appPath, const std::map< std::string, std::string > &libPathCollection, OSType os) |
ROSE_UTIL_API const std::string | StringUtility::stripDotsFromHeaderFileName (const std::string &name) |
ROSE_UTIL_API int | StringUtility::directoryDistance (const std::string &left, const std::string &right) |
ROSE_UTIL_API std::string | StringUtility::htmlEscape (const std::string &s) |
ROSE_UTIL_API std::vector < std::string > | StringUtility::readWordsInFile (std::string filename) |
ROSE_UTIL_API std::string | StringUtility::appendAsmComment (const std::string &s, const std::string &comment) |
Append an assembly comment to a string. More... | |
ROSE_UTIL_API std::string | StringUtility::prefixLines (const std::string &lines, const std::string &prefix, bool prefixAtFront=true, bool prefixAtBack=false) |
Insert a prefix string before every line. More... | |
ROSE_UTIL_API bool | StringUtility::isLineTerminated (const std::string &s) |
Returns true if the string ends with line termination. More... | |
ROSE_UTIL_API std::string | StringUtility::fixLineTermination (const std::string &input) |
Normalizes line termination. More... | |
ROSE_UTIL_API std::string | StringUtility::makeOneLine (const std::string &s, std::string replacement=" ") |
Converts a multi-line string to a single line. More... | |
std::vector< uint8_t > | StringUtility::decode_base64 (const std::string &encoded) |
Convert base-64 to binary. More... | |
ROSE_UTIL_API std::vector < std::string > | StringUtility::split (const std::string &separator, const std::string &str, size_t maxparts=(size_t)(-1), bool trim_white_space=false) |
Splits strings into parts. More... | |
ROSE_UTIL_API std::vector < std::string > | StringUtility::split (char separator, const std::string &str, size_t maxparts=(size_t)(-1), bool trim_white_space=false) |
ROSE_UTIL_API std::string | StringUtility::trim (const std::string &str, const std::string &strip=" \t\r\n", bool at_beginning=true, bool at_end=true) |
Trims white space from the beginning and end of a string. More... | |
std::string | StringUtility::untab (const std::string &str, size_t tabstops=8, size_t firstcol=0) |
Expand horizontal tab characters. More... | |
template<typename T > | |
std::string | StringUtility::plural (T n, const std::string &plural_word) |
Helpful way to print singular or plural words. More... | |
New C++ string functions | |
C++ string style support. Supporting functions for string operations common within ROSE. Uses C++ string interface. | |
ROSE_UTIL_API std::string | StringUtility::copyEdit (const std::string &inputString, const std::string &oldToken, const std::string &newToken) |
Substring replacement function. More... | |
ROSE_UTIL_API std::string | StringUtility::numberToString (long long x) |
Convert a number to a string. More... | |
ROSE_UTIL_API std::string | StringUtility::numberToString (unsigned long long x) |
Substring replacement function. More... | |
ROSE_UTIL_API std::string | StringUtility::numberToString (long x) |
Substring replacement function. More... | |
ROSE_UTIL_API std::string | StringUtility::numberToString (unsigned long x) |
Substring replacement function. More... | |
ROSE_UTIL_API std::string | StringUtility::numberToString (int x) |
Substring replacement function. More... | |
ROSE_UTIL_API std::string | StringUtility::numberToString (unsigned int x) |
Substring replacement function. More... | |
ROSE_UTIL_API std::string | StringUtility::intToHex (uint64_t i) |
Convert an integer to a Hex string. More... | |
ROSE_UTIL_API std::string | StringUtility::numberToString (const void *x) |
Convert a unsigned integer (size_t) to a string. More... | |
ROSE_UTIL_API std::string | StringUtility::numberToString (double x) |
Convert a number to a string. More... | |
ROSE_UTIL_API std::string | StringUtility::addrToString (uint64_t x, size_t nbits=32) |
Convert an address to a string, preferring a hexadecimal representation with at least 8 digits. The second argument. More... | |
ROSE_UTIL_API std::string | StringUtility::indentMultilineString (const std::string &inputString, int statementColumnNumber) |
Formatting support for generated code strings. More... | |
ROSE_UTIL_API std::string | StringUtility::listToString (const std::list< int > &X, bool separateStrings=false) |
Generate a string from a list of ints. More... | |
ROSE_UTIL_API std::string | StringUtility::listToString (const std::list< std::string > &X, bool separateStrings=false) |
Generate a string from a list of strings. More... | |
ROSE_UTIL_API std::list < std::string > | StringUtility::stringToList (const std::string &X) |
Generate a list of strings from a string (list elements are delimited by "\n"). More... | |
ROSE_UTIL_API std::string | StringUtility::listToString (const std::vector< std::string > &X, bool separateStrings=false) |
Generate a string from a vector of strings. More... | |
ROSE_UTIL_API std::list < std::string > | StringUtility::tokenize (std::string X, char delim) |
Substring replacement function. More... | |
ROSE_UTIL_API std::string | StringUtility::removeRedundentSubstrings (std::string X) |
Remove redundant lines (substrings must be separated by "\n". FIXME (spelling) More... | |
ROSE_UTIL_API std::string | StringUtility::removePseudoRedundentSubstrings (std::string X) |
Remove redundant lines containing special substrings of form string#. FIXME (spelling) More... | |
ROSE_UTIL_API void | StringUtility::add_to_reason_string (std::string &result, bool isset, bool do_pad, const std::string &abbr, const std::string &full) |
Append an abbreviation or full name to a string. More... | |
Old C style string support functions | |
C style string support.
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. | |
ROSE_UTIL_API FileWithLineNumbers | StringUtility::copyEdit (const FileWithLineNumbers &inputString, const std::string &oldToken, const std::string &newToken) |
A smarter string concatination function (corrects for space in the target automatically) More... | |
ROSE_UTIL_API FileWithLineNumbers | StringUtility::copyEdit (const FileWithLineNumbers &inputString, const std::string &oldToken, const FileWithLineNumbers &newToken) |
A smarter string concatination function (corrects for space in the target automatically) More... | |
bool | StringUtility::isContainedIn (const std::string &longString, const std::string &shortString) |
A smarter string concatination function (corrects for space in the target automatically) More... | |
void | StringUtility::splitStringIntoStrings (const std::string &inputString, char separator, std::vector< std::string > &stringList) |
A smarter string concatination function (corrects for space in the target automatically) More... | |
File name strings | |
Handling for /path/name.suffix. Namespace CommandlineProcessing also has some file name handling functions. | |
ROSE_UTIL_API std::string | StringUtility::stripPathFromFileName (const std::string &fileNameWithPath) |
Get name.suffix from /path/name.suffix. More... | |
ROSE_UTIL_API std::string | StringUtility::getPathFromFileName (const std::string &fileNameWithPath) |
Get the path from the full file name: /path/name.suffix. More... | |
ROSE_UTIL_API std::string | StringUtility::stripFileSuffixFromFileName (const std::string &fileNameWithSuffix) |
Get the file name without the ".suffix". More... | |
ROSE_UTIL_API std::string | StringUtility::fileNameSuffix (const std::string &fileName) |
Get the file name suffix (extension) without the leading dot, fileName could be either base name or name with full path. More... | |
ROSE_UTIL_API std::string | StringUtility::toHex2 (uint64_t value, size_t nbits, bool show_unsigned_decimal=true, bool show_signed_decimal=true, uint64_t decimal_threshold=256) |
Convert a number to a hexadecimal and decimal string. More... | |
ROSE_UTIL_API std::string | StringUtility::signedToHex2 (uint64_t value, size_t nbits) |
Convert a number to a hexadecimal and decimal string. More... | |
ROSE_UTIL_API std::string | StringUtility::unsignedToHex2 (uint64_t value, size_t nbits) |
Convert a number to a hexadecimal and decimal string. More... | |
template<typename T > | |
std::string | StringUtility::toHex (T value) |
Convert a number to a hexadecimal and decimal string. More... | |
template<typename T > | |
std::string | StringUtility::signedToHex (T value) |
Convert a number to a hexadecimal and decimal string. More... | |
template<typename T > | |
std::string | StringUtility::unsignedToHex (T value) |
Convert a number to a hexadecimal and decimal string. More... | |
std::string | StringUtility::encode_base64 (const std::vector< uint8_t > &data, bool do_pad=true) |
Convert binary data to base-64. More... | |
std::string | StringUtility::encode_base64 (const uint8_t *data, size_t nbytes, bool do_padd=true) |
Convert binary data to base-64. More... | |
template<class Container > | |
std::string | StringUtility::join (const std::string &separator, const Container &strings) |
Join individual strings to form a single string. More... | |
template<class Iterator > | |
std::string | StringUtility::join_range (const std::string &separator, Iterator begin, Iterator end) |
Join individual strings to form a single string. More... | |
std::string | StringUtility::join (const std::string &separator, char *strings[], size_t nstrings) |
Join individual strings to form a single string. More... | |
std::string | StringUtility::join (const std::string &separator, const char *strings[], size_t nstrings) |
Join individual strings to form a single string. More... | |
template<class Container , class Stringifier > | |
std::vector< std::string > | StringUtility::toStrings (const Container &numbers, const Stringifier &stringifier=numberToString) |
Converts a bunch of numbers to strings. More... | |
template<class Iterator , class Stringifier > | |
std::vector< std::string > | StringUtility::toStrings_range (Iterator begin, Iterator end, const Stringifier &stringifier=numberToString) |
Converts a bunch of numbers to strings. More... | |