GM6000 Digital Heater Controller Branch: main
SDX-1330
List of all members | Public Member Functions
Cpl::Text::Frame::Encoder Class Referenceabstract

This class defines an interface for 'transmitted' (encoding) a frame. More...

Detailed Description

This class defines an interface for 'transmitted' (encoding) a frame.

What is a frame ? See the Decoder API for the detailed answer to this question. The Encoder interface will consume a raw sequence of characters and properly insert (when necessary) the framing characters to construct a valid frame. Below are some examples some framed sequences of characters:

Given:
    SOF:= '.'
    EOF:= ';'
    ESC:= '~'


Raw Stream      Encoded Sequence(s)
-----------     --------------------
"abcde"         ".abcde;"
"a"             ".a;"
""              ".;"
"a;bcd"         ";a~;bcd;"
"~"             ".~~;"
".abc"          "..abc;"


Notes:
    o The quotes (") in the above example are NOT part of the frame
      and/or character sequences - the quotes are only used to
      illustrate sets of characters.
    o The SOF character does not need to be escaped within a frame
      because once a SOF has been found - the SOF character is NOT
      looked/scanned for until after an EOF character has been
      detected.  Escaping an SOF character within a frame will
      behave as expected, i.e. same behavior/semantics as escaping
      the EOF character.

#include <Encoder.h>

Inheritance diagram for Cpl::Text::Frame::Encoder:
[legend]

Public Member Functions

virtual bool startFrame (void) noexcept=0
 Begins the frame.
 
virtual bool output (char src) noexcept=0
 Outputs the single character to the output destination.
 
virtual bool output (const char *src) noexcept=0
 Outputs the null terminated string to the output destination.
 
virtual bool output (const char *src, size_t numBytes) noexcept=0
 Outputs 'numBytes' of data (from 'src') to the output destination.
 
virtual bool endFrame (void) noexcept=0
 Ends the frame.
 
virtual ~Encoder ()
 Virtual Destructor.
 

Constructor & Destructor Documentation

◆ ~Encoder()

virtual Cpl::Text::Frame::Encoder::~Encoder ( )
inlinevirtual

Virtual Destructor.

Member Function Documentation

◆ endFrame()

virtual bool Cpl::Text::Frame::Encoder::endFrame ( void  )
pure virtualnoexcept

Ends the frame.

The method will return false if there an error occurred while writing to the output destination; else true is returned. If this method is called twice - without an intervening call to startFrame() - a Fatal error is generated

Implemented in Cpl::Text::Frame::BlockEncoder, and Cpl::Text::Frame::Encoder_.

◆ output() [1/3]

virtual bool Cpl::Text::Frame::Encoder::output ( char  src)
pure virtualnoexcept

Outputs the single character to the output destination.

The method will return false if there an error occurred while writing to the output destination; else true is returned. If this method is called without a previous call to startFrame(), i.e. the frame has NOT been started, a Fatal error is generated

Implemented in Cpl::Text::Frame::Encoder_.

◆ output() [2/3]

virtual bool Cpl::Text::Frame::Encoder::output ( const char *  src)
pure virtualnoexcept

Outputs the null terminated string to the output destination.

The method will return false if there an error occurred while writing to the output destination; else true is returned. If this method is called without a previous call to startFrame(), i.e. the frame has NOT been started, a Fatal error is generated

Implemented in Cpl::Text::Frame::Encoder_.

◆ output() [3/3]

virtual bool Cpl::Text::Frame::Encoder::output ( const char *  src,
size_t  numBytes 
)
pure virtualnoexcept

Outputs 'numBytes' of data (from 'src') to the output destination.

The method will return false if there an error occurred while writing to the output destination; else true is returned. If this method is called without a previous call to startFrame(), i.e. the frame has NOT been started, a Fatal error is generated

Implemented in Cpl::Text::Frame::Encoder_.

◆ startFrame()

virtual bool Cpl::Text::Frame::Encoder::startFrame ( void  )
pure virtualnoexcept

Begins the frame.

The method will return false if there an error occurred while writing to the output destination; else true is returned. If this method is called twice - without an intervening call to endFrame() - a Fatal error is generated

Implemented in Cpl::Text::Frame::Encoder_.


The documentation for this class was generated from the following file: