5c88803942
Error handling: Array now has sufficiently advanced error handling to remove most, if not all, disable_checks. Extention: With the metaprogramming techniques, new types can be added easily. Speed: With the new changes I've made to Judy, the Array module has far exceeded the speed of any traditional datatype
64 lines
1.1 KiB
C++
64 lines
1.1 KiB
C++
#ifndef _JUDYCAP_INCLUDED
|
|
#define _JUDYCAP_INCLUDED
|
|
|
|
#include "JudyIncludes.h"
|
|
|
|
enum
|
|
{
|
|
capsule_type_none,
|
|
capsule_type_bool,
|
|
capsule_type_int,
|
|
capsule_type_flo,
|
|
capsule_type_vec,
|
|
capsule_type_str
|
|
};
|
|
|
|
extern const char* capsule_types[];
|
|
|
|
class Capsule
|
|
{
|
|
private:
|
|
Pvoid_t data;
|
|
char type;
|
|
|
|
protected:
|
|
void Clear( void );
|
|
void ThrowTypeError(cell get_type);
|
|
|
|
public:
|
|
Capsule() { data = NULL; type = capsule_type_none;}
|
|
~Capsule() { Clear(); }
|
|
|
|
Capsule(bool set) { SetBool(set); }
|
|
Capsule(cell set) { SetInt(set); }
|
|
Capsule(REAL set) { SetFlo(set); }
|
|
Capsule(JudyVec* set) { SetVec(set); }
|
|
Capsule(char* set) { SetStr(set); }
|
|
|
|
bool GetBool( void );
|
|
void SetBool(bool set);
|
|
|
|
cell GetInt( void );
|
|
void SetInt(cell set);
|
|
|
|
REAL GetFlo( void );
|
|
void SetFlo(REAL set);
|
|
|
|
const JudyVec* GetVec( void );
|
|
void SetVec(JudyVec* set);
|
|
|
|
const char* GetStr( void );
|
|
void SetStr(char* set);
|
|
|
|
void GetAsStr(char* value);
|
|
|
|
void Load(FILE* db);
|
|
void Save(FILE* db);
|
|
|
|
bool CheckEmpty(bool clear);
|
|
|
|
Pvoid_t GetData( void ) { return data; }
|
|
char GetType( void ) { return type; }
|
|
};
|
|
|
|
#endif |