forked from kenygia/MooseEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LsbReader.h
64 lines (60 loc) · 2.05 KB
/
LsbReader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef LSBREADER_H
#define LSBREADER_H
#include <map>
#include <string>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include "LsbObject.h"
class ReaderProgressCallback {
public:
virtual void onLoadBegin(int dirCount) = 0;
virtual void onLoadUpdate(int dirsLeft) = 0;
virtual void onLoadEnd() = 0;
};
class LsbReader
{
ReaderProgressCallback *readerProgressCallback = 0;
bool loanedTagList = false;
std::vector<TAG_LSB *> tagList;
HEADER_LSB cachedHeader;
bool headerCached = false;
long entityCount;
std::vector<ENTITY_HEADER_LSB *> entityHeaderList;
bool dataHeaderCached = false;
void addItemListToDirectory(long& entitiesBuilt, long& builtEntityTagCount, long& readTagCount, std::vector<LsbObject *>& arrayEntity, LsbObject *array, TAG_LSB *tagPtr, std::stack<LsbObject *>& arrayStack, bool& doneBuilding, bool& readFirst);
LsbObject *addChildToCurrentDirectory(LsbObject *child, LsbObject *array, TAG_LSB *tagPtr, std::stack<LsbObject *>& directoryStack);
bool readTags(std::istream& input, long tagCount, int& bytesLeft, std::vector<TAG_LSB *>& tagList, char *alloc);
bool readTagData(std::istream& input, long readSize, std::stack<LsbObject *>& arrayStack, long tagCount, int& bytesLeft, std::vector<TAG_LSB *>& tagList, char *alloc);
TAG_LSB * getTagByIndex(long &index, std::vector<TAG_LSB *>& tagList);
void readDataHeader(std::istream& input, int& bytesLeft, char *alloc);
void cleanup();
int readCount;
public:
~LsbReader() {
cleanup();
}
LsbReader();
std::vector<TAG_LSB *> getTagList() {
loanedTagList = true;
return tagList;
}
void clearTagList(std::vector<TAG_LSB *>& tagList) {
if (!loanedTagList) {
for (int i=0; i<tagList.size(); ++i) {
delete tagList[i];
}
}
tagList.clear();
}
void registerProgressCallback(ReaderProgressCallback *readerProgressCallback) {
this->readerProgressCallback = readerProgressCallback;
}
std::vector<LsbObject *> loadFile(std::istream& input);
HEADER_LSB *getHeader();
int getReadCount() const;
};
#endif // LSBREADER_H