Ogre::StringUtil Class Reference
Core » General

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. More...
static bool | match (const String &str, const String &pattern, bool caseSensitive=true)
| Simple pattern-matching routine allowing a wildcard pattern. More...
static String | normalizeFilePath (const String &init, bool makeLowerCase=true)
| 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. 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 vector< String >::type | split (const String &str, const String &delims="\ ", unsigned int maxSplits=0, bool preserveDelims=false)
| Returns a StringVector that contains all the substrings delimited by the characters in the passed `delims` argument. More...
static void | splitBaseFilename (const Ogre::String &fullName, Ogre::String &outBasename, Ogre::String &outExtention)
| Method for splitting a filename into the base name and extension. 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 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. More...
static String | standardisePath (const String &init)
| Method for standardising paths - use forward slashes only, end with slash. 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 vector< String >::type | tokenise (const String &str, const String &delims="\ ", 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 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 Public Attributes

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.

Definition at line 75 of file OgreString.h.

## Member Typedef Documentation

## StrStreamType

typedef StringStream Ogre::StringUtil::StrStreamType

Definition at line 78 of file OgreString.h.

## Member Function Documentation

## 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

  pattern | The pattern to compare with.
  lowerCase | If true, the end of the string will be lower cased before comparison, pattern should also be in lower case.

## 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

  str | String to test
  pattern | Pattern to match against; can include simple '*' wildcards
  caseSensitive | Whether the match is case sensitive or not

## normalizeFilePath()

static String Ogre::StringUtil::normalizeFilePath | ( | const String & | init,
|  | bool | makeLowerCase = `true`
| ) |  |

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

    init | The file path to normalize.
    makeLowerCase | If true, transforms all characters in the string to lowercase.

## 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

  source | Source string
  replaceWhat | Sub-string to find and replace
  replaceWithWhat | Sub-string to replace with (the new sub-string)

Returns
  An updated string with the sub-string replaced

## split()

static vector<String>::type Ogre::StringUtil::split | ( | const String & | str,
|  | const String & | delims = `"\ "`,
|  | 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

  delims | A list of delimiter characters to split by
  maxSplits | The 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.
  preserveDelims | Flag to determine if delimiters should be saved as substrings

Referenced by Ogre::DriverVersion::fromString().

## 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.

## 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.

Remarks
  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.

Remarks
  Path is standardised as in standardisePath

## standardisePath()

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

static

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

## 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

  pattern | The pattern to compare with.
  lowerCase | If true, the start of the string will be lower cased before comparison, pattern should also be in lower case.

## tokenise()

static vector<String>::type Ogre::StringUtil::tokenise | ( | const String & | str,
|  | const String & | delims = `"\ "`
| ) |  |

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

  delims | A list of delimiter characters to split by
  doubleDelims | A list of double delimeters characters to tokenise by
  maxSplits | The 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.

## 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.

Remarks
  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).

## Member Data Documentation

## BLANK

const String Ogre::StringUtil::BLANK

static

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

Definition at line 196 of file OgreString.h.

Referenced by Ogre::Mesh::_getAnimationTypesDirty(), Ogre::Animation::_keyFrameListChanged(), Ogre::AnimableObject::getAnimableDictionaryName(), Ogre::StreamSerialiser::getCurrentChunkDepth(), Ogre::MaterialManager::getDefaultSettings(), Ogre::InstanceManager::getInstancingTechnique(), Ogre::TerrainLayerBlendMap::getLayerIndex(), Ogre::PagedWorld::getManager(), Ogre::CompositorInstance::getScheme(), Ogre::Material::getUnsupportedTechniquesExplanation(), Ogre::CompositionPass::InputTex::InputTex(), Ogre::Image::loadRawData(), and Ogre::Root::setRemoveRenderQueueStructuresOnClear().

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

- OgreString.h

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.