Commit 3fe29241 authored by Volker Krause's avatar Volker Krause
Browse files

Change the interface of Uic9183TicketLayout to use the new block type

parent 954beca1
......@@ -17,6 +17,7 @@
#include <KItinerary/JsonLdDocument>
#include <KItinerary/Rct2Ticket>
#include <KItinerary/Uic9183Block>
#include <KItinerary/Uic9183TicketLayout>
#include <QDebug>
......@@ -58,7 +59,7 @@ private Q_SLOTS:
QVERIFY(f.open(QFile::ReadOnly));
const auto data = f.readAll();
Uic9183TicketLayout layout(data.data(), data.size());
Uic9183TicketLayout layout(Uic9183Block(data, 0));
Rct2Ticket rct2(layout);
rct2.setContextDate({{2018, 12, 19}, {18, 35}});
QVERIFY(layout.isValid());
......
......@@ -176,6 +176,7 @@ ecm_generate_headers(KItinerary_Pdf_FORWARDING_HEADERS
ecm_generate_headers(KItinerary_Uic9183_FORWARDING_HEADERS
HEADER_NAMES
Rct2Ticket
Uic9183Block
Uic9183Parser
Uic9183TicketLayout
PREFIX KItinerary
......
......@@ -29,6 +29,7 @@ class KITINERARY_EXPORT Uic9183Block
{
public:
Uic9183Block();
explicit Uic9183Block(const QByteArray &data, int offset);
Uic9183Block(const Uic9183Block&);
Uic9183Block(Uic9183Block&&);
Uic9183Block& operator=(const Uic9183Block&);
......@@ -58,9 +59,6 @@ public:
Uic9183Block nextBlock() const;
private:
friend class Uic9183Parser;
Uic9183Block(const QByteArray &data, int offset);
QByteArray m_data;
int m_offset = 0;
};
......
......@@ -348,7 +348,7 @@ QString Uic9183Parser::seatingType() const
Uic9183TicketLayout Uic9183Parser::ticketLayout() const
{
const auto block = findBlock("U_TLAY");
Uic9183TicketLayout layout(block.data(), block.size());
Uic9183TicketLayout layout(block);
return layout;
}
......
......@@ -16,6 +16,7 @@
*/
#include "uic9183ticketlayout.h"
#include "uic9183block.h"
#include "logging.h"
#include <QDateTime>
......@@ -176,9 +177,7 @@ Uic9183TicketLayoutField Uic9183TicketLayoutPrivate::firstField() const
}
// 6x "U_TLAY"
// 2x version (always "01")
// 4x record length, numbers as ASCII text
// "U_TLAY" Block
// 4x ticket layout type (e.g. "RCT2")
// 4x field count
// Nx fields (see Uic9183TicketLayoutField)
......@@ -187,11 +186,11 @@ Uic9183TicketLayout::Uic9183TicketLayout()
{
}
Uic9183TicketLayout::Uic9183TicketLayout(const char *data, int size)
Uic9183TicketLayout::Uic9183TicketLayout(const Uic9183Block &block)
: d(new Uic9183TicketLayoutPrivate)
{
d->data = data;
d->size = size;
d->data = block.data();
d->size = block.size();
#if 0
std::vector<QString> out;
......
......@@ -27,6 +27,7 @@ class QSize;
namespace KItinerary {
class Uic9183Block;
class Uic9183TicketLayoutPrivate;
/** Parser for a U_TLAY block in a UIC 918-3 ticket. */
......@@ -41,10 +42,9 @@ public:
/** Parse U_TLAY ticket layout block in @p data.
* It's the callers responsibility to ensure @p data outlives this instance, the data
* is not copied.
* @param data UIC 918.3 U_TLAY data block
* @param size The length of the U_TLAY data block
* @param block A UIC 918.3 U_TLAY data block
*/
Uic9183TicketLayout(const char *data, int size);
Uic9183TicketLayout(const Uic9183Block &block);
Uic9183TicketLayout(const Uic9183TicketLayout&);
~Uic9183TicketLayout();
Uic9183TicketLayout& operator=(const Uic9183TicketLayout&);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment