Leviathan  0.8.0.0
Leviathan game engine
Leviathan::VariableBlock Class Reference

Non-template class for working with all types of DataBlocks. More...

#include <DataBlock.h>

+ Inheritance diagram for Leviathan::VariableBlock:

Public Member Functions

 VariableBlock ()
 Default empty constructor, block has no value of any kind. More...
 
template<class DBRType >
 VariableBlock (DataBlock< DBRType > *block)
 
 VariableBlock (const int &var)
 
 VariableBlock (const bool &var, bool isactuallybooltype)
 
 VariableBlock (const std::string &var)
 
 VariableBlock (const std::wstring &var)
 
 VariableBlock (const double &var)
 
 VariableBlock (const float &var)
 
 VariableBlock (const char &var)
 
 VariableBlock (void *var)
 
DLLEXPORT VariableBlock (sf::Packet &packet)
 Constructs from a packet. More...
 
DLLEXPORT void AddDataToPacket (sf::Packet &packet) const
 Stores data to a packet. More...
 
 VariableBlock (const VariableBlock &arg)
 
DLLEXPORT VariableBlock (const std::string &valuetoparse, std::map< std::string, std::shared_ptr< VariableBlock >> *predefined)
 
 VariableBlock (DataBlockAll *block)
 
virtual ~VariableBlock ()
 
DataBlockAllGetBlock ()
 
const DataBlockAllGetBlockConst () const
 
bool IsValid () const
 
VariableBlockoperator= (VariableBlock *arg)
 
template<class DBlockTP >
VariableBlockoperator= (DataBlock< DBlockTP > *arg)
 
VariableBlockoperator= (const VariableBlock &arg)
 
bool operator== (const VariableBlock &other) const
 comparison operator More...
 
bool operator!= (const VariableBlock &other) const
 Opposite of the comparison operator. More...
 
template<class ConvertT >
 operator ConvertT () const
 
template<class ConvertT >
 operator ConvertT * ()
 
template<class ConvertT >
bool IsConversionAllowedNonPtr () const
 
template<class ConvertT >
bool IsConversionAllowedPtr () const
 
template<class ConvertT >
bool ConvertAndAssingToVariable (ConvertT &var) const
 
template<class ConvertT >
ConvertT ConvertAndReturnVariable () const
 

Protected Attributes

DataBlockAllBlockData = nullptr
 

Detailed Description

Non-template class for working with all types of DataBlocks.

If you want a VariableBlock with no value use: VariableBlock(static_cast<DataBlockAll*>(nullptr)) and a cast to void if you want a VoidPtrBlock with no value

Definition at line 425 of file DataBlock.h.

Constructor & Destructor Documentation

◆ VariableBlock() [1/14]

Leviathan::VariableBlock::VariableBlock ( )
inline

Default empty constructor, block has no value of any kind.

Definition at line 429 of file DataBlock.h.

429  : BlockData(NULL){
430 
431  }
DataBlockAll * BlockData
Definition: DataBlock.h:756

◆ VariableBlock() [2/14]

template<class DBRType >
Leviathan::VariableBlock::VariableBlock ( DataBlock< DBRType > *  block)
inline

Definition at line 435 of file DataBlock.h.

435  {
436 
437  BlockData = static_cast<DataBlockAll*>(block);
438  }
DataBlockAll * BlockData
Definition: DataBlock.h:756

◆ VariableBlock() [3/14]

Leviathan::VariableBlock::VariableBlock ( const int &  var)
inline

Definition at line 440 of file DataBlock.h.

440  {
441  BlockData = static_cast<DataBlockAll*>(new IntBlock(var));
442  }
DataBlockAll * BlockData
Definition: DataBlock.h:756
DataBlock< int > IntBlock
Definition: DataBlock.h:382

◆ VariableBlock() [4/14]

Leviathan::VariableBlock::VariableBlock ( const bool &  var,
bool  isactuallybooltype 
)
inline

Definition at line 443 of file DataBlock.h.

443  {
444  BlockData = static_cast<DataBlockAll*>(new BoolBlock(var));
445  }
DataBlockAll * BlockData
Definition: DataBlock.h:756
DataBlock< bool > BoolBlock
Definition: DataBlock.h:384

