MezzanineEngine March 18, 2012

Mezzanine::StringTool Class Reference

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

#include <stringtool.h>

List of all members.

Public Member Functions

 StringTool ()
 Class constructor.
 ~StringTool ()
 Class destructor.

Static Public Member Functions

static bool ConvertToBool (const String &ToConvert, const bool Default=false)
 Converts a string into a bool.
static ColourValue ConvertToColourValue (const String &ToConvert)
 Convert four numbers in a string into a ColourValue.
static Int16 ConvertToInt16 (const String &ToConvert)
 Converts a string into an Int16.
static Int32 ConvertToInt32 (const String &ToConvert)
 Converts an string into an Int32.
static Int8 ConvertToInt8 (const String &ToConvert)
 Converts a string into an Int8.
static Quaternion ConvertToQuaternion (const String &ToConvert)
 Convert four numbers in a string into a Quaternion.
static Real ConvertToReal (const String &ToConvert)
 Converts a string into a Real.
static String ConvertToString (const UInt32 &ToConvert)
 Converts a UInt32 into a string.
static String ConvertToString (const Int32 &ToConvert)
 Converts an Int32 into a string.
static String ConvertToString (const MetaCode::InputCode &Code, bool ShiftPressed)
 Converts a MetaCode::InputCode into a string.
static String ConvertToString (const Int16 &ToConvert)
 Converts an Int16 into a string.
static String ConvertToString (const Vector3 &ToConvert)
 Converts a Vector3 into a string.
static String ConvertToString (const Quaternion &ToConvert)
 Converts a Quaternion into a string.
static String ConvertToString (const Real &ToConvert)
 Converts an Int8 into a string.
static String ConvertToString (const Int8 &ToConvert)
 Converts an Int8 into a string.
static String ConvertToString (const UInt8 &ToConvert)
 Converts a UInt8 into a string.
static String ConvertToString (const Vector2 &ToConvert)
 Converts a Vector2 into a string.
static String ConvertToString (const UInt16 &ToConvert)
 Converts a UInt16 into a string.
static String ConvertToString (const ColourValue &ToConvert)
 Converts a ColourValue into a string.
static UInt16 ConvertToUInt16 (const String &ToConvert)
 Converts a string into a UInt16.
static UInt32 ConvertToUInt32 (const String &ToConvert)
 Converts a string into a UInt32.
static UInt8 ConvertToUInt8 (const String &ToConvert)
 Converts a string into a UInt8.
static Vector2 ConvertToVector2 (const String &ToConvert)
 Convert two numbers in a string into a Vector2.
static Vector3 ConvertToVector3 (const String &ToConvert)
 Convert three numbers in a string into a Vector3.
static bool EndsWith (const String &Str, const String &Pattern, const bool CaseSensitive)
 Checks a string to see if it ends with a specific pattern.
static void RemoveDuplicateWhitespaces (String &Source)
 Replaces all instances of multiple consecutive whitespaces with only a single whitespace.
static std::vector< StringSplit (const String &Source, const String &Delims=" \t\n", const Whole &MaxSplits=0)
 Splits a string into multiple substrings based on the specified delimiters.
static bool StartsWith (const String &Str, const String &Pattern, const bool CaseSensitive)
 Checks a string to see if it starts with a specific pattern.
static String StringCat (const String &Front, const String &Middle1, const String &Middle2, const String &Middle3, const String &Back)
 Concatenates 5 Strings.
static String StringCat (const String &Front, const String &Middle, const String &Back)
 Concatenates 3 Strings.
static String StringCat (const String &Front, const String &Middle1, const String &Middle2, const String &Back)
 Concatenates 4 Strings.
static String StringCat (const String &Front, const String &Back)
 Concatenates 2 Strings.
static String StringCat (const String &Front, const String &Middle1, const String &Middle2, const String &Middle3, const String &Middle4, const String &Back)
 Concatenates 6 Strings.
static void ToLowerCase (String &Source)
 Converts all upper case characters in a string to their respective lower case.
static void ToUpperCase (String &Source)
 Converts all lower case characters in a string to their respective upper case.
static void Trim (String &Source, bool Left=true, bool Right=true)
 Trims all whitespaces and tabs from a one or both sides of a string.

Detailed Description

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

Definition at line 57 of file stringtool.h.


Member Function Documentation

bool Mezzanine::StringTool::ConvertToBool ( const String ToConvert,
const bool  Default = false 
) [static]

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 254 of file stringtool.cpp.

ColourValue Mezzanine::StringTool::ConvertToColourValue ( const String ToConvert) [static]

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 231 of file stringtool.cpp.

Int16 Mezzanine::StringTool::ConvertToInt16 ( const String ToConvert) [static]

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 291 of file stringtool.cpp.

Int32 Mezzanine::StringTool::ConvertToInt32 ( const String ToConvert) [static]

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 307 of file stringtool.cpp.

Int8 Mezzanine::StringTool::ConvertToInt8 ( const String ToConvert) [static]

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 275 of file stringtool.cpp.

Quaternion Mezzanine::StringTool::ConvertToQuaternion ( const String ToConvert) [static]

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 211 of file stringtool.cpp.

Real Mezzanine::StringTool::ConvertToReal ( const String ToConvert) [static]

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 267 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const UInt32 ToConvert) [static]

Converts a UInt32 into a string.

Parameters:
ToConvertThe UInt32 to be converted.
Returns:
Returns a string containing the converted input.

