Blamite Game Engine - blam!  00263.10.17.20.0001.blamite
The core library for the Blamite Game Engine.
Functions
Blam::Converters Namespace Reference

Namespace containing functions to convert between various types of variables. More...

Functions

std::wstring ConvertStringToWstring (std::string string)
 Converts a String to a Wide String. More...
 
std::string WstringToString (std::wstring wide_string)
 Converts a Wide String to a String. More...
 
bool StringToBool (std::string string)
 Converts a string to a boolean. More...
 
bool HexStringToChar (std::string hex, char *character)
 Converts a hexadecimal code to its respective character. More...
 
float StringToFloat (std::string string)
 Converts a string representation of a float to a float. More...
 
int StringToInt (std::string string)
 Converts a string representation of an integer to an int. More...
 
double StringToDouble (std::string string)
 Converts a string representation of a double to a double. More...
 
std::string BytesToString (void *bytes, int bytes_length)
 Converts a series of bytes to a string. More...
 

Detailed Description

Namespace containing functions to convert between various types of variables.

Function Documentation

◆ BytesToString()

std::string Blam::Converters::BytesToString ( void *  bytes,
int  bytes_length 
)

Converts a series of bytes to a string.

Parameters
bytes- Start address of the bytes to read.
bytes_length- The number of bytes to read.
Returns
The string representation of the bytes.

◆ ConvertStringToWstring()

std::wstring Blam::Converters::ConvertStringToWstring ( std::string  string)

Converts a String to a Wide String.

Parameters
string- The string to convert.
Returns
The string as a wstring.

◆ HexStringToChar()

bool Blam::Converters::HexStringToChar ( std::string  hex,
char *  character 
)

Converts a hexadecimal code to its respective character.

This is used to evaluate a hex code representing a byte to its equivalent char.

Parameters
hex- The string containing the hexadecimal representation of a character.
character- Pointer to the char to set to the evaluated character.
Returns
true if the character was converted successfully, false if an error occurred.

◆ StringToBool()

bool Blam::Converters::StringToBool ( std::string  string)

Converts a string to a boolean.

The following will be interpreted as true:

true, t, 1, on, yes, y

The following will be interpreted as false:

false, f, 0, off, no, n

Any other value will return false and add a message to console.

Parameters
string- The string to convert.
Returns
The string evaluated to a bool.

◆ StringToDouble()

double Blam::Converters::StringToDouble ( std::string  string)

Converts a string representation of a double to a double.

Parameters
string- The string containing the double value representation.
Returns
The evaluated double value, or 0 if the value failed to convert.

◆ StringToFloat()

float Blam::Converters::StringToFloat ( std::string  string)

Converts a string representation of a float to a float.

Parameters
string- The string containing the float value representation.
Returns
The evaluated float value, or 0.0f if the value failed to convert.

◆ StringToInt()

int Blam::Converters::StringToInt ( std::string  string)

Converts a string representation of an integer to an int.

Parameters
string- The string containing the float value representation.
Returns
The evaluated float value, or 0.0f if the value failed to convert.

◆ WstringToString()

std::string Blam::Converters::WstringToString ( std::wstring  wide_string)

Converts a Wide String to a String.

Parameters
wide_string- The wide string to convert.
Returns
The wide string as a string.
Note
If the wide string contains multi-byte characters, data loss will occur.