◆ VariableBlock() [5/14]

Leviathan::VariableBlock::VariableBlock ( const std::string &  var)
inline

Definition at line 446 of file DataBlock.h.

446  {
447  BlockData = static_cast<DataBlockAll*>(new StringBlock(var));
448  }
DataBlockAll * BlockData
Definition: DataBlock.h:756
DataBlock< std::string > StringBlock
Definition: DataBlock.h:386

◆ VariableBlock() [6/14]

Leviathan::VariableBlock::VariableBlock ( const std::wstring &  var)
inline

Definition at line 449 of file DataBlock.h.

449  {
450  BlockData = static_cast<DataBlockAll*>(new WstringBlock(var));
451  }
DataBlock< std::wstring > WstringBlock
Definition: DataBlock.h:385
DataBlockAll * BlockData
Definition: DataBlock.h:756

◆ VariableBlock() [7/14]

Leviathan::VariableBlock::VariableBlock ( const double &  var)
inline

Definition at line 452 of file DataBlock.h.

452  {
453  BlockData = static_cast<DataBlockAll*>(new DoubleBlock(var));
454  }
DataBlock< double > DoubleBlock
Definition: DataBlock.h:388
DataBlockAll * BlockData
Definition: DataBlock.h:756

◆ VariableBlock() [8/14]

Leviathan::VariableBlock::VariableBlock ( const float &  var)
inline

Definition at line 455 of file DataBlock.h.

455  {
456  BlockData = static_cast<DataBlockAll*>(new FloatBlock(var));
457  }
DataBlock< float > FloatBlock
Definition: DataBlock.h:383
DataBlockAll * BlockData
Definition: DataBlock.h:756

◆ VariableBlock() [9/14]

Leviathan::VariableBlock::VariableBlock ( const char &  var)
inline

Definition at line 458 of file DataBlock.h.

458  {
459  BlockData = static_cast<DataBlockAll*>(new CharBlock(var));
460  }
DataBlockAll * BlockData
Definition: DataBlock.h:756
DataBlock< char > CharBlock
Definition: DataBlock.h:387

◆ VariableBlock() [10/14]

Leviathan::VariableBlock::VariableBlock ( void *  var)
inline

Definition at line 461 of file DataBlock.h.

461  {
462  BlockData = static_cast<DataBlockAll*>(new VoidPtrBlock(var));
463  }
DataBlockAll * BlockData
Definition: DataBlock.h:756
DataBlock< void * > VoidPtrBlock
Definition: DataBlock.h:389

◆ VariableBlock() [11/14]

DLLEXPORT Leviathan::VariableBlock::VariableBlock ( sf::Packet &  packet)

Constructs from a packet.

Definition at line 232 of file DataBlock.cpp.

233 {
234 
235  // Get the type //
236  short type;
237  packet >> type;
238 
239  // Load the actual data based on the type //
240  switch(type) {
241  case 0: {
242  // No data //
243  BlockData = NULL;
244  return;
245  }
246  case DATABLOCK_TYPE_INT: {
247  BlockData = new IntBlock(packet);
248  return;
249  }
250  case DATABLOCK_TYPE_FLOAT: {
251  BlockData = new FloatBlock(packet);
252  return;
253  }
254  case DATABLOCK_TYPE_BOOL: {
255  BlockData = new BoolBlock(packet);
256  return;
257  }
258  case DATABLOCK_TYPE_WSTRING: {
259  BlockData = new WstringBlock(packet);
260  return;
261  }
262  case DATABLOCK_TYPE_STRING: {
263  BlockData = new StringBlock(packet);
264  return;
265  }
266  case DATABLOCK_TYPE_CHAR: {
267  BlockData = new CharBlock(packet);
268  return;
269  }
270  case DATABLOCK_TYPE_DOUBLE: {
271  BlockData = new DoubleBlock(packet);
272  return;
273  }
274  }
275 
276  // Invalid packet //
277  throw InvalidArgument("invalid packet format");
278 }
DataBlock< float > FloatBlock
Definition: DataBlock.h:383
DataBlock< std::wstring > WstringBlock
Definition: DataBlock.h:385
DataBlock< double > DoubleBlock
Definition: DataBlock.h:388
#define DATABLOCK_TYPE_INT
Definition: DataBlock.h:22
DataBlockAll * BlockData
Definition: DataBlock.h:756
#define DATABLOCK_TYPE_WSTRING
Definition: DataBlock.h:25
#define DATABLOCK_TYPE_FLOAT
Definition: DataBlock.h:23
DataBlock< bool > BoolBlock
Definition: DataBlock.h:384
#define DATABLOCK_TYPE_STRING
Definition: DataBlock.h:26
#define DATABLOCK_TYPE_DOUBLE
Definition: DataBlock.h:28
DataBlock< int > IntBlock
Definition: DataBlock.h:382
#define DATABLOCK_TYPE_BOOL
Definition: DataBlock.h:24
DataBlock< std::string > StringBlock
Definition: DataBlock.h:386
#define DATABLOCK_TYPE_CHAR
Definition: DataBlock.h:27
DataBlock< char > CharBlock
Definition: DataBlock.h:387