Definition at line 368 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const Int32 ToConvert) [static]

Converts an Int32 into a string.

Parameters:
ToConvertThe Int32 to be converted.
Returns:
Returns a string containing the converted input.

Definition at line 361 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const MetaCode::InputCode Code,
bool  ShiftPressed 
) [static]

Converts a MetaCode::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.

Definition at line 375 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const Int16 ToConvert) [static]

Converts an Int16 into a string.

Parameters:
ToConvertThe Int16 to be converted.
Returns:
Returns a string containing the converted input.

Definition at line 347 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const Vector3 ToConvert) [static]

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 204 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const Quaternion ToConvert) [static]

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 224 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const Real ToConvert) [static]

Converts an Int8 into a string.

Parameters:
ToConvertThe Int8 to be converted.
Returns:
Returns a string containing the converted input.

Definition at line 326 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const Int8 ToConvert) [static]

Converts an Int8 into a string.

Parameters:
ToConvertThe Int8 to be converted.
Returns:
Returns a string containing the converted input.

Definition at line 333 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const UInt8 ToConvert) [static]

Converts a UInt8 into a string.

Parameters:
ToConvertThe UInt8 to be converted.
Returns:
Returns a string containing the converted input.

Definition at line 340 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const Vector2 ToConvert) [static]

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 184 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const UInt16 ToConvert) [static]

Converts a UInt16 into a string.

Parameters:
ToConvertThe UInt16 to be converted.
Returns:
Returns a string containing the converted input.

Definition at line 354 of file stringtool.cpp.

String Mezzanine::StringTool::ConvertToString ( const ColourValue ToConvert) [static]

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 244 of file stringtool.cpp.

UInt16 Mezzanine::StringTool::ConvertToUInt16 ( const String ToConvert) [static]

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 299 of file stringtool.cpp.

UInt32 Mezzanine::StringTool::ConvertToUInt32 ( const String ToConvert) [static]

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 315 of file stringtool.cpp.

UInt8 Mezzanine::StringTool::ConvertToUInt8 ( const String ToConvert) [static]

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 283 of file stringtool.cpp.

Vector2 Mezzanine::StringTool::ConvertToVector2 ( const String ToConvert) [static]

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 171 of file stringtool.cpp.

Vector3 Mezzanine::StringTool::ConvertToVector3 ( const String ToConvert) [static]

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 191 of file stringtool.cpp.

bool Mezzanine::StringTool::EndsWith ( const String Str,
const String Pattern,
const bool  CaseSensitive 
) [static]

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 136 of file stringtool.cpp.

void Mezzanine::StringTool::RemoveDuplicateWhitespaces ( String Source) [static]

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

Parameters:
SourceThe string to be altered.

Definition at line 157 of file stringtool.cpp.

std::vector< String > Mezzanine::StringTool::Split ( const String Source,
const String Delims = " \t\n",
const Whole MaxSplits = 0 
) [static]

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 72 of file stringtool.cpp.

bool Mezzanine::StringTool::StartsWith ( const String Str,
const String Pattern,
const bool  CaseSensitive 
) [static]

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 115 of file stringtool.cpp.

String Mezzanine::StringTool::StringCat ( const String Front,
const String Middle1,
const String Middle2,
const String Middle3,
const String Back 
) [static]

Concatenates 5 Strings.

Parameters:
FrontThe first String
Middle1The second string
Middle2The third string
Middle3The fourth string
BackThe last String
Returns:
A string containing the other Strings passed attached end to end

Definition at line 746 of file stringtool.cpp.

String Mezzanine::StringTool::StringCat ( const String Front,
const String Middle,
const String Back 
) [static]

Concatenates 3 Strings.

Parameters:
FrontThe first String
MiddleA String in the middle
BackThe last String
Returns:
A string containing the other Strings passed attached end to end

Definition at line 732 of file stringtool.cpp.

String Mezzanine::StringTool::StringCat ( const String Front,
const String Middle1,
const String Middle2,
const String Back 
) [static]

Concatenates 4 Strings.

Parameters:
FrontThe first String
Middle1The second string
Middle2The third string
BackThe last String
Returns:
A string containing the other Strings passed attached end to end

Definition at line 739 of file stringtool.cpp.

String Mezzanine::StringTool::StringCat ( const String Front,
const String Back 
) [static]

Concatenates 2 Strings.

Parameters:
FrontThe first String
BackThe last String
Returns:
A string containing the other Strings passed attached end to end

Definition at line 725 of file stringtool.cpp.

String Mezzanine::StringTool::StringCat ( const String Front,
const String Middle1,
const String Middle2,
const String Middle3,
const String Middle4,
const String Back 
) [static]

Concatenates 6 Strings.

Parameters:
FrontThe first String
Middle1The second string
Middle2The third string
Middle3The fourth string
Middle4The fifth string
BackThe last String
Returns:
A string containing the other Strings passed attached end to end

Definition at line 753 of file stringtool.cpp.

void Mezzanine::StringTool::ToLowerCase ( String Source) [static]

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

Parameters:
SourceThe string to be converted.

Definition at line 110 of file stringtool.cpp.

void Mezzanine::StringTool::ToUpperCase ( String Source) [static]

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

Parameters:
SourceThe string to be converted.

Definition at line 105 of file stringtool.cpp.

void Mezzanine::StringTool::Trim ( String Source,
bool  Left = true,
bool  Right = true 
) [static]

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 63 of file stringtool.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines