Class PrimaryParser

Inheritance Relationships

Base Type

Class Documentation

class PrimaryParser : public urcl::comm::Parser<PrimaryPackage>

The primary specific parser. Interprets a given byte stream as serialized primary packages and parses it accordingly.

Public Functions

PrimaryParser() = default
virtual ~PrimaryParser() = default
inline void setStrictMode(bool strict_mode)

Set the strict mode for parsing. If strict mode is enabled, the parser will throw an exception if a sub-package is not parsed completely. If strict mode is disabled, the parser will just log a warning and continue parsing the next sub-package.

!

Strict mode is meant for testing only, as it may break existing applications when running against a newer software version that adds new fields to existing packages, which would lead to parsing errors of the respective sub-package.

Parameters:

strict_mode – Whether to enable strict mode or not.

inline bool parse(comm::BinParser &bp, std::vector<std::unique_ptr<PrimaryPackage>> &results) override

Uses the given BinParser to create package objects from the contained serialization.

Parameters:
  • bp – A BinParser holding one or more serialized primary packages

  • results – A vector of pointers to created primary package objects

Returns:

True, if the byte stream could successfully be parsed as primary packages, false otherwise

inline bool parse(comm::BinParser &bp, std::unique_ptr<PrimaryPackage> &results) override

Uses the given BinParser to create a single package object from the contained serialization.

Note: This function assumes that the byte stream contains exactly one primary package. For packages with sub-packages this will return false.

Parameters:
  • bp – A BinParser holding one serialized primary package

  • results – A unique pointer to hold the created primary package object

Returns:

True, if the byte stream could successfully be parsed as a primary package, false otherwise