◆ VariableBlock() [12/14]

Leviathan::VariableBlock::VariableBlock ( const VariableBlock arg)
inline

Definition at line 478 of file DataBlock.h.

478  {
479  // copy data //
480  BlockData = arg.BlockData->AllocateNewFromThis();
481  }
DataBlockAll * BlockData
Definition: DataBlock.h:756
virtual DLLEXPORT DataBlockAll * AllocateNewFromThis() const =0

◆ VariableBlock() [13/14]

DLLEXPORT Leviathan::VariableBlock::VariableBlock ( const std::string &  valuetoparse,
std::map< std::string, std::shared_ptr< VariableBlock >> *  predefined 
)

Definition at line 14 of file DataBlock.cpp.

16 {
17  // the text should have all preceding and trailing spaces removed //
18  if(valuetoparse.size() == 0) {
19  // can't be anything //
20 #ifndef ALTERNATIVE_EXCEPTIONS_FATAL
21  throw InvalidArgument("no data passed");
22 #else
23  return;
24 #endif
25  }
26  // try to figure out what type of block is required for this variable //
27 
28  // easy one first, quotes //
29  if(valuetoparse[0] == '"') {
30  // it's a string //
31 
32  // use iterator to get data inside quotes //
33  StringIterator itr(valuetoparse);
34 
35  auto tempdata = itr.GetStringInQuotes<std::string>(QUOTETYPE_DOUBLEQUOTES);
36 
37  // set data //
38  // WstringBlock takes the pointer as it's own here //
39  BlockData = new StringBlock(tempdata ? tempdata.release() : new std::string());
40 
41  return;
42  }
43 
44  // check does it contain non numeric characters //
45  if(!StringOperations::IsStringNumeric<std::string>(valuetoparse)) {
46 
47  // check does it match true/false //
48  bool possiblevalue = false;
49 
50  if(Convert::IsStringBool(valuetoparse, &possiblevalue)) {
51 
52  BlockData = new BoolBlock(possiblevalue);
53 
54  return;
55  }
56 
57  // check does some special value match it //
58  if(predefined != NULL) {
59  // check do them match //
60 
61  auto ivaliterator = predefined->find(valuetoparse);
62 
63  if(ivaliterator != predefined->end()) {
64  // found! //
65 
66  BlockData = ivaliterator->second->GetBlockConst()->AllocateNewFromThis();
67  return;
68  }
69  }
70 
71  // create a string from the whole thing //
72  BlockData = new StringBlock(valuetoparse);
73 
74  return;
75  }
76 
77  // Try to figure out what kind of a number it is //
78  size_t decimalspot = valuetoparse.find_first_of('.');
79  if(decimalspot != std::wstring::npos) {
80  // has decimal separator //
81 
82  // check does it need more decimal digits than a float has //
83 
84  if(valuetoparse.size() - 1 - decimalspot > FLT_DIG) {
85  // create a double //
86  BlockData = new DoubleBlock(Convert::StringTo<double>(valuetoparse));
87 
88  } else {
89 
90  // float should have space to hold all characters //
91  BlockData = new FloatBlock(Convert::StringTo<float>(valuetoparse));
92  }
93 
94  return;
95  }
96 
97  // Should be a plain old int //
98  BlockData = new IntBlock(Convert::StringTo<int>(valuetoparse));
99 }
DataBlock< float > FloatBlock
Definition: DataBlock.h:383
DataBlock< double > DoubleBlock
Definition: DataBlock.h:388
DataBlockAll * BlockData
Definition: DataBlock.h:756
DataBlock< bool > BoolBlock
Definition: DataBlock.h:384
Iterator class for getting parts of a string.
virtual DLLEXPORT DataBlockAll * AllocateNewFromThis() const =0
DataBlock< int > IntBlock
Definition: DataBlock.h:382
DataBlock< std::string > StringBlock
Definition: DataBlock.h:386
static DLLEXPORT bool IsStringBool(const std::string &val, bool *receiver)
Definition: Convert.cpp:37

