aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_bsplugins/src/TESData/SingleRecordParser.h
blob: 4304166c2e8280e03589aa8a18d815430b885830 (plain)
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
#ifndef TESDATA_SINGLERECORDPARSER_H
#define TESDATA_SINGLERECORDPARSER_H

#include "DataItem.h"
#include "RecordPath.h"
#include "TESFile/Stream.h"

#include <iplugingame.h>

#include <coroutine>
#include <functional>
#include <memory>
#include <vector>

namespace TESData
{

class IFormParser;

class SingleRecordParser final
{
public:
  SingleRecordParser(const QString& gameName, const RecordPath& path,
                     const std::string& file, DataItem* root, int index);

  bool Group(TESFile::GroupData group);
  bool Form(TESFile::FormData form);
  bool Chunk(TESFile::Type type);
  void Data(std::istream& stream);

private:
  QString m_GameName;
  RecordPath m_Path;
  std::string m_File;
  DataItem* m_DataRoot;
  int m_FileIndex;

  TESFile::Type m_CurrentType;
  std::uint32_t m_CurrentFlags = 0;
  std::coroutine_handle<> m_ParseTask;
  std::istream* m_ChunkStream;

  std::vector<std::string> m_Masters;
  int m_Depth           = 0;
  bool m_Localized      = false;
  bool m_RecordFound    = false;
  TESFile::Type m_CurrentChunk;
};

}  // namespace TESData

#endif  // TESDATA_SINGLERECORDPARSER_H