omegalib  13.1
omicron::StringUtils Class Reference

Utility class for manipulating Strings. More...

#include <StringUtils.h>

Public Types

enum  LogLevel { Silent, Normal, Verbose, Debug }
 Log level enumeration. More...
 

Static Public Member Functions

static void trim (String &str, bool left=true, bool right=true)
 Removes any whitespace characters, be it standard space or TABs and so on. More...
 
static Vector< Stringsplit (const String &str, const String &delims="\t\n ", unsigned int maxSplits=0)
 Returns a StringVector that contains all the substrings delimited by the characters in the passed delims argument. More...
 
static Vector< Stringtokenise (const String &str, const String &delims="\t\n ", const String &doubleDelims="\"", unsigned int maxSplits=0)
 Returns a StringVector that contains all the substrings delimited by the characters in the passed delims argument, or in the doubleDelims argument, which is used to include (normal) delimeters in the tokenised string. More...
 
static void toLowerCase (String &str)
 Lower-cases all the characters in the string. More...
 
static void toUpperCase (String &str)
 Upper-cases all the characters in the string. More...
 
static bool startsWith (const String &str, const String &pattern, bool lowerCase=true)
 Returns whether the string begins with the pattern passed in. More...
 
static bool endsWith (const String &str, const String &pattern, bool lowerCase=true)
 Returns whether the string ends with the pattern passed in. More...
 
static String standardisePath (const String &init)
 Method for standardising paths - use forward slashes only, end with slash. More...
 
static void splitFilename (const String &qualifiedName, String &outBasename, String &outPath)
 Method for splitting a fully qualified filename into the base name and path. More...
 
static void splitFullFilename (const String &qualifiedName, String &outBasename, String &outExtention, String &outPath)
 Method for splitting a fully qualified filename into the base name, extension and path. More...
 
static void splitBaseFilename (const String &fullName, String &outBasename, String &outExtention)
 Method for splitting a filename into the base name and extension. More...
 
static bool match (const String &str, const String &pattern, bool caseSensitive=true)
 Simple pattern-matching routine allowing a wildcard pattern. More...
 
static const String replaceAll (const String &source, const String &replaceWhat, const String &replaceWithWhat)
 replace all instances of a sub-string with a another sub-string. More...
 

Static Public Attributes

static LogLevel logLevel
 The current log level. More...
 
static const String BLANK
 Constant blank string, useful for returning by ref where local does not exist. More...
 

Detailed Description

Utility class for manipulating Strings.

Member Enumeration Documentation

Log level enumeration.

Enumerator
Silent 
Normal 
Verbose 
Debug 

Member Function Documentation

static bool omicron::StringUtils::endsWith ( const String str,
const String pattern,
bool  lowerCase = true 
)
static

Returns whether the string ends with the pattern passed in.

Parameters
patternThe pattern to compare with.
lowerCaseIf true, the end of the string will be lower cased before comparison, pattern should also be in lower case.
static bool omicron::StringUtils::match ( const String str,
const String pattern,
bool  caseSensitive = true 
)
static

Simple pattern-matching routine allowing a wildcard pattern.

Parameters
strString to test
patternPattern to match against; can include simple '*' wildcards
caseSensitiveWhether the match is case sensitive or not
static const String omicron::StringUtils::replaceAll ( const String source,
const String replaceWhat,
const String replaceWithWhat 
)
static

replace all instances of a sub-string with a another sub-string.

Parameters
sourceSource string
replaceWhatSub-string to find and replace
replaceWithWhatSub-string to replace with (the new sub-string)
Returns
An updated string with the sub-string replaced
static Vector<String> omicron::StringUtils::split ( const String str,
const String delims = "\t\n ",
unsigned int  maxSplits = 0 
)
static

Returns a StringVector that contains all the substrings delimited by the characters in the passed delims argument.

Parameters
delimsA list of delimiter characters to split by
maxSplitsThe maximum number of splits to perform (0 for unlimited splits). If this parameters is > 0, the splitting process will stop after this many splits, left to right.
static void omicron::StringUtils::splitBaseFilename ( const String fullName,
String outBasename,
String outExtention 
)
static

Method for splitting a filename into the base name and extension.

static void omicron::StringUtils::splitFilename ( const String qualifiedName,
String outBasename,
String outPath 
)
static

Method for splitting a fully qualified filename into the base name and path.

Remarks
Path is standardised as in standardisePath
static void omicron::StringUtils::splitFullFilename ( const String qualifiedName,
String outBasename,
String outExtention,
String outPath 
)
static

Method for splitting a fully qualified filename into the base name, extension and path.

Remarks
Path is standardised as in standardisePath
static String omicron::StringUtils::standardisePath ( const String init)
static

Method for standardising paths - use forward slashes only, end with slash.

static bool omicron::StringUtils::startsWith ( const String str,
const String pattern,
bool  lowerCase = true 
)
static

Returns whether the string begins with the pattern passed in.

Parameters
patternThe pattern to compare with.
lowerCaseIf true, the start of the string will be lower cased before comparison, pattern should also be in lower case.
static Vector<String> omicron::StringUtils::tokenise ( const String str,
const String delims = "\t\n ",
const String doubleDelims = "\"",
unsigned int  maxSplits = 0 
)
static

Returns a StringVector that contains all the substrings delimited by the characters in the passed delims argument, or in the doubleDelims argument, which is used to include (normal) delimeters in the tokenised string.

For example, "strings like this".

Parameters
delimsA list of delimiter characters to split by
delimsA list of double delimeters characters to tokenise by
maxSplitsThe maximum number of splits to perform (0 for unlimited splits). If this parameters is > 0, the splitting process will stop after this many splits, left to right.
static void omicron::StringUtils::toLowerCase ( String str)
static

Lower-cases all the characters in the string.

static void omicron::StringUtils::toUpperCase ( String str)
static

Upper-cases all the characters in the string.

static void omicron::StringUtils::trim ( String str,
bool  left = true,
bool  right = true 
)
static

Removes any whitespace characters, be it standard space or TABs and so on.

Remarks
The user may specify wether they want to trim only the beginning or the end of the String ( the default action is to trim both).

Member Data Documentation

const String omicron::StringUtils::BLANK
static

Constant blank string, useful for returning by ref where local does not exist.

LogLevel omicron::StringUtils::logLevel
static

The current log level.


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