◆ VariableBlock() [14/14]

Leviathan::VariableBlock::VariableBlock ( DataBlockAll block)
inline

Definition at line 488 of file DataBlock.h.

488  {
489 
490  BlockData = block;
491  }
DataBlockAll * BlockData
Definition: DataBlock.h:756

◆ ~VariableBlock()

virtual Leviathan::VariableBlock::~VariableBlock ( )
inlinevirtual

Definition at line 493 of file DataBlock.h.

493  {
494 
496  }
DataBlockAll * BlockData
Definition: DataBlock.h:756
#define SAFE_DELETE(x)
Definition: Define.h:147

Member Function Documentation

◆ AddDataToPacket()

DLLEXPORT void Leviathan::VariableBlock::AddDataToPacket ( sf::Packet &  packet) const

Stores data to a packet.

Definition at line 195 of file DataBlock.cpp.

196 {
197  // Set the type //
198  if(BlockData != NULL) {
199  packet << BlockData->Type;
200  } else {
201  packet << 0;
202  return;
203  }
204 
205  // Set the data //
208  packet);
209  else if(BlockData->Type == DATABLOCK_TYPE_FLOAT)
211  ->AddDataToPacket(packet);
212  else if(BlockData->Type == DATABLOCK_TYPE_BOOL)
214  packet);
217  ->AddDataToPacket(packet);
220  ->AddDataToPacket(packet);
221  else if(BlockData->Type == DATABLOCK_TYPE_CHAR)
223  packet);
226  ->AddDataToPacket(packet);
227 
228  // type that shouldn't be used is used //
229  throw InvalidType("unallowed datatype in datablock for writing to packet");
230 }
#define DATABLOCK_TYPE_INT
Definition: DataBlock.h:22
DataBlockAll * BlockData
Definition: DataBlock.h:756
#define DATABLOCK_TYPE_WSTRING
Definition: DataBlock.h:25
#define DATABLOCK_TYPE_FLOAT
Definition: DataBlock.h:23
#define DATABLOCK_TYPE_STRING
Definition: DataBlock.h:26
#define DATABLOCK_TYPE_DOUBLE
Definition: DataBlock.h:28
static const DataBlockAll * Conversion(const DataBlockAll *bl)
Definition: DataBlock.h:395
#define DATABLOCK_TYPE_BOOL
Definition: DataBlock.h:24
#define DATABLOCK_TYPE_CHAR
Definition: DataBlock.h:27

◆ ConvertAndAssingToVariable()

template<class ConvertT >
bool Leviathan::VariableBlock::ConvertAndAssingToVariable ( ConvertT &  var) const
inline

Definition at line 728 of file DataBlock.h.

728  {
729  // return if not allowed conversion //
730  if(!IsConversionAllowedNonPtr<ConvertT>()){
731  //Logger::Get()->Warning(L"VariableBlock: conversion not allowed");
732  return false;
733  }
734  // assign directly to the wanted value, should be faster than converting returning and then assigning //
735  var = this->operator ConvertT();
736 
737  // assignment succeeded //
738  return true;
739  }

