1 #ifndef __LEVELLER_TAG_H__
2 #define __LEVELLER_TAG_H__
45 typedef uchar uint8, uchar, byte;
48 typedef unsigned short uint16, word;
50 typedef uint uint32, dword;
51 typedef float float32;
52 typedef double float64;
54 typedef void* (*_MALLOCFUNC)(size_t);
55 typedef void (*_FREEFUNC)(
void*);
56 typedef void* (*_MEMCOPYFUNC)(
void*,
const void*, size_t);
59 const size_t MAX_TAGNAMELEN = 15;
78 TAGRELATION_CHILD = 1,
79 TAGRELATION_SIBLING = 2
85 char szName[MAX_TAGNAMELEN + 1];
87 daylon::uint32 valueSize;
88 daylon::uint32 reserved;
94 daylon::uint32 tagSize;
95 daylon::uint32 reserved2;
97 daylon::int16 relationFlags;
98 daylon::int16 valueKind;
136 CRootTag() : m_pRoot(NULL), m_mark(0), m_size(0),
140 size_t GetValSize(
int)
const;
141 size_t CalcNormalStorage(
size_t numTags,
int kind,
size_t arraySize = 1)
const;
142 size_t CalcBinaryTagStorage(
size_t binSize)
const;
144 void SetStorage(
void* p,
size_t n)
145 { m_pRoot = (uchar*)p;
146 m_mark = 0; m_size = n; m_openMode = 0; }
148 void Open(
const char* pszMode);
152 void WriteParent(
const char* pszName,
bool bHasSibling)
153 { this->Write(pszName,
155 (bHasSibling ? TAGRELATION_SIBLING : 0));
160 const char* pszName,
int relationFlags,
161 int valueKind = VALKIND_NONE,
162 const void* pvData = NULL,
163 size_t datasize = 0);
165 void Write(
const char* pszName,
166 daylon::uint32 value,
169 void Write(
const char* pszName,
179 const char* pszName,
bool bHasSibling,
184 size_t Read(
const char*,
void**);
185 daylon::uint32 ReadUINT32(
const char*, daylon::uint32 _default);
186 double ReadDouble(
const char*,
double _default);
188 size_t MemSize(
void)
const
189 {
return sizeof(*this) + m_size; }
190 void CopyFrom(
const CRootTag&, _MALLOCFUNC, _MEMCOPYFUNC);
191 void Destroy(_FREEFUNC);
195 void DumpTag(
const char*);
196 static const char* TypeString(
int);
197 static char* ValueString(
const TAG&,
char*);
206 void WasEndReached(
void);
208 size_t ReadTag(
const char*,
void**);
209 size_t ArraySize(
const TAG&)
const;
215 #endif // __LEVELLER_TAG_H__