KItinerary::File

Search for usage in LXR

#include <file.h>

Classes

struct  PkPassIdentifier
 

Public Types

enum  OpenMode { Read , Write }
 

Public Member Functions

 File (const File &)=delete
 
 File (const QString &fileName)
 
 File (File &&) noexcept
 
 File (QIODevice *device)
 
void addCustomData (QStringView scope, const QString &id, const QByteArray &data)
 
void addDocument (const QString &id, const QVariant &docInfo, const QByteArray &docData)
 
void addPass (const QString &passId, const QByteArray &rawData)
 
void addPass (KPkPass::Pass *pass, const QByteArray &rawData)
 
void addReservation (const QString &id, const QVariant &res)
 
void addReservation (const QVariant &res)
 
void close ()
 
QByteArray customData (QStringView scope, const QString &id) const
 
QByteArray documentData (const QString &id) const
 
QVariant documentInfo (const QString &id) const
 
QList< QStringdocuments () const
 
QString errorString () const
 
bool hasCustomData (QStringView scope, const QString &id) const
 
QList< QStringlistCustomData (QStringView scope) const
 
bool open (OpenMode mode) const
 
Fileoperator= (const File &)=delete
 
Fileoperator= (File &&) noexcept
 
QByteArray passData (const QString &passId) const
 
QList< QStringpasses () const
 
QVariant reservation (const QString &resId) const
 
QList< QStringreservations () const
 
void setFileName (const QString &fileName)
 

Static Public Member Functions

static PkPassIdentifier decodePassId (QStringView)
 
static QString normalizeDocumentFileName (const QString &name)
 
static QString passId (const KPkPass::Pass *pass)
 
static QString passId (const QString &passTypeIdenfier, const QString &serialNumber)
 

Detailed Description

A file containing a bundle of reservations and associated documents.

This is used to export or transfer a set of reservation-related documents while keeping the associations between them.

A KItinerary::File can contain the following elements:

  • JSON-LD reservation objects (see KItinerary::Reservation). Each reservation has a UUID.
  • PkPass files. Their identifier is determined by their pass type identifier and their serial number.
  • JSON-LD document objects (see KItinerary::CreativeWork) and their associated file content. Each document has a UUID.
  • Application-specific data in custom namespaces.

Definition at line 37 of file file.h.

Member Enumeration Documentation

◆ OpenMode

enum KItinerary::File::OpenMode

Definition at line 54 of file file.h.

Constructor & Destructor Documentation

◆ File() [1/3]

File::File ( )
explicit

Definition at line 37 of file file.cpp.

◆ File() [2/3]

File::File ( const QString & fileName)
explicit

Create a File instance for the file named fileName.

Definition at line 42 of file file.cpp.

◆ File() [3/3]

File::File ( QIODevice * device)
explicit

Create a File instance for the given i/o device.

Definition at line 48 of file file.cpp.

◆ ~File()

File::~File ( )

Definition at line 56 of file file.cpp.

Member Function Documentation

◆ addCustomData()

void File::addCustomData ( QStringView scope,
const QString & id,
const QByteArray & data )

Adds a custom data element with identifier id in to namespace scope.

Definition at line 384 of file file.cpp.

◆ addDocument()

void File::addDocument ( const QString & id,
const QVariant & docInfo,
const QByteArray & docData )

Adds a document and associated meta data to the file.

Definition at line 322 of file file.cpp.

◆ addPass() [1/2]

void File::addPass ( const QString & passId,
const QByteArray & rawData )

Add a pkpass file with the given pass id.

Definition at line 232 of file file.cpp.

◆ addPass() [2/2]

void File::addPass ( KPkPass::Pass * pass,
const QByteArray & rawData )

Add a pkpass file to this file.

Definition at line 227 of file file.cpp.

◆ addReservation() [1/2]

void File::addReservation ( const QString & id,
const QVariant & res )

Add a reservation to this file.

The given identifier will be used.

Definition at line 154 of file file.cpp.

◆ addReservation() [2/2]

void File::addReservation ( const QVariant & res)

Add a reservation to this file.

A new unique identifier will be generated for the reservation.

Definition at line 149 of file file.cpp.

◆ close()

void File::close ( )

Save and close the file.

Automatically called from the dtor.

Definition at line 92 of file file.cpp.

◆ customData()

QByteArray File::customData ( QStringView scope,
const QString & id ) const
nodiscard

Returns the custom data in the given namespace and with the given id.

Definition at line 368 of file file.cpp.

◆ decodePassId()

File::PkPassIdentifier File::decodePassId ( QStringView passId)
staticnodiscard

Definition at line 174 of file file.cpp.

◆ documentData()

QByteArray File::documentData ( const QString & id) const
nodiscard

Loads the content of document id.

Definition at line 286 of file file.cpp.

◆ documentInfo()

QVariant File::documentInfo ( const QString & id) const
nodiscard

Loads the document meta data of document id.

Definition at line 257 of file file.cpp.

◆ documents()

QList< QString > File::documents ( ) const
nodiscard

Lists all document identifiers.

Definition at line 238 of file file.cpp.

◆ errorString()

QString File::errorString ( ) const
nodiscard

Error message in case opening the file failed.

Definition at line 84 of file file.cpp.

◆ hasCustomData()

bool File::hasCustomData ( QStringView scope,
const QString & id ) const
nodiscard

Returns true if custom data with the given id exists in scope.

Definition at line 357 of file file.cpp.

◆ listCustomData()

QList< QString > File::listCustomData ( QStringView scope) const
nodiscard

List custom data in the given namespace.

Definition at line 342 of file file.cpp.

◆ normalizeDocumentFileName()

QString File::normalizeDocumentFileName ( const QString & name)
staticnodiscard

Makes sure the resulting file name is something that can safely be used without messing up the file system or archive structure.

Definition at line 304 of file file.cpp.

◆ open()

bool File::open ( File::OpenMode mode) const
nodiscard

Open the file for reading or writing.

A filename needs to be set before calling this. All read/write operations require the file to be open as a precondition.

Definition at line 68 of file file.cpp.

◆ passData()

QByteArray File::passData ( const QString & passId) const
nodiscard

Pass data for the given pass id.

Definition at line 211 of file file.cpp.

◆ passes()

QList< QString > File::passes ( ) const
nodiscard

Lists all pkpass files in this file.

Definition at line 184 of file file.cpp.

◆ passId() [1/2]

QString File::passId ( const KPkPass::Pass * pass)
staticnodiscard

Returns the pass identifier used in here for pass.

Definition at line 160 of file file.cpp.

◆ passId() [2/2]

QString File::passId ( const QString & passTypeIdenfier,
const QString & serialNumber )
staticnodiscard

Definition at line 165 of file file.cpp.

◆ reservation()

QVariant File::reservation ( const QString & resId) const
nodiscard

Loads the reservation with the given identifier.

Definition at line 120 of file file.cpp.

◆ reservations()

QList< QString > File::reservations ( ) const
nodiscard

Lists the identifiers of all reservations in this file.

Definition at line 100 of file file.cpp.

◆ setFileName()

void File::setFileName ( const QString & fileName)

Sets the file name.

Needs to be done before calling open().

Definition at line 63 of file file.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:28:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.