Angel 3.2
A 2D Game Prototyping Engine
Typedefs | Functions
StringUtil.h File Reference
#include "../Infrastructure/Common.h"
#include "../Infrastructure/Vector2.h"
#include <set>

Go to the source code of this file.

Typedefs

typedef std::string String
 
typedef std::vector< String > StringList
 
typedef std::set< String > StringSet
 

Functions

int StringToInt (const String &s)
 
float StringToFloat (const String &s)
 
bool StringToBool (const String &s)
 
Vector2 StringToVector2 (const String &s)
 
String IntToString (int val)
 
String ULLIntToString (unsigned long long val)
 
String FloatToString (float val)
 
String BoolToString (bool val)
 
String Vector2ToString (const Vector2 &val)
 
String ToUpper (const String &s)
 
String ToLower (const String &s)
 
String JoinString (const StringList &list, const String &joinString="")
 
StringList SplitString (const String &splitMe, const String &splitChars, bool bRemoveEmptyEntries=true)
 
StringList SplitString (const String &splitMe)
 
String TrimString (const String &trimMe, const String &trimChars)
 
String TrimString (const String &trimMe)
 

Detailed Description

A set of C-style utility functions for manipulating strings.

Definition in file StringUtil.h.

Function Documentation

int StringToInt ( const String &  s)

Convert a string to an integer.

Parameters
sThe string to convert
Returns
The int representation thereof (0 if the string couldn't be parsed)

Definition at line 65 of file StringUtil.cpp.

float StringToFloat ( const String &  s)

Convert a string to a float.

Parameters
sThe string to convert
Returns
The float representation thereof (0.0f if the string couldn't be parsed)

Definition at line 72 of file StringUtil.cpp.

bool StringToBool ( const String &  s)

Convert a string to a bool. First looks to see if the string is "true" or "false" with any capitalization. If not, then it tries to convert it to an integer and uses that as the result (0 being false; any other value being true).

Parameters
sThe string to convert
Returns
The bool representation thereof

Definition at line 79 of file StringUtil.cpp.

Vector2 StringToVector2 ( const String &  s)

Converts a string of two numbers separated by a whitespace character to a Vector2. Returns a zero-length vector if the string is invalid. (0, 0)

Parameters
sThe string to convert
Returns
The Vector2 representation thereof

Definition at line 89 of file StringUtil.cpp.

String IntToString ( int  val)

Converts an integer to a string.

Parameters
valThe integer to convert
Returns
The string representation of the integer

Definition at line 104 of file StringUtil.cpp.

String ULLIntToString ( unsigned long long  val)

Converts extra long integers to a string.

Parameters
valThe unsigned long long integer to convert.
Returns
The string representation of the number.

Definition at line 114 of file StringUtil.cpp.

String FloatToString ( float  val)

Converts a float to a string.

Parameters
valThe float to convert
Returns
The string representation of the float

Definition at line 109 of file StringUtil.cpp.

String BoolToString ( bool  val)

Converts a bool to a string.

Parameters
valThe bool to convert
Returns
The string representation of the bool (in numeric form)

Definition at line 119 of file StringUtil.cpp.

String Vector2ToString ( const Vector2 val)

Converts a Vector2 to a string.

Parameters
valThe Vector2 to convert
Returns
The string representation of the Vector2 ("X Y")

Definition at line 124 of file StringUtil.cpp.

String ToUpper ( const String &  s)

Converts a string to all uppercase

Parameters
sThe string to convert
Returns
The transformed string

Definition at line 130 of file StringUtil.cpp.

String ToLower ( const String &  s)

Converts a string to all lowercase

Parameters
sThe string to convert
Returns
The transformed string

Definition at line 140 of file StringUtil.cpp.

String JoinString ( const StringList &  list,
const String &  joinString = "" 
)

Joins a list of strings into one, with a specified separator.

Parameters
Thestring list to join
Thestring to put between each entry in the final string.
Returns
The joined string.

Definition at line 185 of file StringUtil.cpp.

StringList SplitString ( const String &  splitMe,
const String &  splitChars,
bool  bRemoveEmptyEntries = true 
)

Splits a long string into a StringList.

Parameters
splitMeThe string to split up
splitCharsThe set of delimiter characters to use for the splitting
bRemoveEmptyEntriesWhether or not empty strings (resulting from multiple delimiters) should be added to the return list
Returns
The list of strings derived from the split

Definition at line 151 of file StringUtil.cpp.

StringList SplitString ( const String &  splitMe)

Splits a long string into a StringList wherever newlines or tabs appear.

Parameters
splitMeThe string to split
Returns
The list of strings derived from the split

Definition at line 180 of file StringUtil.cpp.

String TrimString ( const String &  trimMe,
const String &  trimChars 
)

Remove a series of duplicated characters from a string.

Parameters
trimMeThe string to trim
trimCharsThe characters to remove
Returns
The trimmed string

Definition at line 201 of file StringUtil.cpp.

String TrimString ( const String &  trimMe)

Remove whitespace from the beginning or end of a string

Parameters
trimMeThe string to trim
Returns
The trimmed string

Definition at line 236 of file StringUtil.cpp.