-
Notifications
You must be signed in to change notification settings - Fork 1
/
txbiterator.hpp
63 lines (54 loc) · 1.74 KB
/
txbiterator.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef TXB_ITERATOR_HPP_GUARD
#define TXB_ITERATOR_HPP_GUARD
//===----------------------------------------------------------------------===//
//
// The Descent map loader
//
// NAME : TxbIterator
// PURPOSE : Providing an iterator over text in aDescent .TXB format.
// COPYRIGHT : (c) 2022 Sean Donnellan. All Rights Reserved.
// AUTHORS : Sean Donnellan ([email protected])
// DESCRIPTION : Provides a forward iterator over text in a TXB (encrypted)
// text file. This is one of the files found in HOG file format
// that is used by Parallax Software in the computer game
// Descent.
//
//===----------------------------------------------------------------------===//
#include <iterator>
#include <stdint.h>
class TxbReaderIterator
{
const uint8_t* mySource;
char myValue;
char CurrentValue() const;
public:
// Ideally this would be a std::random_access_iterator_tag, unless it
// was going to support expanding LR to CR LF.
using iterator_category = std::forward_iterator_tag;
using value_type = char;
using difference_type = std::ptrdiff_t;
using pointer = const char*;
using reference = const char&;
TxbReaderIterator(const uint8_t* Value);
reference operator*() const
{
return myValue;
}
pointer operator->()
{
return &myValue;
}
TxbReaderIterator& operator++();
TxbReaderIterator operator++(int);
friend bool operator==(const TxbReaderIterator& Lhs,
const TxbReaderIterator& Rhs)
{
return Lhs.mySource == Rhs.mySource;
};
friend bool operator!=(const TxbReaderIterator& Lhs,
const TxbReaderIterator& Rhs)
{
return Lhs.mySource != Rhs.mySource;
};
};
#endif