Contains core functionality for each component of the API. More...
Namespaces | |
Debug | |
Contains some functionality for creating a debug log, and in some cases (Windows) popping open a console window. | |
Error | |
Contains defines and functionality for protecting the framework and your project from disaster. | |
Version | |
Contains functionality for retrieving and comparing the version of the TurtleBrains framework. | |
Classes | |
class | DynamicStructure |
class | Formatter |
class | Noncopyable |
class | ResourceCache |
class | ResourceHandle |
Typedefs | |
typedef std::string | tbString |
typedef int8_t | int8 |
Signed integer with a size of 8 bits. Supports values from -128 to 127. | |
typedef uint8_t | uint8 |
Unsigned integer with a size of 8 bits. Supports values from 0 to 255. | |
typedef uint8 | byte |
Unsigned integer with 8 bits (1 byte). Supports 256 values from 0 to 255. | |
typedef int16_t | int16 |
Signed integer with a size of 16 bits. Supports values from -32768 to 32767. | |
typedef uint16_t | uint16 |
Unsigned integer with a size of 16 bits. Supports values from 0 to 65535. | |
typedef int32_t | int32 |
Signed integer with a size of 32 bits. Supports values from -2147483648 to 2147483647. | |
typedef uint32_t | uint32 |
Unsigned integer with a size of 32 bits. Supports values from 0 to 4294967295, (2^32 - 1). | |
typedef int64_t | int64 |
Signed integer with a size of 64 bits. Supports values from -(2^63) to (2^63 - 1). | |
typedef uint64_t | uint64 |
Unsigned integer with a size of 64 bits, Supports values from 0 to (2^64 - 1). | |
Functions | |
template<typename Type > | |
void | SafeDelete (Type *&objectPointer) |
template<typename Type > | |
void | SafeDeleteArray (Type *&arrayPointer) |
template<typename ReturnType , typename InitialType > | |
ReturnType | RangedCast (const InitialType &value) |
template<typename ReturnType , typename InitialType > | |
ReturnType | ClampedCast (const InitialType &value, const ReturnType &minimum, const ReturnType &maximum) |
void | WriteBinary (const tbCore::DynamicStructure &data, std::ostream &output) |
tbCore::DynamicStructure | ReadBinary (std::istream &input) |
tbCore::tbString | ToJsonString (const tbCore::DynamicStructure &data, bool prettyJson) |
tbCore::tbString | EscapeJsonString (const tbCore::tbString &input) |
DynamicStructure | ParseJson (const tbCore::tbString &jsonData) |
DynamicStructure | LoadJsonFile (const tbCore::tbString &filepath) |
bool | SaveJsonFile (const tbCore::tbString &filepath, const DynamicStructure &saveData, bool prettyJson=true) |
tbCore::tbString | GetPathFromFilepath (const tbCore::tbString &filepath) |
tbCore::tbString | GetChildFilepath (const tbCore::tbString &parentFilename, const tbCore::tbString &childFilename) |
template<typename T > | |
std::string | ToStdString (const T &object) |
std::string | ToStdString (const std::string &object) |
std::string | ToStdString (const std::wstring &object) |
std::string | ToStdString (const wchar_t *object) |
std::string | ToStdString (float value, int precision=-1) |
template<typename T > | |
T | FromStdString (const std::string &input) |
template<typename T > | |
T | FromString (const std::string &input) |
template<typename T > | |
std::wstring | ToWideString (const T &object) |
std::wstring | ToWideString (const std::wstring &object) |
std::wstring | ToWideString (const std::string &object) |
std::wstring | ToWideString (const char *object) |
std::wstring | ToWideString (float value, int precision=-1) |
template<typename T > | |
T | FromWideString (const std::wstring &input) |
template<typename T > | |
T | FromString (const std::wstring &input) |
template<typename T > | |
tbString | ToString (const T &object) |
tbString | ToString (float value, int precision=0) |
bool | StringContains (const tbString &input, const tbString &contents) |
bool | StringStartsWith (const tbString &input, const tbString &contents) |
Most contents in the Core namespace will be required for other portions of the TurtleBrains framework. Core contains types like tbString which are used widely through the framework, and small helper classes/objects to create the small and common building blocks to the TurtleBrains framework and handle errors or configurations.
typedef std::string TurtleBrains::Core::tbString |
The tbString is a type definition of either wide-string (std::wstring) when tb_with_wide_string is defined or std::string when tb_with_wide_string is not defined. This effects how TurtleBrains strings are held and passed The tb_with_wide_string can be defined in tb_configuration.h if wide-strings are preferred.
ReturnType TurtleBrains::Core::ClampedCast | ( | const InitialType & | value, |
const ReturnType & | minimum, | ||
const ReturnType & | maximum | ||
) |
First range cast to ensure the value it fits within the range (min/max) of the return type. Then clamp that value to the specified minimum and maximum provded. This will trigger an error condition if the initial value does not fit in the return type; at runtime.
value | The value to test to check if within range of ReturnType, then gets returned as a ReturnType. |
minimum | The lowest value to return from this function. |
maximum | The highest value to return from the function. |
T TurtleBrains::Core::FromStdString | ( | const std::string & | input | ) |
Convert a std::string into some type of an object, specified by type T, using the operator>>(istream) which must exist in for the type specified by T as must a default constructor. For best portability and reducing non-wide to wide string conversions, using the function FromString() should be used instead.
input | The string that will be used to create an object. |
T TurtleBrains::Core::FromString | ( | const std::string & | input | ) |
Convert a std::string into some type of an object, specified by type T, using the operator>>(istream) which must exist in for the type specified by T as must a default constructor.
input | The string that will be used to create an object. |
T TurtleBrains::Core::FromString | ( | const std::wstring & | input | ) |
Convert a std::wstring into some type of an object, specified by type T, using operator>>(wistream) which must exist in for the type specified by T as must a default constructor.
input | The wide-string that will be used to create an object of type T |
T TurtleBrains::Core::FromWideString | ( | const std::wstring & | input | ) |
Convert a std::wstring into some type of an object, specified by type T, using operator>>(wistream) which must exist in for the type specified by T as must a default constructor. For best portability and reducing non-wide to wide string conversions, using the function FromString() should be used instead.
input | The wide-string that will be used to create an object of type T |
tbCore::tbString TurtleBrains::Core::GetChildFilepath | ( | const tbCore::tbString & | parentFilename, |
const tbCore::tbString & | childFilename | ||
) |
TODO: TIM: This belongs in some form of Utilities / FileSystem thing?
Attempts to find the location of a file based on a parent file for containing filepaths within another file. Ex. A level file format containing textures, sounds or other assets. The texture/sound or other asset would be the child file, and the level being the parent file. This will first check if the childFilename is already existing as is, as a file and if it does, returns that path. If it doesn't the parentFilename will be broken down to a directory path (where the level file exists) and the childFilename appended to create a second attempt to see if that file exists, returning the path if it did. If both fail, an empty string is returned.
parentFilename | The path and filename of the parent file that contains the child file, the Level file as described in the example above. |
childFilename | The path to or filename of the child file that was contained in the parent file, the Asset file as described in the example above. |
tbCore::tbString TurtleBrains::Core::GetPathFromFilepath | ( | const tbCore::tbString & | filepath | ) |
TODO: TIM: This belongs in some form of Utilities / FileSystem thing?
Returns the directory path to the given file without the filename, "data/art/castle.png" would become "data/art/" on return.
DynamicStructure TurtleBrains::Core::LoadJsonFile | ( | const tbCore::tbString & | filepath | ) |
TODO: TIM: This may become an "Extensions" or such that takes json to create a DynamicStructure.
Loads all the contents of the file specified by filepath into a string object and passes it into ParseJson returning the resulting DynamicStructure. If the file was not loaded or memory for the string could not be allocated an error condition will be triggered.
DynamicStructure TurtleBrains::Core::ParseJson | ( | const tbCore::tbString & | jsonData | ) |
TODO: TIM: This may become an "Extensions" or such that takes json to create a DynamicStructure.
Parses a string with the "SuperEasyJSON" parser written by Jeff Weinstein and then converted into a DynamicStructure. This is not the most memory efficient way to parse json, but most tables will likely be loaded then destroyed after processing so the memory footprint should be temporary. Will return a DynamicStructure of type Nil if any errors occurred such as invalid json data.
ReturnType TurtleBrains::Core::RangedCast | ( | const InitialType & | value | ) |
Ensures the value fits within the range (min/max) of the return type. This will trigger an error condition if the types are mismatched; at runtime.
value | The value to test to check if within range of ReturnType, then gets returned as a ReturnType. |
void TurtleBrains::Core::SafeDelete | ( | Type *& | objectPointer | ) |
Checks the objectPointer and deletes it setting it to nullptr, this will only work for objects that were dynamically allocated using new.
void TurtleBrains::Core::SafeDeleteArray | ( | Type *& | arrayPointer | ) |
Checks the objectPointer and deletes it setting it to nullptr, this will only work for object arrays that were dynamically allocated using new [].
bool TurtleBrains::Core::SaveJsonFile | ( | const tbCore::tbString & | filepath, |
const DynamicStructure & | saveData, | ||
bool | prettyJson = true |
||
) |
TODO: TurtleBrains: Documentation: This needs to teach user how to use.
|
inline |
Checks a string input for the contents and returns true if the contents were found anywhere in the input string, otherwise false is returned.
|
inline |
Checks a string input for the contents and returns true if the contents were found at the start of the input string, otherwise false is returned - even if contents exist somewhere else in the string.
tbCore::tbString TurtleBrains::Core::ToJsonString | ( | const tbCore::DynamicStructure & | data, |
bool | prettyJson | ||
) |
TODO: TurtleBrains: Documentation: This needs to teach user how to use.
std::string TurtleBrains::Core::ToStdString | ( | const T & | object | ) |
Convert some type of an object into a std::string using the operator<<(ostream) which must exist in for the type specified by T.
object | The object to convert into a string, typically a basic-type, (int, float, bool), but any type with a defined operator<<(ostream) will work. |
|
inline |
This is a specialization of the template function above, if the type specified by T is already a std::string, simply return a value of that string without needing conversion.
object | The string to return |
|
inline |
This is a specialization of the template function ToStdString, if the type specified by T is a wide-string (std::wstring), attempt to convert the characters into a std::string the best way possible to retain as much of the initial string as possible, replacing unknown or unsupported characters with a question mark '?' character.
object | The wide-string to covert into a std::string |
|
inline |
This is a specialization of the template function ToStdString, if the type specified by T is a c-style string of wchar's, attempt to convert the characters into a std::string by first converting it into a wide-string and reusing the ToStdString(const std::wstring&) code.
object | The c-style wide-string to covert into a std::string. |
|
inline |
This is a specialization of the template function ToWideString to provide specific precision values when dealing with floating point numbers, so ToWideString(value, 3) would print out: value to the third decimal point like: 52.123
value | The floating point value that will be converted into a std::string. |
precision | How many points AFTER the decimal point should be displayed, defaults to -1 which means use the defaults of stringstream. |
tbString TurtleBrains::Core::ToString | ( | const T & | object | ) |
Easily convert to the string type defined by tbString, which is either std::string or std::wstring depending on the tb_with_wide_string definition. By using this to convert when passing string parameters into the TurtleBrains framework you can sleep well knowing it will be converted and held safely regardless of the tb_with_wide_string definition and the string type passed. Even objects with both operator<<(ostream) and operator<<(wostream) can be converted into a tbString using ToString().
std::wstring TurtleBrains::Core::ToWideString | ( | const T & | object | ) |
Convert some type of an object into a std::wstring using the operator<<(wostream) which must exist in for the type specified by T.
object | The object to convert into a wide-string, typically a basic-type, (int, float, bool), but any type with a defined operator<<(wostream) will work. |
|
inline |
This is a specialization of the template function ToWideString, if the type specified by T is already a std::wstring, simply return a value of that string without needing conversion.
object | The wide-string to return |
|
inline |
This is a specialization of the template function ToWideString, if the type specified by T is a std::string, attempt to convert the characters into a std::wstring the best way possible by widening each character to retain the same initial string in widened format.
object | The string to covert into a wide string, (std::wstring) |
|
inline |
This is a specialization of the template function ToWideString, if the type specified by T is a c-style string of char's, attempt to convert the characters into a std::wstring by first converting it into a std::string and reusing the ToWideString(const std::string&) code.
object | The c-style string to convert into a std::string. |
|
inline |
This is a specialization of the template function ToWideString to provide specific precision values when dealing with floating point numbers, so ToWideString(value, 3) would print out: value to the third decimal point like: 52.123
value | The floating point value that will be converted into a wide string. |
precision | How many points AFTER the decimal point should be displayed, defaults to -1 which means use the defaults of stringstream. |
void TurtleBrains::Core::WriteBinary | ( | const tbCore::DynamicStructure & | data, |
std::ostream & | output | ||
) |
TODO: TurtleBrains: Documentation: Teach the user how to use.