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 | Component |
| class | DynamicStructure |
| class | FixedString |
| class | Formatter |
| class | HybridOwnedPointer |
| class | Node |
| class | Noncopyable |
| class | ResourceCache |
| class | ResourceHandle |
| struct | TypedInteger |
| struct | TypedRange |
| struct | DynamicTypedRange |
| struct | OtherTypedRange |
| class | size |
| class | size32 |
| class | size64 |
| class | TypedUUID |
Typedefs | |
| using | ScopedDebugInfo = Debug::ScopedDebugInfo |
| typedef TypedUUID< Implementation::ComponentKeyType > | ComponentKey |
| typedef TypedUUID< Implementation::ComponentTypeKeyType > | ComponentTypeKey |
| typedef std::unique_ptr< Component > | ComponentPointer |
| typedef std::function< ComponentPointer(Node &, const ComponentKey &)> | CreateComponentFunction |
| using | NodeKey = TypedUUID< NodeKeyType > |
| using | NodePointer = std::unique_ptr< Node > |
| typedef std::string | String |
| using | tbString = String |
| using | int8 = std::int8_t |
| Signed integer with a size of 8 bits. Supports values from -128 to 127. | |
| using | uint8 = std::uint8_t |
| Unsigned integer with a size of 8 bits. Supports values from 0 to 255. | |
| using | byte = std::uint8_t |
| Unsigned integer with a size of 8 bits. Supports values from 0 to 255. | |
| using | int16 = std::int16_t |
| Signed integer with a size of 16 bits. Supports values from -32768 to 32767. | |
| using | uint16 = std::uint16_t |
| Unsigned integer with a size of 16 bits. Supports values from 0 to 65535. | |
| using | int32 = std::int32_t |
| Signed integer with a size of 32 bits. Supports values from -2147483648 to 2147483647. | |
| using | uint32 = std::uint32_t |
| Unsigned integer with a size of 32 bits. Supports values from 0 to 4294967295, (2^32 - 1). | |
| using | int64 = std::int64_t |
| Signed integer with a size of 64 bits. Supports values from -(2^63) to (2^63 - 1). | |
| using | uint64 = std::uint64_t |
| Unsigned integer with a size of 64 bits, Supports values from 0 to (2^64 - 1). | |
| using | InputFile = std::istream |
| using | OutputFile = std::ostream |
| using | uuid = TypedUUID< DefaultKeyType > |
Enumerations | |
| enum class | Space { Local , World } |
| enum class | Recursive { No , Yes } |
| enum class | NodeKeyType |
| enum class | DefaultKeyType |
Functions | |
| DynamicStructure | ParseCsv (const String &csvData, const String &debugID="") |
| DynamicStructure | LoadCsvFile (const String &filepath) |
| bool | SaveCsvFile (const String &filepath, const DynamicStructure &saveData) |
| 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) |
| String | ToJsonString (const tbCore::DynamicStructure &data, bool prettyJson) |
| template<size_t Size> | |
| std::ostream & | operator<< (std::ostream &outputStream, const FixedString< Size > &fixed) |
| template<size_t Size> | |
| std::istream & | operator<< (std::istream &inputStream, FixedString< Size > &fixed) |
| template<size_t Size> | |
| bool | operator== (const char *left, const FixedString< Size > &right) |
| template<size_t Size> | |
| bool | operator== (const String &left, const FixedString< Size > &right) |
| template<size_t Size> | |
| bool | operator!= (const char *left, const FixedString< Size > &right) |
| template<size_t Size> | |
| bool | operator!= (const String &left, const FixedString< Size > &right) |
| String | EscapeJsonString (const String &input) |
| DynamicStructure | ParseJson (const String &jsonData) |
| DynamicStructure | LoadJsonFile (const String &filepath) |
| bool | SaveJsonFile (const String &filepath, const DynamicStructure &saveData, bool prettyJson=true) |
| String | GetPathFromFilepath (const String &filepath) |
| String | GetChildFilepath (const String &parentFilename, const String &childFilename) |
| const NodePointer & | GetRootNode (void) |
| NodePointer & | GetMutableRootNode (void) |
| void | SetRootNode (NodePointer &&rootNode) |
| template<typename Type > | |
| std::string | ToStdString (const Type &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) |
| std::string | ToStdString (double value, int precision=-1) |
| template<typename Type > | |
| Type | FromStdString (const std::string &input) |
| template<typename Type > | |
| std::wstring | ToWideString (const Type &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) |
| std::wstring | ToWideString (double value, int precision=-1) |
| template<typename Type > | |
| Type | FromWideString (const std::wstring &input) |
| template<typename Type > | |
| String | ToString (const Type &object) |
| String | ToString (float value, int precision=-1) |
| String | ToString (double value, int precision=-1) |
| template<typename Type > | |
| Type | FromString (const std::string &input) |
| template<typename Type > | |
| Type | FromString (const std::wstring &input) |
| template<typename MapContainerType > | |
| Internals::ValuesOfAccessor< MapContainerType > | ValuesOf (MapContainerType &container) |
| DynamicStructure | ParseYaml (const String &yamlData) |
| DynamicStructure | LoadYamlFile (const String &filepath) |
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::String |
The String 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. |
| Type 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. |
| Type 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. |
| Type 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 |
| Type 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 |
| String TurtleBrains::Core::GetChildFilepath | ( | const String & | parentFilename, |
| const String & | 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. |
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::LoadCsvFile | ( | const String & | filepath | ) |
TODO: TIM: This may become an "Extensions" or such that takes csv to create a DynamicStructure.
Loads all the contents of the file specified by filepath into a string object and passes it into ParseCsv 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::LoadJsonFile | ( | const String & | 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::LoadYamlFile | ( | const String & | 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 ParseYaml 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::ParseCsv | ( | const String & | csvData, |
| const String & | debugID = "" |
||
| ) |
TODO: TIM: This may become an "Extensions" or such that takes csv to create a DynamicStructure.
Parses a string in the CSV format, although it may be a super basic subset of the CSV format. This function is not yet thoroughly tested for more complicated CSV features, like escaped-strings with commas, quotes, CR LF etc.
| DynamicStructure TurtleBrains::Core::ParseJson | ( | const String & | 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.
| DynamicStructure TurtleBrains::Core::ParseYaml | ( | const String & | yamlData | ) |
TODO: TIM: This may become an "Extensions" or such that takes yaml to create a DynamicStructure.
Parses a string in the YAML format, although it may be a super basic subset of the YAML format. This function was written to collect data from the iRacing SDK in TelemetryBuddy and not thoroughly tested for more complicated YAML features/strings.
| 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::SaveCsvFile | ( | const String & | filepath, |
| const DynamicStructure & | saveData | ||
| ) |
TODO: TurtleBrains: Documentation: This needs to teach user how to use.
| bool TurtleBrains::Core::SaveJsonFile | ( | const String & | filepath, |
| const DynamicStructure & | saveData, | ||
| bool | prettyJson = true |
||
| ) |
TODO: TurtleBrains: Documentation: This needs to teach user how to use.
| String TurtleBrains::Core::ToJsonString | ( | const tbCore::DynamicStructure & | data, |
| bool | prettyJson | ||
| ) |
TODO: TurtleBrains: Documentation: This needs to teach user how to use.
|
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 |
| std::string TurtleBrains::Core::ToStdString | ( | const Type & | 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 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. |
| String TurtleBrains::Core::ToString | ( | const Type & | object | ) |
Easily convert to the string type defined by String, 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 String using ToString().
|
inline |
Easily convert to the string type defined by String, 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 String using ToString().
| value | The floating point value to convert into a string. |
| precision | How much precision to display, -1 is the default. |
|
inline |
Easily convert to the string type defined by String, 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 String using ToString().
| value | The floating point value to convert into a string. |
| precision | How much precision to display, -1 is the default. |
|
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, 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 already a std::wstring, simply return a value of that string without needing conversion.
| object | The wide-string to return |
| std::wstring TurtleBrains::Core::ToWideString | ( | const Type & | 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 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. |
| Internals::ValuesOfAccessor<MapContainerType> TurtleBrains::Core::ValuesOf | ( | MapContainerType & | container | ) |
This is an attempt to have a "nicer" range-base loop over maps/unordered_maps etc where we can ignore the Key, so range-based loop over the values in the map.
Given a map: map<Key, Value> myMap; Access like: for (Value& : ValuesOf(myMap)) { ... } Access like: for (const Value& : ValuesOf(myMap)) { ... }