◆ ConvertAndReturnVariable()

template<class ConvertT >
ConvertT Leviathan::VariableBlock::ConvertAndReturnVariable ( ) const
inline
Todo:
Throw an exception if unallowed

Definition at line 743 of file DataBlock.h.

743  {
744  // return if not allowed conversion //
745  if(!IsConversionAllowedNonPtr<ConvertT>()){
746  //Logger::Get()->Warning(L"VariableBlock: conversion not allowed");
747  return ConvertT(0);
748  }
749 
750  // return conversion result //
751  return this->operator ConvertT();
752  }

◆ GetBlock()

DataBlockAll* Leviathan::VariableBlock::GetBlock ( )
inline

Definition at line 499 of file DataBlock.h.

499  {
500 
501  return BlockData;
502  }
DataBlockAll * BlockData
Definition: DataBlock.h:756

◆ GetBlockConst()

const DataBlockAll* Leviathan::VariableBlock::GetBlockConst ( ) const
inline

Definition at line 504 of file DataBlock.h.

504  {
505 
506  return static_cast<const DataBlockAll*>(BlockData);
507  }
DataBlockAll * BlockData
Definition: DataBlock.h:756

◆ IsConversionAllowedNonPtr()

template<class ConvertT >
bool Leviathan::VariableBlock::IsConversionAllowedNonPtr ( ) const
inline

Definition at line 663 of file DataBlock.h.

663  {
664  // check it //
667  IsConversionAllowedNonPtr<ConvertT>();
668  else if(BlockData->Type == DATABLOCK_TYPE_FLOAT)
670  IsConversionAllowedNonPtr<ConvertT>();
671  else if(BlockData->Type == DATABLOCK_TYPE_BOOL)
673  IsConversionAllowedNonPtr<ConvertT>();
676  IsConversionAllowedNonPtr<ConvertT>();
679  IsConversionAllowedNonPtr<ConvertT>();
680  else if(BlockData->Type == DATABLOCK_TYPE_CHAR)
682  IsConversionAllowedNonPtr<ConvertT>();
685  IsConversionAllowedNonPtr<ConvertT>();
688  IsConversionAllowedNonPtr<ConvertT>();
689 
690  LEVIATHAN_ASSERT(0, "invalid datablock type");
691  return false;
692  }
#define DATABLOCK_TYPE_INT
Definition: DataBlock.h:22
#define DATABLOCK_TYPE_VOIDPTR
Definition: DataBlock.h:29
DataBlockAll * BlockData
Definition: DataBlock.h:756
#define DATABLOCK_TYPE_WSTRING
Definition: DataBlock.h:25
#define DATABLOCK_TYPE_FLOAT
Definition: DataBlock.h:23
#define DATABLOCK_TYPE_STRING
Definition: DataBlock.h:26
#define DATABLOCK_TYPE_DOUBLE
Definition: DataBlock.h:28
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:98
static const DataBlockAll * Conversion(const DataBlockAll *bl)
Definition: DataBlock.h:395
#define DATABLOCK_TYPE_BOOL
Definition: DataBlock.h:24
#define DATABLOCK_TYPE_CHAR
Definition: DataBlock.h:27

◆ IsConversionAllowedPtr()

template<class ConvertT >
bool Leviathan::VariableBlock::IsConversionAllowedPtr ( ) const
inline

Definition at line 695 of file DataBlock.h.

