-
Notifications
You must be signed in to change notification settings - Fork 1
/
txbreader.hpp
47 lines (40 loc) · 1.33 KB
/
txbreader.hpp
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
#ifndef TXB_READER_HPP_GUARD
#define TXB_READER_HPP_GUARD
//===----------------------------------------------------------------------===//
//
// The Descent map loader
//
// NAME : TxbReader
// PURPOSE : Read contents of Descent .TXB format.
// COPYRIGHT : (c) 2022 Sean Donnellan. All Rights Reserved.
// AUTHORS : Sean Donnellan ([email protected])
// DESCRIPTION : Provides a iterators over series of bytes that represent the
// text in a TXB (encrypted) text file.
//
// This class could likely be replaced with creating a TxbReaderIterator from
// a std::span in C++20 instead or at least a function which takes the
// std::vector and returns the begin/end iterates.
//
//===----------------------------------------------------------------------===//
class TxbReader
{
public:
// The reader should not outlive the vector of bytes.
TxbReader(const std::vector<uint8_t>& Data);
TxbReaderIterator begin() const;
TxbReaderIterator end() const;
private:
const std::vector<uint8_t>& myData;
};
inline TxbReader::TxbReader(const std::vector<uint8_t>& Data) : myData(Data)
{
}
inline TxbReaderIterator TxbReader::begin() const
{
return TxbReaderIterator(myData.data());
}
inline TxbReaderIterator TxbReader::end() const
{
return TxbReaderIterator(myData.data() + myData.size());
}
#endif