OGRE 14.3
Object-Oriented Graphics Rendering Engine
Loading...
Searching...
No Matches
Ogre::StringUtil Class Reference

Utility class for manipulating Strings. More...

#include <OgreString.h>

Public Types

typedef StringStream StrStreamType
 

Static Public Member Functions

static bool endsWith (const String &str, const String &pattern, bool lowerCase=true)
 Returns whether the string ends with the pattern passed in.
 
static String format (const char *fmt,...)
 create a string from a printf expression
 
static bool match (const String &str, const String &pattern, bool caseSensitive=true)
 Simple pattern-matching routine allowing a wildcard pattern.
 
static String normalizeFilePath (const String &init, bool makeLowerCase=false)
 Returns a normalized version of a file path This method can be used to make file path strings which point to the same directory but have different texts to be normalized to the same text.
 
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.
 
static std::vector< Stringsplit (const String &str, const String &delims="\t\n ", unsigned int maxSplits=0, bool preserveDelims=false)
 Returns a StringVector that contains all the substrings delimited by the characters in the passed delims argument.
 
static void splitBaseFilename (const Ogre::String &fullName, Ogre::String &outBasename, Ogre::String &outExtention)
 Method for splitting a filename into the base name and extension.
 
static void splitFilename (const String &qualifiedName, String &outBasename, String &outPath)
 Method for splitting a fully qualified filename into the base name and path.
 
static void splitFullFilename (const Ogre::String &qualifiedName, Ogre::String &outBasename, Ogre::String &outExtention, Ogre::String &outPath)
 Method for splitting a fully qualified filename into the base name, extension and path.
 
static String standardisePath (const String &init)
 Method for standardising paths - use forward slashes only, end with slash.
 
static bool startsWith (const String &str, const String &pattern, bool lowerCase=true)
 Returns whether the string begins with the pattern passed in.
 
static std::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) delimiters in the tokenised string.
 
static void toLowerCase (String &str)
 Lower-cases all the characters in the string.
 
static void toTitleCase (String &str)
 Upper-cases the first letter of each word.
 
static void toUpperCase (String &str)
 Upper-cases all the characters in the string.
 
static void trim (String &str, bool left=true, bool right=true)
 Removes any whitespace characters, be it standard space or TABs and so on.
 

Static Public Attributes

static const StringBLANK
 

Detailed Description

Utility class for manipulating Strings.


Member Typedef Documentation

◆ StrStreamType

Member Function Documentation

◆ trim()

static void Ogre::StringUtil::trim ( String str,
bool  left = true,
bool  right = true 
)
static

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

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

◆ split()

static std::vector< String > Ogre::StringUtil::split ( const String str,
const String delims = "\t\n ",
unsigned int  maxSplits = 0,
bool  preserveDelims = false 
)
static

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

Parameters
str
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.
preserveDelimsFlag to determine if delimiters should be saved as substrings

Referenced by Ogre::StringConverter::parseStringVector().

◆ tokenise()

static std::vector< String > Ogre::StringUtil::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) delimiters in the tokenised string.

For example, "strings like this".

Parameters
str
delimsA list of delimiter characters to split by
doubleDelimsA list of double delimiters 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.

◆ toLowerCase()

static void Ogre::StringUtil::toLowerCase ( String str)
static

Lower-cases all the characters in the string.

◆ toUpperCase()

static void Ogre::StringUtil::toUpperCase ( String str)
static

Upper-cases all the characters in the string.

◆ toTitleCase()

static void Ogre::StringUtil::toTitleCase ( String str)
static

Upper-cases the first letter of each word.

◆ startsWith()

static bool Ogre::StringUtil::startsWith ( const String str,
const String pattern,
bool  lowerCase = true 
)
static

Returns whether the string begins with the pattern passed in.

Parameters
str
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.

◆ endsWith()

static bool Ogre::StringUtil::endsWith ( const String str,
const String pattern,
bool  lowerCase = true 
)
static

Returns whether the string ends with the pattern passed in.

Parameters
str
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.

◆ standardisePath()

static String Ogre::StringUtil::standardisePath ( const String init)
static

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

◆ normalizeFilePath()

static String Ogre::StringUtil::normalizeFilePath ( const String init,
bool  makeLowerCase = false 
)
static

Returns a normalized version of a file path This method can be used to make file path strings which point to the same directory but have different texts to be normalized to the same text.

The function:

  • Transforms all backward slashes to forward slashes.
  • Removes repeating slashes.
  • Removes initial slashes from the beginning of the path.
  • Removes ".\" and ".." meta directories.
  • Sets all characters to lowercase (if requested)
    Parameters
    initThe file path to normalize.
    makeLowerCaseIf true, transforms all characters in the string to lowercase.

◆ splitFilename()

static void Ogre::StringUtil::splitFilename ( const String qualifiedName,
String outBasename,
String outPath 
)
static

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

Path is standardised as in standardisePath

◆ splitFullFilename()

static void Ogre::StringUtil::splitFullFilename ( const Ogre::String qualifiedName,
Ogre::String outBasename,
Ogre::String outExtention,
Ogre::String outPath 
)
static

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

Path is standardised as in standardisePath

◆ splitBaseFilename()

static void Ogre::StringUtil::splitBaseFilename ( const Ogre::String fullName,
Ogre::String outBasename,
Ogre::String outExtention 
)
static

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

◆ match()

static bool Ogre::StringUtil::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

◆ replaceAll()

static const String Ogre::StringUtil::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

◆ format()

static String Ogre::StringUtil::format ( const char fmt,
  ... 
)
static

create a string from a printf expression

Note
this function - like printf - uses a locale dependent decimal point

Referenced by Ogre::Font::getGlyphInfo().

Member Data Documentation

◆ BLANK

const String& Ogre::StringUtil::BLANK
static

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