Open ssproessig opened 5 years ago
Provide a declarative complex configuration
<?xml version="1.0" encoding="UTF-8"?>
<configuration version="1" xmlns="urn:ipca-configuration-v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ipca-configuration-v1 ipca-configuration-v1.xsd">
<configurations>
<bsd:configuration id="cfgBsd" xmlns:bsd="urn:ipca-configuration-for-byte-stream-definitions-v1">
<bsd:struct name="Sample">
<bsd:uint8 name="index"/>
<bsd:uint16-be name="shortField"/>
<bsd:uint64-be name="longLongField"/>
<bsd:string name="message" type="fixed" encoding="utf-8"/>
<bsd:debug/>
</bsd:struct>
</bsd:configuration>
</configurations>
<components>
<component id="bsrTest" type="ByteStreamReader">
<configuration ref="cfgBsd"/>
</component>
...
IByteHandler
with methods
bool read(QByteArray const& readFrom, quint64 pos, Context&)
bool write(QByteArray& writeTo, Context&)
Context
to share
QString namePrefix
carries the prefix to add to local name, derived from the element hierarchy (@name
in XML configuration)QMap<QString, QVariant> metaData
AbstractByteHandler
that
QString const& getLastError() const
and void setError(QString const&)
AbstractHandler
(they are stateless! no factory needed) - compare to GlobalComponentRegistry
for how to do itwrite(...)
method from ByteStreamWriter
, using the IPipelineFrame::getMetaData()
as value provider for the context keyread(...)
method from ByteStreamReader
, updating the meta-data in the pipeline frame returned with Context.metaData
just parsedc
reading from data
until we encounter a 0x00
byte
0x00
byte until reachingpascal
where the first byte of the data is the length of the bytes to read as quint8
fixed
where fixed
prefix means fixed number of bytes to write
QByteArray
, they must be encoded: https://doc.qt.io/qt-5/qtextcodec.htmlQByteArray
<debug/>
realization of IByteHandler
shall not alter any datafinally, think about to add <struct/>
as sub-element into a <struct/>
so that the parser structures the data better
Todo