ActiveLib
Loading...
Searching...
No Matches
Transport.h
1
6#ifndef ACTIVE_SERIALISE_TRANSPORT
7#define ACTIVE_SERIALISE_TRANSPORT
8
9#include "Active/Serialise/XML/Item/XMLDateTime.h"
10#include "Active/Utility/Memory.h"
11
12namespace active::utility {
13
14 class BufferIn;
15 class BufferOut;
16
17}
18
19namespace active::serialise {
20
21 class Cargo;
22 struct Identity;
23
24}
25
26namespace active::serialise {
27
31 class Transport {
32 public:
33
34 // MARK: - Types
35
36 using TimeFormat = std::optional<xml::XMLDateTime::Format>;
37 using size_type = utility::Memory::size_type;
38 using enum xml::XMLDateTime::Format;
39
40 // MARK: - Constructors
41
47 Transport(bool isUnknownNameSkipped = false, TimeFormat timeFormat = iso8601) noexcept {
48 m_isUnknownNameSkipped = isUnknownNameSkipped;
49 m_timeFormat = timeFormat;
50 }
54 virtual ~Transport() noexcept {}
55
56
57 // MARK: - Functions (const)
58
70 virtual void send(serialise::Cargo&& cargo, const serialise::Identity& identity, utility::BufferOut&& destination,
71 bool isTabbed = false, bool isLineFeeds = false, bool isNameSpaces = true, bool isProlog = true) const = 0;
79 virtual void receive(serialise::Cargo&& cargo, const serialise::Identity& identity, utility::BufferIn&& source) const = 0;
84 TimeFormat getTimeFormat() const noexcept { return m_timeFormat; }
89 size_type getLastRow() const noexcept { return m_lastRow; }
94 size_type getLastColumn() const noexcept { return m_lastColumn; }
99 bool isUnknownNameSkipped() const noexcept { return m_isUnknownNameSkipped; }
100
101 // MARK: - Functions (mutating)
102
107 void setTimeFormat(TimeFormat format) noexcept { m_timeFormat = format; }
112 void setUnknownNameSkipped(bool state) noexcept { m_isUnknownNameSkipped = state; }
113
114 protected:
119 void setLastRow(size_type row) const noexcept { m_lastRow = row; }
124 void setLastColumn(size_type col) const noexcept { m_lastColumn = col; }
125
126 private:
127 //The preferred date/time format
128 TimeFormat m_timeFormat = iso8601;
129 //The last row read from the data source (can be useful for error diagnostics)
130 mutable size_type m_lastRow = 0;
131 //The last column read from the data source (can be useful for error diagnostics)
132 mutable size_type m_lastColumn = 0;
133 //True if unknown tags should be skipped over
134 bool m_isUnknownNameSkipped = false;
135 };
136
137}
138
139#endif //ACTIVE_SERIALISE_TRANSPORT
Definition Cargo.h:17
Definition Transport.h:31
virtual void receive(serialise::Cargo &&cargo, const serialise::Identity &identity, utility::BufferIn &&source) const =0
void setTimeFormat(TimeFormat format) noexcept
Definition Transport.h:107
bool isUnknownNameSkipped() const noexcept
Definition Transport.h:99
virtual void send(serialise::Cargo &&cargo, const serialise::Identity &identity, utility::BufferOut &&destination, bool isTabbed=false, bool isLineFeeds=false, bool isNameSpaces=true, bool isProlog=true) const =0
void setLastRow(size_type row) const noexcept
Definition Transport.h:119
Transport(bool isUnknownNameSkipped=false, TimeFormat timeFormat=iso8601) noexcept
Definition Transport.h:47
TimeFormat getTimeFormat() const noexcept
Definition Transport.h:84
virtual ~Transport() noexcept
Definition Transport.h:54
size_type getLastColumn() const noexcept
Definition Transport.h:94
size_type getLastRow() const noexcept
Definition Transport.h:89
void setLastColumn(size_type col) const noexcept
Definition Transport.h:124
void setUnknownNameSkipped(bool state) noexcept
Definition Transport.h:112
Format
Preferred JSON date/time format.
Definition XMLDateTime.h:21
Definition BufferIn.h:27
Definition BufferOut.h:23
std::size_t size_type
Memory size/position type.
Definition Memory.h:26
Definition Cargo.h:12
Definition Base64Transport.h:11
Definition Identity.h:18