Nebula
Loading...
Searching...
No Matches
bxmlloaderutil.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
18#include "core/types.h"
19#include "io/stream.h"
21#include "util/array.h"
22
23//------------------------------------------------------------------------------
24namespace IO
25{
27{
28public:
29 static const ushort InvalidNodeIndex = 0xffff;
30 static const uint InvalidAttrIndex = 0xffffffff;
31
36
38 void SetupFromFileInMemory(void* buf, Stream::Size size);
40 void Discard();
42 bool IsValid() const;
43
45 ushort FindNodeIndex(const char* path) const;
47 void SetCurrentNodeIndex(ushort index);
51 const char* GetCurrentNodeName() const;
53 bool SetToFirstChild(const char* name);
55 bool SetToNextChild(const char* name);
57 bool SetToParent();
58
60 uint FindAttrIndex(const char* attrName) const;
62 uint GetNumAttrs() const;
64 const char* GetAttrName(uint attrIndex) const;
66 const char* GetAttrValue(uint attrIndex) const;
67
69 ushort FindChildNodeIndex(ushort nodeIndex, const char* childName) const;
71 ushort FindSiblingNodeIndex(ushort nodeIndex, const char* sibName) const;
73 ushort GetParentNodeIndex(ushort nodeIndex) const;
75 const char* GetNodeName(ushort nodeIndex) const;
76
77private:
78 void* buffer;
80
85
87};
88
89//------------------------------------------------------------------------------
92inline bool
94{
95 return (0 != this->buffer);
96}
97
98//------------------------------------------------------------------------------
101inline void
103{
104 n_assert((0 != this->header) && (i < this->header->numNodes));
105 this->curNodeIndex = i;
106}
107
108//------------------------------------------------------------------------------
111inline ushort
113{
114 return this->curNodeIndex;
115}
116
117//------------------------------------------------------------------------------
120inline const char*
126
127} // namespace IO
128//------------------------------------------------------------------------------
129
130
Structures used by the BXML file format.
Helper class for loading binary xml files created with N3's binaryxmlconverter3 tool.
Definition bxmlloaderutil.h:27
const char * GetNodeName(ushort nodeIndex) const
get name of a given node
Definition bxmlloaderutil.cc:155
const char * GetAttrName(uint attrIndex) const
get name of attribute by index
Definition bxmlloaderutil.cc:324
bool SetToFirstChild(const char *name)
set cursor to first matching child node, name may point to empty string
Definition bxmlloaderutil.cc:232
ushort FindSiblingNodeIndex(ushort nodeIndex, const char *sibName) const
find a sibling node index by name, name may point to empty string
Definition bxmlloaderutil.cc:122
uint FindAttrIndex(const char *attrName) const
find attribute index by name
Definition bxmlloaderutil.cc:292
void * buffer
Definition bxmlloaderutil.h:78
ushort FindChildNodeIndex(ushort nodeIndex, const char *childName) const
find a child node index by name, name may point to empty string
Definition bxmlloaderutil.cc:98
~BXmlLoaderUtil()
destructor
Definition bxmlloaderutil.cc:31
BXmlLoaderUtil()
constructor
Definition bxmlloaderutil.cc:17
bool SetToParent()
set to parent node
Definition bxmlloaderutil.cc:271
ushort curNodeIndex
Definition bxmlloaderutil.h:86
static const ushort InvalidNodeIndex
Definition bxmlloaderutil.h:29
Util::Array< const char * > stringTable
Definition bxmlloaderutil.h:84
BXMLFileHeader * header
Definition bxmlloaderutil.h:81
ushort FindNodeIndex(const char *path) const
find a node index by path
Definition bxmlloaderutil.cc:165
void SetCurrentNodeIndex(ushort index)
set cursor to node index
Definition bxmlloaderutil.h:102
static const uint InvalidAttrIndex
Definition bxmlloaderutil.h:30
ushort GetCurrentNodeIndex() const
get current node index
Definition bxmlloaderutil.h:112
void SetupFromFileInMemory(void *buf, Stream::Size size)
setup the object from a file-in-memory, buffer must remain intact until Discard() is called!
Definition bxmlloaderutil.cc:40
uint GetNumAttrs() const
get number of attributes on node
Definition bxmlloaderutil.cc:314
BXMLFileNode * nodes
Definition bxmlloaderutil.h:83
Stream::Size bufSize
Definition bxmlloaderutil.h:79
bool SetToNextChild(const char *name)
set cursor to next matching child node, name may point to empty string
Definition bxmlloaderutil.cc:251
bool IsValid() const
return true if the object has been setup
Definition bxmlloaderutil.h:93
const char * GetAttrValue(uint attrIndex) const
get value of attribute by index
Definition bxmlloaderutil.cc:335
BXMLFileAttr * attrs
Definition bxmlloaderutil.h:82
void Discard()
discard the object
Definition bxmlloaderutil.cc:79
const char * GetCurrentNodeName() const
get name of current node
Definition bxmlloaderutil.h:121
ushort GetParentNodeIndex(ushort nodeIndex) const
get the parent node index of a node
Definition bxmlloaderutil.cc:145
int64_t Size
Definition stream.h:34
Nebula's dynamic array class.
Definition array.h:60
#define n_assert(exp)
Definition debug.h:50
Instances of wrapped stream classes.
Definition orientation.cc:10
Definition bxmlfilestructs.h:26
Definition bxmlfilestructs.h:19
uint numNodes
Definition bxmlfilestructs.h:22
Definition bxmlfilestructs.h:31
ushort nameIndex
Definition bxmlfilestructs.h:32
unsigned int uint
Definition types.h:31
unsigned short ushort
Definition types.h:32