-
Notifications
You must be signed in to change notification settings - Fork 5
/
asterix.h
93 lines (65 loc) · 2.46 KB
/
asterix.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* This application is free software and is released under the terms of
* the BSD license. See LICENSE file for details.
*
* Copyright (c) 2014 Volker Poplawski ([email protected])
*/
#ifndef ASTERIX_H
#define ASTERIX_H
#include <QtCore>
class AsterixRecord;
class AsterixDataItem;
#include "uap.h"
#include "bit.h"
class AsterixBlock
{
public:
AsterixBlock(const uchar* data, const Uap& uap);
const uchar* data() const { return m_data; }
quint8 category() const { return *(quint8*)(m_data + 0); }
quint16 length() const { return qFromBigEndian<quint16>(m_data + 1); }
int numRecords() const { return m_records.count(); }
const AsterixRecord& record(int index) const { return m_records[index]; }
static int countExtends(const uchar* p);
static QList<int> decodeFspecSection(const uchar* p, int size);
protected:
const uchar* m_data;
QList<AsterixRecord> m_records;
};
class AsterixRecord
{
public:
AsterixRecord(const uchar* data, int blockIndex, const UapCategory* uapCat);
const uchar* data() const { return m_data; }
int length() const { return m_length; }
int numFields() const { return m_fields.count(); }
const AsterixDataItem& field(int index) const { return m_fields[index]; }
QTime timeOfDay() const { return m_timeOfDay; }
QList<int> decodeFspecSection() const;
protected:
const uchar* m_data;
int m_index; // record-index in block
int m_length;
QTime m_timeOfDay;
QList<AsterixDataItem> m_fields;
};
class AsterixDataItem
{
public:
AsterixDataItem(const uchar* data, const UapDataItem* uapDataItem);
const UapDataItem* uapDataItem() const { return m_uapDataItem; }
const uchar* data() const { return m_data; }
int length() const { return m_length; }
int numSubfields() const { return m_subfields.count(); }
const AsterixDataItem& subField(int index) const { return m_subfields[index]; }
QByteArray bitfield(int o, int l, int msb, int lsb) const;
static QChar decodeIcaoSixBitChar(int c);
static QString decodeIcaoStr(const uchar* p);
protected:
int numExtends() const { return AsterixBlock::countExtends(m_data); }
const uchar* m_data;
int m_length;
const UapDataItem* m_uapDataItem;
QList<AsterixDataItem> m_subfields; // if this is a compound item, otherwise empty
};
#endif // ASTERIX_H