695  {
696  // check it //
699  IsConversionAllowedPtr<ConvertT>();
700  else if(BlockData->Type == DATABLOCK_TYPE_FLOAT)
702  IsConversionAllowedPtr<ConvertT>();
703  else if(BlockData->Type == DATABLOCK_TYPE_BOOL)
705  IsConversionAllowedPtr<ConvertT>();
708  IsConversionAllowedPtr<ConvertT>();
711  IsConversionAllowedPtr<ConvertT>();
712  else if(BlockData->Type == DATABLOCK_TYPE_CHAR)
714  IsConversionAllowedPtr<ConvertT>();
717  IsConversionAllowedPtr<ConvertT>();
720  IsConversionAllowedPtr<ConvertT>();
721 
722  LEVIATHAN_ASSERT(0, "invalid datablock type");
723  return false;
724  }
#define DATABLOCK_TYPE_INT
Definition: DataBlock.h:22
#define DATABLOCK_TYPE_VOIDPTR
Definition: DataBlock.h:29
DataBlockAll * BlockData
Definition: DataBlock.h:756
#define DATABLOCK_TYPE_WSTRING
Definition: DataBlock.h:25
#define DATABLOCK_TYPE_FLOAT
Definition: DataBlock.h:23
#define DATABLOCK_TYPE_STRING
Definition: DataBlock.h:26
#define DATABLOCK_TYPE_DOUBLE
Definition: DataBlock.h:28
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:98
static const DataBlockAll * Conversion(const DataBlockAll *bl)
Definition: DataBlock.h:395
#define DATABLOCK_TYPE_BOOL
Definition: DataBlock.h:24
#define DATABLOCK_TYPE_CHAR
Definition: DataBlock.h:27

◆ IsValid()

bool Leviathan::VariableBlock::IsValid ( ) const
inline

Definition at line 511 of file DataBlock.h.

511  {
512 
513  if (!BlockData)
514  return false;
515 
516  return true;
517  }
DataBlockAll * BlockData
Definition: DataBlock.h:756

◆ operator ConvertT()

template<class ConvertT >
Leviathan::VariableBlock::operator ConvertT ( ) const
inline

Definition at line 610 of file DataBlock.h.

610  {
611  // cast DataBlock to derived type //
614  else if(BlockData->Type == DATABLOCK_TYPE_FLOAT)
616  else if(BlockData->Type == DATABLOCK_TYPE_BOOL)
622  else if(BlockData->Type == DATABLOCK_TYPE_CHAR)
626 
627  // type that shouldn't be used is used //
628  LEVIATHAN_ASSERT(0, "unallowed datatype in datablock");
629  return ConvertT();
630  }
#define DATABLOCK_TYPE_INT
Definition: DataBlock.h:22
DataBlockAll * BlockData
Definition: DataBlock.h:756
#define DATABLOCK_TYPE_WSTRING
Definition: DataBlock.h:25
#define DATABLOCK_TYPE_FLOAT
Definition: DataBlock.h:23
#define DATABLOCK_TYPE_STRING
Definition: DataBlock.h:26
#define DATABLOCK_TYPE_DOUBLE
Definition: DataBlock.h:28
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:98
static const DataBlockAll * Conversion(const DataBlockAll *bl)
Definition: DataBlock.h:395
#define DATABLOCK_TYPE_BOOL
Definition: DataBlock.h:24
#define DATABLOCK_TYPE_CHAR
Definition: DataBlock.h:27

◆ operator ConvertT *()

template<class ConvertT >
Leviathan::VariableBlock::operator ConvertT * ( )
inline

Definition at line 632 of file DataBlock.h.

632  {
633  // check does types match //
635 
638  else if(BlockData->Type == DATABLOCK_TYPE_FLOAT)
640  else if(BlockData->Type == DATABLOCK_TYPE_BOOL)
646  else if(BlockData->Type == DATABLOCK_TYPE_CHAR)
652  }
653  // non matching types //
654  LEVIATHAN_ASSERT(0, "unallowed cast from type to another with return pointer");
655  return NULL;
656  }
static const short TVal
Definition: DataBlock.h:43
#define DATABLOCK_TYPE_INT
Definition: DataBlock.h:22
#define DATABLOCK_TYPE_VOIDPTR
Definition: DataBlock.h:29
DataBlockAll * BlockData
Definition: DataBlock.h:756
#define DATABLOCK_TYPE_WSTRING
Definition: DataBlock.h:25
#define DATABLOCK_TYPE_FLOAT
Definition: DataBlock.h:23
#define DATABLOCK_TYPE_STRING
Definition: DataBlock.h:26
#define DATABLOCK_TYPE_DOUBLE
Definition: DataBlock.h:28
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:98
static const DataBlockAll * Conversion(const DataBlockAll *bl)
Definition: DataBlock.h:395
#define DATABLOCK_TYPE_BOOL
Definition: DataBlock.h:24
#define DATABLOCK_TYPE_CHAR
Definition: DataBlock.h:27

