9 #ifndef _TurtleBrains_DynamicStructure_h_
10 #define _TurtleBrains_DynamicStructure_h_
12 #include "tb_string.h"
96 bool IsNil(
void)
const;
419 StructureContainer::const_iterator
EndStructure(
void)
const;
443 size_t Size(
void)
const;
457 operator float()
const {
return AsFloat(
true); }
492 int ConvertToInteger(
void)
const;
497 float ConvertToFloat(
void)
const;
502 bool ConvertToBoolean(
void)
const;
512 enum DynamicStructureValueType
538 DynamicStructureValueType mValueType;
549 ArrayContainer* mArray;
550 StructureContainer* mStructure;
568 inline bool operator==(
const DynamicStructure& leftSide,
const int& rightSide) {
return (leftSide.
AsInteger() == rightSide) ?
true :
false; }
569 inline bool operator==(
const int& leftSide,
const DynamicStructure& rightSide) {
return (rightSide.AsInteger() == leftSide) ?
true :
false; }
570 inline bool operator!=(
const DynamicStructure& leftSide,
const int& rightSide) {
return (leftSide.AsInteger() != rightSide) ?
true :
false; }
571 inline bool operator!=(
const int& leftSide,
const DynamicStructure& rightSide) {
return (rightSide.AsInteger() != leftSide) ?
true :
false; }
573 inline bool operator==(
const DynamicStructure& leftSide,
const float& rightSide) {
return (fabs(leftSide.AsFloat() - rightSide) <=
DynamicStructure::kFloatElipson) ?
true :
false; }
574 inline bool operator==(
const float& leftSide,
const DynamicStructure& rightSide) {
return (fabs(rightSide.AsFloat() - leftSide) <=
DynamicStructure::kFloatElipson) ?
true :
false; }
575 inline bool operator!=(
const DynamicStructure& leftSide,
const float& rightSide) {
return (fabs(leftSide.AsFloat() - rightSide) >
DynamicStructure::kFloatElipson) ?
true :
false; }
576 inline bool operator!=(
const float& leftSide,
const DynamicStructure& rightSide) {
return (fabs(rightSide.AsFloat() - leftSide) >
DynamicStructure::kFloatElipson) ?
true :
false; }
578 inline bool operator==(
const DynamicStructure& leftSide,
const bool& rightSide) {
return (leftSide.AsBoolean() == rightSide) ?
true :
false; }
579 inline bool operator==(
const bool& leftSide,
const DynamicStructure& rightSide) {
return (rightSide.AsBoolean() == leftSide) ?
true :
false; }
580 inline bool operator!=(
const DynamicStructure& leftSide,
const bool& rightSide) {
return (leftSide.AsBoolean() != rightSide) ?
true :
false; }
581 inline bool operator!=(
const bool& leftSide,
const DynamicStructure& rightSide) {
return (rightSide.AsBoolean() != leftSide) ?
true :
false; }
583 inline bool operator==(
const DynamicStructure& leftSide,
const tbCore::tbString& rightSide) {
return (leftSide.AsString() == rightSide) ?
true :
false; }
584 inline bool operator==(
const tbCore::tbString& leftSide,
const DynamicStructure& rightSide) {
return (rightSide.AsString() == leftSide) ?
true :
false; }
585 inline bool operator!=(
const DynamicStructure& leftSide,
const tbCore::tbString& rightSide) {
return (leftSide.AsString() != rightSide) ?
true :
false; }
586 inline bool operator!=(
const tbCore::tbString& leftSide,
const DynamicStructure& rightSide) {
return (rightSide.AsString() != leftSide) ?
true :
false; }
const DynamicStructure & GetMember(const tbCore::tbString &memberName) const
bool IsString(void) const
DynamicStructure & PushValue(const DynamicStructure &value)
static const bool kImplicitConversions
Definition: tb_dynamic_structure.h:560
static const DynamicStructure kNullValue
Definition: tb_dynamic_structure.h:554
tbCore::tbString AsString(bool implicitConversion=kImplicitConversions) const
tbCore::tbString AsStringWithDefault(const tbCore::tbString &defaultValue) const
StructureContainer::const_iterator EndStructure(void) const
static const float kFloatElipson
Definition: tb_dynamic_structure.h:562
Contains all functions, classes and helpers related to game/application development written by Tim "B...
Definition: tb_application_dialog.h:21
float AsFloat(bool implicitConversion=kImplicitConversions) const
static const tbCore::tbString kTrueAsString
Definition: tb_dynamic_structure.h:556
float AsFloatWithDefault(const float defaultValue) const
const DynamicStructure & operator[](const size_t &arrayIndex) const
static const unsigned int kInvalidSize
Definition: tb_dynamic_structure.h:558
const DynamicStructure & GetValue(const size_t &arrayIndex) const
int AsInteger(bool implicitConversion=kImplicitConversions) const
static const bool kTypeSafeArrays
Definition: tb_dynamic_structure.h:559
static const tbCore::tbString kNullAsString
Definition: tb_dynamic_structure.h:555
bool IsBoolean(void) const
Definition: tb_dynamic_structure.h:28
bool IsInteger(void) const
std::map< tbCore::tbString, DynamicStructure > StructureContainer
Definition: tb_dynamic_structure.h:39
static const tbCore::tbString kFalseAsString
Definition: tb_dynamic_structure.h:557
bool operator==(const DynamicStructure &rightSide) const
bool AsBoolean(bool implicitConversion=kImplicitConversions) const
std::vector< DynamicStructure > ArrayContainer
Definition: tb_dynamic_structure.h:34
StructureContainer::const_iterator BeginStructure(void) const
DynamicStructure & AddMember(const tbCore::tbString &memberName, const DynamicStructure &memberValue)
void SetValue(const int &integerValue, bool implicitTypeChange=kImplicitTypeChange)
Contains core functionality for each component of the API.
Definition: tb_dynamic_structure.h:21
std::string tbString
Definition: tb_string.h:293
bool IsStructure(void) const
DynamicStructure & operator=(const DynamicStructure &other)
bool AsBooleanWithDefault(const bool defaultValue) const
int AsIntegerWithDefault(const int defaultValue) const
static const bool kImplicitTypeChange
Definition: tb_dynamic_structure.h:561
DynamicStructure & SetMember(const tbCore::tbString &memberName, const DynamicStructure &memberValue)