MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
Mezzanine::StringTools Namespace Reference

This is a utility to help perform all kinds of string related tasks. More...

Functions

ColourValue ConvertHexToColourValue (const String &ToConvert)
 Converts a Hex code in a string into a ColourValue. More...
 
bool ConvertToBool (const String &ToConvert, const bool Default=false)
 Converts a string into a bool. More...
 
ColourValue ConvertToColourValue (const String &ToConvert)
 Convert four numbers in a string into a ColourValue. More...
 
String ConvertToHexString (const ColourValue &ToConvert)
 Converts a ColourValue into a string as a Hex code. More...
 
Int16 ConvertToInt16 (const String &ToConvert)
 Converts a string into an Int16. More...
 
Int32 ConvertToInt32 (const String &ToConvert)
 Converts an string into an Int32. More...
 
Int8 ConvertToInt8 (const String &ToConvert)
 Converts a string into an Int8. More...
 
Integer ConvertToInteger (const String &ToConvert)
 Converts a string into an Integer. More...
 
Quaternion ConvertToQuaternion (const String &ToConvert)
 Convert four numbers in a string into a Quaternion. More...
 
Real ConvertToReal (const String &ToConvert)
 Converts a string into a Real. More...
 
String ConvertToString (const Vector2 &ToConvert)
 Converts a Vector2 into a string. More...
 
String ConvertToString (const Vector3 &ToConvert)
 Converts a Vector3 into a string. More...
 
String ConvertToString (const Quaternion &ToConvert)
 Converts a Quaternion into a string. More...
 
String ConvertToString (const ColourValue &ToConvert)
 Converts a ColourValue into a string. More...
 
template<typename T >
String ConvertToString (const T &ToConvert)
 Converts any into a string. More...
 
String ConvertToString (const Input::InputCode &Code, bool ShiftPressed)
 Converts a Input::InputCode into a string. More...
 
UInt16 ConvertToUInt16 (const String &ToConvert)
 Converts a string into a UInt16. More...
 
UInt32 ConvertToUInt32 (const String &ToConvert)
 Converts a string into a UInt32. More...
 
UInt8 ConvertToUInt8 (const String &ToConvert)
 Converts a string into a UInt8. More...
 
Vector2 ConvertToVector2 (const String &ToConvert)
 Convert two numbers in a string into a Vector2. More...
 
Vector3 ConvertToVector3 (const String &ToConvert)
 Convert three numbers in a string into a Vector3. More...
 
bool EndsWith (const String &Str, const String &Pattern, const bool CaseSensitive)
 Checks a string to see if it ends with a specific pattern. More...
 
void RemoveDuplicateWhitespaces (String &Source)
 Replaces all instances of multiple consecutive whitespaces with only a single whitespace. More...
 
CountedPtr< StringVectorSplit (const String &Source, const String &Delims=" \t\n", const Whole &MaxSplits=0)
 Splits a string into multiple substrings based on the specified delimiters. More...
 
bool StartsWith (const String &Str, const String &Pattern, const bool CaseSensitive)
 Checks a string to see if it starts with a specific pattern. More...
 
void ToLowerCase (String &Source)
 Converts all upper case characters in a string to their respective lower case. More...
 
void ToUpperCase (String &Source)
 Converts all lower case characters in a string to their respective upper case. More...
 
void Trim (String &Source, bool Left=true, bool Right=true)
 Trims all whitespaces and tabs from a one or both sides of a string. More...
 

Variables

const String Blank = ""
 

Detailed Description

This is a utility to help perform all kinds of string related tasks.

Function Documentation

ColourValue Mezzanine::StringTools::ConvertHexToColourValue ( const String &  ToConvert)

Converts a Hex code in a string into a ColourValue.

Parameters
ToConvertThe string to be converted.
Returns
Returns a ColourValue populated with the values from the string passed in.

Definition at line 276 of file stringtool.cpp.

bool Mezzanine::StringTools::ConvertToBool ( const String &  ToConvert,
const bool  Default = false 
)

Converts a string into a bool.

Parameters
ToConvertThe string to be converted to a bool.
Returns
Returns a bool with the converted value.

Definition at line 306 of file stringtool.cpp.

ColourValue Mezzanine::StringTools::ConvertToColourValue ( const String &  ToConvert)

Convert four numbers in a string into a ColourValue.

