EHS
Loading...
Searching...
No Matches
DbVarTmpl.h
Go to the documentation of this file.
1#pragma once
2
3#include "ehs/EHS.h"
4#include "ehs/Serializer.h"
5#include "ehs/Str.h"
6
7namespace ehs
8{
9 class DbVar;
10
11 class EHS_LIB_IO DbVarTmpl
12 {
13 private:
14 friend class DbTable;
15
16 UInt_64 hashId;
17 Str_8 id;
18 Byte* def;
19 UInt_64 size;
20
21 public:
22 ~DbVarTmpl();
23
24 DbVarTmpl();
25
26 template<typename T>
27 DbVarTmpl(Str_8 id, const T* const def, UInt_64 size)
28 : hashId(id.Hash_64()), id((Str_8&&)id), def(new Byte[sizeof(T) * size]), size(sizeof(T) * size)
29 {
30 Util::Copy(this->def, def, this->size);
31 }
32
33 template<typename T>
34 DbVarTmpl(Str_8 id, const T* const def)
35 : hashId(id.Hash_64()), id((Str_8&&)id), def(new Byte[sizeof(T)]), size(sizeof(T))
36 {
37 Util::Copy(this->def, def, this->size);
38 }
39
40 DbVarTmpl(Str_8 id);
41
42 DbVarTmpl(DbVarTmpl&& varTmpl) noexcept;
43
44 DbVarTmpl(const DbVarTmpl& varTmpl);
45
46 DbVarTmpl& operator=(DbVarTmpl&& varTmpl) noexcept;
47
48 DbVarTmpl& operator=(const DbVarTmpl& varTmpl);
49
50 operator Byte *() const;
51
52 UInt_64 GetHashId() const;
53
54 void SetId(Str_8 newId);
55
56 Str_8 GetId() const;
57
58 template<typename T>
59 T* GetDefaultArray() const
60 {
61 return (T*)def;
62 }
63
64 template<typename T>
65 T GetDefault() const
66 {
67 return *(T*)def;
68 }
69
70 UInt_64 GetSize() const;
71
72 private:
73 void Serialize(Serializer<UInt_64> &data) const;
74
75 void Deserialize(Serializer<UInt_64> &data);
76 };
77}
Definition DbVarTmpl.h:12
T GetDefault() const
Definition DbVarTmpl.h:65
DbVarTmpl(Str_8 id, const T *const def)
Definition DbVarTmpl.h:34
DbVarTmpl(Str_8 id, const T *const def, UInt_64 size)
Definition DbVarTmpl.h:27
T * GetDefaultArray() const
Definition DbVarTmpl.h:59
DbVarTmpl()
Definition DbVarTmpl.cpp:11
friend class DbTable
Definition DbVarTmpl.h:14
Definition DbVar.h:12
Definition Serializer.h:25
static void Copy(void *out, const void *in, UInt_64 size)
Definition Util.cpp:67
Definition Anchor.h:6
Str< Char_8, UInt_64 > Str_8
Definition Str.h:1953
unsigned char Byte
Definition Types.h:39