artromone / Single-thread-byte-converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Single thread byte converter

    ByteConverter Class

The ByteConverter class represents a converter for byte data into string values based on their type and data.

    Public Methods

  • ByteConverter(Source *source, Sink *sink): Class constructor. Takes pointers to Source and Sink objects and creates an instance of the ByteConverter class.
  • void start(): Starts the process of byte data conversion. Creates a new execution thread and calls the run() method.
  • void stop(): Stops the process of byte data conversion. Sets the isRunning_ flag to false and waits for the execution thread to finish.

    Private Methods

  • void run(): Method that performs the byte data conversion process. In a loop, it checks for data availability in the source, reads the next byte, converts it into a string value, and writes it to the Sink. In case of an error, it outputs an error message to the standard error stream.

    Sink Class

The Sink class represents an interface for writing data.

    Public Methods

  • virtual void writeData(const std::string &data) = 0: Virtual method for writing data. Takes a string data to be written.

    Source Class

The Source class represents an interface for retrieving data.

    Public Methods

  • virtual bool hasDataNext() const = 0: Virtual method for checking if there is more data available. Returns true if there is data to read, and false otherwise.
  • virtual std::uint8_t read() = 0: Virtual method for reading the next byte of data. Returns the read byte.

About


Languages

Language:C++ 89.9%Language:Python 6.9%Language:CMake 1.1%Language:C 0.9%Language:Starlark 0.8%Language:Shell 0.2%Language:SCSS 0.1%Language:HTML 0.1%Language:Batchfile 0.0%