Parameters
ToConvertThe string to be converted.
Remarks
The string is expected to have a certain format. The format should be "R G B A". If there are not 4 numbers an exception will be thrown.
Returns
Returns a ColourValue populated with the values from the string passed in.

Definition at line 258 of file stringtool.cpp.

String Mezzanine::StringTools::ConvertToHexString ( const ColourValue &  ToConvert)

Converts a ColourValue into a string as a Hex code.

Parameters
ToConvertThe ColourValue to be converted.
Returns
Returns a string containing the values from the string passed in.

Definition at line 293 of file stringtool.cpp.

Int16 Mezzanine::StringTools::ConvertToInt16 ( const String &  ToConvert)

Converts a string into an Int16.

Parameters
ToConvertThe string to be converted to an Int16.
Returns
Returns an Int16 with the converted value.

Definition at line 351 of file stringtool.cpp.

Int32 Mezzanine::StringTools::ConvertToInt32 ( const String &  ToConvert)

Converts an string into an Int32.

Parameters
ToConvertThe string to be converted to an Int32.
Returns
Returns an Int32 with the converted value.

Definition at line 367 of file stringtool.cpp.

Int8 Mezzanine::StringTools::ConvertToInt8 ( const String &  ToConvert)

Converts a string into an Int8.

Parameters
ToConvertThe string to be converted to an Int8.
Returns
Returns an Int8 with the converted value.

Definition at line 335 of file stringtool.cpp.

Integer Mezzanine::StringTools::ConvertToInteger ( const String &  ToConvert)

Converts a string into an Integer.

Parameters
ToConvertThe string to be converted to an Integer.
Returns
Returns an Integer with the converted value.

Definition at line 327 of file stringtool.cpp.

Quaternion Mezzanine::StringTools::ConvertToQuaternion ( const String &  ToConvert)

Convert four numbers in a string into a Quaternion.

Parameters
ToConvertThe string to be converted.
Remarks
The string is expected to have a certain format. The format should be "X Y Z W". If there are not 4 numbers an exception will be thrown.
Returns
Returns a Quaternion populated with the values from the string passed in.

Definition at line 240 of file stringtool.cpp.

Real Mezzanine::StringTools::ConvertToReal ( const String &  ToConvert)

Converts a string into a Real.

Parameters
ToConvertThe string to be converted to a Real.
Returns
Returns a Real with the converted value.

Definition at line 319 of file stringtool.cpp.

String Mezzanine::StringTools::ConvertToString ( const Vector2 &  ToConvert)

Converts a Vector2 into a string.

Parameters
ToConvertThe Vector2 to be converted.
Returns
Returns a string containing the values from the Vector2 in "X Y" format.

Definition at line 215 of file stringtool.cpp.

String Mezzanine::StringTools::ConvertToString ( const Vector3 &  ToConvert)

Converts a Vector3 into a string.

Parameters
ToConvertThe Vector3 to be converted.
Returns
Returns a string containing the values from the Vector3 in "X Y Z" format.

Definition at line 233 of file stringtool.cpp.

String Mezzanine::StringTools::ConvertToString ( const Quaternion &  ToConvert)

Converts a Quaternion into a string.

Parameters
ToConvertThe Quaternion to be converted.
Returns
Returns a string containing the values from the Quaternion in "X Y Z W" format.

Definition at line 251 of file stringtool.cpp.

String Mezzanine::StringTools::ConvertToString ( const ColourValue &  ToConvert)

Converts a ColourValue into a string.

Parameters
ToConvertThe ColourValue to be converted.
Returns
Returns a string containing the values from the ColourValue in "R G B A" format.

Definition at line 269 of file stringtool.cpp.

template<typename T >
String Mezzanine::StringTools::ConvertToString ( const T &  ToConvert)

Converts any into a string.

Parameters
ToConvertStream class instance to be converted.
Returns
Returns a string containing the lexicagraphically converted data.

Definition at line 194 of file stringtool.h.

String Mezzanine::StringTools::ConvertToString ( const Input::InputCode &  Code,
bool  ShiftPressed 
)

Converts a Input::InputCode into a string.

Parameters
CodeThe input code to be converted.
ShiftPressedWhether or not the shift modifier key has been pressed.
Returns
Returns a string(usually with only one character) containing the converted input code.
Todo:
Get this ( StringTools::ConvertToString ) to support non us keyboards

Definition at line 383 of file stringtool.cpp.