◆ operator!=()

bool Leviathan::VariableBlock::operator!= ( const VariableBlock other) const
inline

Opposite of the comparison operator.

Definition at line 602 of file DataBlock.h.

602  {
603 
604  return !(*this == other);
605  }

◆ operator=() [1/3]

VariableBlock& Leviathan::VariableBlock::operator= ( VariableBlock arg)
inline

Definition at line 521 of file DataBlock.h.

521  {
522  // release existing value (if any) //
523  if(BlockData){
525  }
526 
527  // copy pointer //
528  BlockData = arg->BlockData;
529 
530  // destroy original //
531  arg->BlockData = NULL;
532 
533  // avoid performance issues //
534  return *this;
535  }
DataBlockAll * BlockData
Definition: DataBlock.h:756
#define SAFE_DELETE(x)
Definition: Define.h:147

◆ operator=() [2/3]

template<class DBlockTP >
VariableBlock& Leviathan::VariableBlock::operator= ( DataBlock< DBlockTP > *  arg)
inline

Definition at line 538 of file DataBlock.h.

538  {
539  // release existing value (if any) //
540  if(BlockData){
542  }
543 
544  // copy pointer //
545  BlockData = static_cast<DataBlockAll*>(arg);
546 
547  // avoid performance issues //
548  return *this;
549  }
DataBlockAll * BlockData
Definition: DataBlock.h:756
#define SAFE_DELETE(x)
Definition: Define.h:147

◆ operator=() [3/3]

VariableBlock& Leviathan::VariableBlock::operator= ( const VariableBlock arg)
inline

Definition at line 552 of file DataBlock.h.

552  {
553  // release existing value (if any) //
554  if(BlockData){
556  }
557 
558  // copy data //
559  BlockData = arg.BlockData->AllocateNewFromThis();
560 
561  // avoid performance issues //
562  return *this;
563  }
DataBlockAll * BlockData
Definition: DataBlock.h:756
virtual DLLEXPORT DataBlockAll * AllocateNewFromThis() const =0
#define SAFE_DELETE(x)
Definition: Define.h:147

◆ operator==()

bool Leviathan::VariableBlock::operator== ( const VariableBlock other) const
inline

comparison operator

Definition at line 566 of file DataBlock.h.

566  {
567  // returns false if either block is NULL //
568  if(BlockData == NULL || other.BlockData == NULL)
569  return false;
570  // if different types cannot match //
571  if(BlockData->Type != other.BlockData->Type)
572  return false;
573  // need to check if values match //
577  else if(BlockData->Type == DATABLOCK_TYPE_FLOAT)
580  else if(BlockData->Type == DATABLOCK_TYPE_BOOL)
589  else if(BlockData->Type == DATABLOCK_TYPE_CHAR)
595 
596  // type that shouldn't be used is used //
597  LEVIATHAN_ASSERT(0, "unallowed datatype in datablock");
598  return false;
599  }
#define DATABLOCK_TYPE_INT
Definition: DataBlock.h:22
DataBlockAll * BlockData
Definition: DataBlock.h:756
#define DATABLOCK_TYPE_WSTRING
Definition: DataBlock.h:25
#define DATABLOCK_TYPE_FLOAT
Definition: DataBlock.h:23
#define DATABLOCK_TYPE_STRING
Definition: DataBlock.h:26
#define DATABLOCK_TYPE_DOUBLE
Definition: DataBlock.h:28
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:98
static const DataBlockAll * Conversion(const DataBlockAll *bl)
Definition: DataBlock.h:395
#define DATABLOCK_TYPE_BOOL
Definition: DataBlock.h:24
#define DATABLOCK_TYPE_CHAR
Definition: DataBlock.h:27

Member Data Documentation

◆ BlockData

DataBlockAll* Leviathan::VariableBlock::BlockData = nullptr
protected

Definition at line 756 of file DataBlock.h.


The documentation for this class was generated from the following files: