Keyple C++  0.9.0
Keyple, an Open Source SDK for Ticketing
Public Member Functions | Friends | List of all members
keyple::calypso::transaction::FileData Class Referencefinal

#include <FileData.h>

Public Member Functions

 FileData ()
 
 FileData (const FileData &o)
 
const std::map< int, std::vector< uint8_t > > & getAllRecordsContent () const
 
const std::vector< uint8_t > & getContent () const
 
const std::vector< uint8_t > & getContent (const int numRecord) const
 
const std::vector< uint8_t > getContent (const int numRecord, const int dataOffset, const int dataLength) const
 
int getContentAsCounterValue (const int numCounter) const
 
const std::map< int, int > getAllCountersValue () const
 
void setContent (const int numRecord, const std::vector< uint8_t > &content)
 
void setCounter (const int numCounter, const std::vector< uint8_t > &content)
 
void setContent (const int numRecord, const std::vector< uint8_t > &content, const int offset)
 
void fillContent (const int numRecord, std::vector< uint8_t > &content)
 
void addCyclicContent (const std::vector< uint8_t > &content)
 
bool operator== (const FileData &o) const
 
bool operator!= (const FileData &o) const
 

Friends

KEYPLECALYPSO_API std::ostream & operator<< (std::ostream &os, const FileData &fd)
 

Detailed Description

The class

contains all known data content of a Calypso EF.

Since
0.9

Constructor & Destructor Documentation

◆ FileData() [1/2]

keyple::calypso::transaction::FileData::FileData ( )

(package-private)
Constructor

◆ FileData() [2/2]

keyple::calypso::transaction::FileData::FileData ( const FileData o)

Copy constructor

C++ vs. Java: Copy constructor is prefereable to .clone() method

Member Function Documentation

◆ addCyclicContent()

void keyple::calypso::transaction::FileData::addCyclicContent ( const std::vector< uint8_t > &  content)

(package-private)
Add cyclic content at record #1 by rolling previously all actual records contents (record #1 -> record #2, record #2 -> record #3,...).
This is useful for cyclic files.
Note that records are infinitely shifted.

Parameters
contentthe content (should be not empty)

◆ fillContent()

void keyple::calypso::transaction::FileData::fillContent ( const int  numRecord,
std::vector< uint8_t > &  content 
)

(package-private)
Fill the content of the specified numRecord using a binary OR operation with the provided content.
If actual record content is not set or has a size

<

content size, then missing data will be completed by the provided content.

Parameters
numRecordthe record number (should be
>=
1)
contentthe content (should be not empty)

◆ getAllCountersValue()

const std::map< int, int > keyple::calypso::transaction::FileData::getAllCountersValue ( ) const

Gets all known counters value.
The counters values are extracted from record #1.
If last counter has a truncated value (when size of record #1 modulo 3 != 0), then last counter value is not returned.

Returns
a not empty object.
Exceptions
NoSuchElementExceptionif record #1 is not set.
Since
0.9

◆ getAllRecordsContent()

const std::map< int, std::vector< uint8_t > > & keyple::calypso::transaction::FileData::getAllRecordsContent ( ) const

Gets a reference to all known records content.

Returns
a not null map eventually empty if there's no content.
Since
0.9

◆ getContent() [1/3]

const std::vector< uint8_t > & keyple::calypso::transaction::FileData::getContent ( ) const

Gets a reference to the known content of record #1.
For a Binary file, it means all the bytes of the file.

Returns
a not empty reference to the record content.
Exceptions
NoSuchElementExceptionif record #1 is not set.
Since
0.9

◆ getContent() [2/3]

const std::vector< uint8_t > & keyple::calypso::transaction::FileData::getContent ( const int  numRecord) const

Gets a reference to the known content of a specific record.

Parameters
numRecordthe record number
Returns
a not empty reference to the record content.
Exceptions
NoSuchElementExceptionif record numRecord is not set.
Since
0.9

◆ getContent() [3/3]

const std::vector< uint8_t > keyple::calypso::transaction::FileData::getContent ( const int  numRecord,
const int  dataOffset,
const int  dataLength 
) const

Gets a copy of a known content subset of a specific record from dataOffset to dataLength.

Parameters
numRecordthe record number
dataOffsetthe offset index (should be
>=
0)
dataLengththe data length (should be
>=
1)
Returns
a copy not empty of the record subset content.
Exceptions
IllegalArgumentExceptionif dataOffset
<
0 or dataLength
<
1.
NoSuchElementExceptionif record numRecord is not set.
IndexOutOfBoundsExceptionif dataOffset
>=
content length or (dataOffset + dataLength)
>
content length.
Since
0.9

◆ getContentAsCounterValue()

int keyple::calypso::transaction::FileData::getContentAsCounterValue ( const int  numCounter) const

Gets the known value of the counter numCounter.
The counter value is extracted from the 3 next bytes at the index [(numCounter - 1) * 3] of the record #1.
e.g. if numCounter == 2, then value is extracted from bytes indexes [3,4,5].

Parameters
numCounterthe counter number (should be
>=
1)
Returns
the counter value.
Exceptions
IllegalArgumentExceptionif numCounter is
<
1.
NoSuchElementExceptionif record #1 or numCounter is not set.
IndexOutOfBoundsExceptionif numCounter has a truncated value (when size of record #1 modulo 3 != 0).
Since
0.9

◆ operator!=()

bool keyple::calypso::transaction::FileData::operator!= ( const FileData o) const

◆ operator==()

bool keyple::calypso::transaction::FileData::operator== ( const FileData o) const

◆ setContent() [1/2]

void keyple::calypso::transaction::FileData::setContent ( const int  numRecord,
const std::vector< uint8_t > &  content 
)

(package-private)
Set or replace the entire content of the specified record numRecord by the provided content.

Parameters
numRecordthe record number (should be
>=
1)
contentthe content (should be not empty)

◆ setContent() [2/2]

void keyple::calypso::transaction::FileData::setContent ( const int  numRecord,
const std::vector< uint8_t > &  content,
const int  offset 
)

(package-private)
Set or replace the content at the specified offset of record numRecord by a copy of the provided content.
If actual record content is not set or has a size

<

offset, then missing data will be padded with 0.

Parameters
numRecordthe record number (should be
>=
1)
contentthe content (should be not empty)
offsetthe offset (should be
>=
0)

◆ setCounter()

void keyple::calypso::transaction::FileData::setCounter ( const int  numCounter,
const std::vector< uint8_t > &  content 
)

(package-private)
Sets a counter value in record #1.

Parameters
numCounterthe counter number (should be
>=
1)
contentthe counter value (should be not null and 3 bytes length)

Friends And Related Function Documentation

◆ operator<<

KEYPLECALYPSO_API std::ostream& operator<< ( std::ostream &  os,
const FileData fd 
)
friend

The documentation for this class was generated from the following files:
keyple::calypso::transaction::FileData::FileData
FileData()
Definition: FileData.cpp:36