UInt16 Mezzanine::StringTools::ConvertToUInt16 ( const String &  ToConvert)

Converts a string into a UInt16.

Parameters
ToConvertThe string to be converted to a UInt16.
Returns
Returns a UInt16 with the converted value.

Definition at line 359 of file stringtool.cpp.

UInt32 Mezzanine::StringTools::ConvertToUInt32 ( const String &  ToConvert)

Converts a string into a UInt32.

Parameters
ToConvertThe string to be converted to a UInt32.
Returns
Returns a UInt32 with the converted value.

Definition at line 375 of file stringtool.cpp.

UInt8 Mezzanine::StringTools::ConvertToUInt8 ( const String &  ToConvert)

Converts a string into a UInt8.

Parameters
ToConvertThe string to be converted to a UInt8.
Returns
Returns a UInt8 with the converted value.

Definition at line 343 of file stringtool.cpp.

Vector2 Mezzanine::StringTools::ConvertToVector2 ( const String &  ToConvert)

Convert two numbers in a string into a Vector2.

Parameters
ToConvertThe string to be converted.
Remarks
The string is expected to have a certain format. The format should be "X Y". If there are not 2 numbers an exception will be thrown.
Returns
Returns a Vector2 populated with the values from the string passed in.

Definition at line 204 of file stringtool.cpp.

Vector3 Mezzanine::StringTools::ConvertToVector3 ( const String &  ToConvert)

Convert three numbers in a string into a Vector3.

Parameters
ToConvertThe string to be converted.
Remarks
The string is expected to have a certain format. The format should be "X Y Z". If there are not 3 numbers an exception will be thrown.
Returns
Returns a Vector3 populated with the values from the string passed in.

Definition at line 222 of file stringtool.cpp.

bool Mezzanine::StringTools::EndsWith ( const String &  Str,
const String &  Pattern,
const bool  CaseSensitive 
)

Checks a string to see if it ends with a specific pattern.

Parameters
StrThe string to check.
PatternThe sequence to check for at the end of the string.
CaseSensitiveIf false this function will check lower-case copies for the pattern, otherwise the strings will be checked as is.
Returns
Returns true if the string ends with the provided pattern, false otherwise.

Definition at line 169 of file stringtool.cpp.

void Mezzanine::StringTools::RemoveDuplicateWhitespaces ( String &  Source)

Replaces all instances of multiple consecutive whitespaces with only a single whitespace.

Parameters
SourceThe string to be altered.

Definition at line 190 of file stringtool.cpp.

CountedPtr< StringVector > Mezzanine::StringTools::Split ( const String &  Source,
const String &  Delims = " \t\n",
const Whole &  MaxSplits = 0 
)

Splits a string into multiple substrings based on the specified delimiters.

Parameters
SourceThe string to be split.
DelimsThe characters to look for and use as split points in the source string.
MaxSplitsThe maximum number of splits to perform on this string. Value of zero means unlimited splits.
Returns
Returns a vector containing all the substrings generated from the source string.

Definition at line 105 of file stringtool.cpp.

bool Mezzanine::StringTools::StartsWith ( const String &  Str,
const String &  Pattern,
const bool  CaseSensitive 
)

Checks a string to see if it starts with a specific pattern.

Parameters
StrThe string to check.
PatternThe sequence to check for at the start of the string.
CaseSensitiveIf false this function will check lower-case copies for the pattern, otherwise the strings will be checked as is.
Returns
Returns true if the string starts with the provided pattern, false otherwise.

Definition at line 148 of file stringtool.cpp.

void Mezzanine::StringTools::ToLowerCase ( String &  Source)

Converts all upper case characters in a string to their respective lower case.

Parameters
SourceThe string to be converted.

Definition at line 143 of file stringtool.cpp.

void Mezzanine::StringTools::ToUpperCase ( String &  Source)

Converts all lower case characters in a string to their respective upper case.

Parameters
SourceThe string to be converted.

Definition at line 138 of file stringtool.cpp.

void Mezzanine::StringTools::Trim ( String &  Source,
bool  Left = true,
bool  Right = true 
)

Trims all whitespaces and tabs from a one or both sides of a string.

Parameters
SourceThe original string to be trimmed.
LeftWhether or not to trim the left side of the string.
RightWhether or not to trim the right side of the string.

Definition at line 96 of file stringtool.cpp.