KItinerary

uic9183block.h
1/*
2 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "kitinerary_export.h"
10
11#include <QByteArray>
12#include <QMetaType>
13#include <QString>
14
15namespace KItinerary {
16
17/** A data block from a UIC 918.3 ticket. */
18class KITINERARY_EXPORT Uic9183Block
19{
20 Q_GADGET
21 /** Content as string, for use in JS. */
22 Q_PROPERTY(QString contentText READ contentText)
23public:
25 explicit Uic9183Block(const QByteArray &data, int offset);
28 Uic9183Block& operator=(const Uic9183Block&);
29 Uic9183Block& operator=(Uic9183Block&&);
30
31 bool operator==(const Uic9183Block &other) const;
32
33 /** Returns the block name (6 characters).
34 * The name is either "U_" + 4 letter standard type or a 4 digit vendor id + 2 char vendor type
35 */
36 const char *name() const;
37
38 /** Checks if this block has the given record id. */
39 bool isA(const char recordId[6]) const;
40 /** Checks if a block is of type @tparam T. */
41 template <typename T> inline bool isA() const
42 {
43 return isA(T::RecordId);
44 }
45
46 /** Returns the payload data (not including the block header). */
47 const char *content() const;
48 /** Returns the size of the entire block data. */
49 int size() const;
50 /** Returns the size of the content data. */
51 int contentSize() const;
52 /** Returns the version number of this block. */
53 int version() const;
54
55 /** Checks if the block is valid or empty/default constructed. */
56 bool isNull() const;
57
58 /** Returns the next block in the ticket.
59 * If there is no more block, a null block is returned.
60 */
61 Uic9183Block nextBlock() const;
62
63private:
64 QString contentText() const;
65
66 QByteArray m_data;
67 int m_offset = 0;
68};
69
70}
A data block from a UIC 918.3 ticket.
bool isA() const
Checks if a block is of type.
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:03:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.