|
DUDS
|
Distributed Update of Data from Something
|
Holds a conversation part inside a vector. More...
#include <ConversationVector.hpp>
Classes | |
| struct | BigEndian |
| Use with the insertion operator to specify big-endian data will follow. More... | |
| struct | FixedLength |
| Used as a parameter to constructors to specify that communication will not change the length of the conversation part. More... | |
| struct | Input |
| Used as a parameter to constructors to specify an input conversation part. More... | |
| struct | LittleEndian |
| Use with the insertion operator to specify little-endian data will follow. More... | |
| struct | Output |
| Used as a parameter to constructors to specify an output conversation part. More... | |
| struct | Reserve |
| Use with the insertion operator to reserve space in the vector. More... | |
| struct | VaribleLength |
| Used as a parameter to constructors to specify that communication may change the length of the part. More... | |
Public Member Functions | |
| ConversationVector (const ConversationVector &)=default | |
| Copies are OK. More... | |
| ConversationVector (Input) | |
| Construct for fixed-length input without allocating space for the input. More... | |
| ConversationVector (Output) | |
| Construct for output. More... | |
| ConversationVector (bool input) | |
| Construct for either output or fixed-length input. More... | |
| ConversationVector (const std::vector< char > &v) | |
| Construct for output and copy the given vector into this object. More... | |
| ConversationVector (std::vector< char > &&v) | |
| Construct for output and move the given vector into this object. More... | |
| ConversationVector (std::size_t length, FixedLength) | |
| Construct for fixed-length input and allocate space for the input. More... | |
| ConversationVector (std::size_t length, VaribleLength) | |
| Construct for variable-length input and allocate space for the input. More... | |
| ConversationVector (std::size_t length, bool varlen=false) | |
| Construct for fixed or variable-length input and allocate space for the input. More... | |
| ConversationVector (std::size_t length, Output) | |
| Construct for output and reserve the given length within the internal vector. More... | |
| void | add (char i) |
| Adds a byte to an output part. More... | |
| template<typename Int > | |
| void | add (Int i) |
| Adds an integer to the end an output part. More... | |
| void | add (const std::string &str) |
| Adds a string as binary data to the end an output part. More... | |
| void | add (std::int8_t *a, std::size_t l) |
| Adds binary data to the end of an output part. More... | |
| template<std::size_t N> | |
| void | add (std::int8_t(&a)[N]) |
| Adds an array to the end an output part. More... | |
| template<typename Int > | |
| void | add (const Int *a, std::size_t count) |
| Adds an array of integers to the end of an output part. More... | |
| template<typename Int , std::size_t N> | |
| void | add (const Int(&a)[N]) |
| Adds an array of integers to the end of an output part. More... | |
| template<typename Int > | |
| void | addBe (Int i) |
| Adds an integer in big-endian form to an output part. More... | |
| void | addBe (std::int8_t i) |
| Adds a byte to an output part. More... | |
| template<typename Int > | |
| void | addBe (const Int *a, std::size_t count) |
| Adds an array of integers to the end of an output part in big-endian form. More... | |
| template<typename Int , std::size_t N> | |
| void | addBe (const Int(&a)[N]) |
| Adds an array of integers to the end of an output part in big-endian form. More... | |
| template<typename Int > | |
| void | addLe (Int i) |
| Adds an integer in little-endian form to an output part. More... | |
| void | addLe (std::int8_t i) |
| Adds a byte to an output part. More... | |
| template<typename Int > | |
| void | addLe (const Int *a, std::size_t count) |
| Adds an array of integers to the end of an output part in little-endian form. More... | |
| template<typename Int , std::size_t N> | |
| void | addLe (const Int(&a)[N]) |
| Adds an array of integers to the end of an output part in little-endian form. More... | |
| std::vector< char >::const_iterator | begin () const |
| Begining iterator to inspect the contained data. More... | |
| std::vector< char >::const_iterator | end () const |
| Ending iterator to inspect the contained data. More... | |
| virtual std::size_t | length () const |
| Returns the length of the buffer following the start pointer. More... | |
| void | reserve (std::size_t len) |
| Reserves space in the internal vector. More... | |
| void | setLength (std::size_t len) |
| Sets a new length, including the data prior to the start pointer, for a conversation part with a varying length. More... | |
| void | setStartOffset (std::int16_t offset) |
| Sets a new start offset, in bytes, for a variable length input part. More... | |
| virtual char * | start () const |
| Returns a pointer to the begining of the conversation part's buffer. More... | |
Public Member Functions inherited from duds::hardware::interface::ConversationPart | |
| ConversationPart (const ConversationPart &)=default | |
| Copies are OK. More... | |
| virtual | ~ConversationPart () |
| bool | bigEndian () const |
| True if this part is flagged as having data in big-endian form. More... | |
| ConversationPart & | bigEndian (bool big) |
| Changes the flagged endianess of this part. More... | |
| ConversationPart & | breakBefore () |
| Flags the conversation part to have a break before this part is sent. More... | |
| bool | extract () const |
| True if this part is flagged for extraction by ConversationExtractor. More... | |
| ConversationPart & | extract (bool ex) |
| Changes the extraction flag for this part. More... | |
| Flags | flags () const |
| Returns the flags. More... | |
| bool | input () const |
| True if this part is flagged for input use. More... | |
| bool | littleEndian () const |
| True if this part is flagged as having data in little-endian form. More... | |
| ConversationPart & | littleEndian (bool little) |
| Changes the flagged endianess of this part. More... | |
| bool | output () const |
| True if this part is flagged for output use. More... | |
| bool | varyingLength () const |
| True if this part is flagged as having a variable length. More... | |
Private Attributes | |
| std::vector< char > | data |
| The internal buffer. More... | |
Related Functions | |
(Note that these are not member functions.) | |
| template<typename Int > | |
| ConversationVector & | operator<< (ConversationVector &cv, const Int &i) |
| Insertion operator to add an integer to a ConversationVector object. More... | |
| template<typename Int , std::size_t N> | |
| ConversationVector & | operator<< (ConversationVector &cv, const Int(&a)[N]) |
| Insertion operator to add an array of integers to a ConversationVector object. More... | |
| ConversationVector & | operator<< (ConversationVector &cv, const ConversationVector::Reserve &cvr) |
| Insertion operator to reserve space in a ConversationVector. More... | |
| ConversationVector & | operator<< (ConversationVector &cv, const ConversationVector::BigEndian) |
| Insertion operator to make the ConversationVector handle any following adds using big-endian format. More... | |
| ConversationVector & | operator<< (ConversationVector &cv, const ConversationVector::LittleEndian) |
| Insertion operator to make the ConversationVector handle any following adds using little-endian format. More... | |
| ConversationVector & | operator<< (ConversationVector &cv, const std::string &str) |
| Insertion operator to add a string as binary data to the end of an output ConversationVector. More... | |
Additional Inherited Members | |
Public Types inherited from duds::hardware::interface::ConversationPart | |
| typedef duds::general::BitFlags< struct ConversationPartFlags, std::uint16_t > | Flags |
| The type used to store flags that modify the operation of the classes derived from this class, or how the objects are used. More... | |
Static Public Attributes inherited from duds::hardware::interface::ConversationPart | |
| static constexpr Flags | MpfBigendian = Flags::Bit(3) |
| True/set to expect data to be big-endian. More... | |
| static constexpr Flags | MpfBreak = Flags::Bit(4) |
| True/set to indicate that any kind of selection signal should be toggled, or a stop condition should occur, before communicating the part with this flag. More... | |
| static constexpr Flags | MpfExtract = Flags::Bit(1) |
| True/set to extract message part contents with the ConversationExtractor. More... | |
| static constexpr Flags | MpfInput = Flags::Bit(0) |
| True/set for input; false for output. More... | |
| static constexpr Flags | MpfVarlen = Flags::Bit(2) |
| True/set for a varying length; valid only for input. More... | |
Protected Member Functions inherited from duds::hardware::interface::ConversationPart | |
| ConversationPart (Flags f) | |
| Construct with the given flags. More... | |
| ConversationPart (Flags f, std::int16_t v) | |
| Construct with the given flags and an initial value for val16. More... | |
Protected Attributes inherited from duds::hardware::interface::ConversationPart | |
| std::int16_t | val16 |
| A small integer for derived classes to use. More... | |
Holds a conversation part inside a vector.
Output data can be placed in the part using the various add() functions. Templates are used to avoid the need to specify the data size when arrays are used. addBe() functions will put the given data in big-endian form, while addLe() functions will use little-endian. Other add functions will use the endianess indicated in the part flags (ConversationPart::flags()). None of the add functions modify the endianess flag. The default endianess is little-endian.
The insertion operator is defined for this class and uses the add functions. It is also defined to use structs within this class to modify the part in other ways. The BigEndian struct will set the big-endian flag and affect data added later using means other than the addLe() functions. LittleEndian does the same, but selects little-endian data. The Reserve struct will cause reserve() to be called.
Variable length inputs are implemented by allowing resizing of the internal vector. The start pointer can be offset from the start of the vector using setStartOffset(). The offset is stored in val16. This allows input using a large enough vector (defined by communication protocol) that starts with the size of the input.
Definition at line 64 of file ConversationVector.hpp.
|
default |
Copies are OK.
|
inline |
Construct for fixed-length input without allocating space for the input.
Definition at line 102 of file ConversationVector.hpp.
|
inline |
Construct for output.
Definition at line 106 of file ConversationVector.hpp.
|
inline |
Construct for either output or fixed-length input.
| input | True for input. |
Definition at line 111 of file ConversationVector.hpp.
|
inline |
Construct for output and copy the given vector into this object.
Definition at line 117 of file ConversationVector.hpp.
|
inline |
Construct for output and move the given vector into this object.
Definition at line 122 of file ConversationVector.hpp.
|
inline |
Construct for fixed-length input and allocate space for the input.
| length | The number of bytes to allocate for the input. |
Definition at line 130 of file ConversationVector.hpp.
|
inline |
Construct for variable-length input and allocate space for the input.
| length | The number of bytes to allocate for the input. It should be the maximum size possible for the input. |
Definition at line 139 of file ConversationVector.hpp.
|
inline |
Construct for fixed or variable-length input and allocate space for the input.
| length | The number of bytes to allocate for the input. |
| varlen | True for a variable-length input; false for fixed-length. |
Definition at line 149 of file ConversationVector.hpp.
|
inline |
Construct for output and reserve the given length within the internal vector.
| length | The number of bytes to reserve. |
Definition at line 159 of file ConversationVector.hpp.
| void duds::hardware::interface::ConversationVector::add | ( | char | i | ) |
Adds a byte to an output part.
| i | The character to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 15 of file ConversationVector.cpp.
Referenced by duds::hardware::interface::operator<<().
|
inline |
Adds an integer to the end an output part.
The endianess is chosen based on the part's MpfBigendian flag.
| Int | The integer type. |
| i | The integer value to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 243 of file ConversationVector.hpp.
| void duds::hardware::interface::ConversationVector::add | ( | const std::string & | str | ) |
Adds a string as binary data to the end an output part.
| str | The string to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 22 of file ConversationVector.cpp.
| void duds::hardware::interface::ConversationVector::add | ( | std::int8_t * | a, |
| std::size_t | l | ||
| ) |
Adds binary data to the end of an output part.
| a | The start of the binary data to add to the end of the part. |
| l | The number of bytes to copy. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 29 of file ConversationVector.cpp.
|
inline |
Adds an array to the end an output part.
| N | The length of the array. |
| a | The array to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 270 of file ConversationVector.hpp.
|
inline |
Adds an array of integers to the end of an output part.
The endianess is chosen based on the part's MpfBigendian flag.
| Int | The integer type. |
| a | The start of the array to add to the end of the part. |
| count | The number of items to copy. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 354 of file ConversationVector.hpp.
|
inline |
Adds an array of integers to the end of an output part.
The endianess is chosen based on the part's MpfBigendian flag.
| Int | The integer type. |
| N | The length of the array. |
| a | The array to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 370 of file ConversationVector.hpp.
|
inline |
Adds an integer in big-endian form to an output part.
| Int | The integer type. |
| i | The integer value to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 206 of file ConversationVector.hpp.
|
inline |
Adds a byte to an output part.
Avoids extra endian code in cases where template code is given a byte type as a parameter.
| i | The character to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 232 of file ConversationVector.hpp.
|
inline |
Adds an array of integers to the end of an output part in big-endian form.
| Int | The integer type. |
| a | The start of the array to add to the end of the part. |
| count | The number of items to copy. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 318 of file ConversationVector.hpp.
|
inline |
Adds an array of integers to the end of an output part in big-endian form.
| Int | The integer type. |
| N | The length of the array. |
| a | The array to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 342 of file ConversationVector.hpp.
|
inline |
Adds an integer in little-endian form to an output part.
| Int | The integer type. |
| i | The integer value to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 188 of file ConversationVector.hpp.
|
inline |
Adds a byte to an output part.
Avoids extra endian code in cases where template code is given a byte type as a parameter.
| i | The character to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 223 of file ConversationVector.hpp.
|
inline |
Adds an array of integers to the end of an output part in little-endian form.
| Int | The integer type. |
| a | The start of the array to add to the end of the part. |
| count | The number of items to copy. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 282 of file ConversationVector.hpp.
|
inline |
Adds an array of integers to the end of an output part in little-endian form.
| Int | The integer type. |
| N | The length of the array. |
| a | The array to add to the end of the part. |
| ConversationBadAdd | The part is flagged for input. |
Definition at line 306 of file ConversationVector.hpp.
|
inline |
Begining iterator to inspect the contained data.
Definition at line 166 of file ConversationVector.hpp.
|
inline |
Ending iterator to inspect the contained data.
Definition at line 172 of file ConversationVector.hpp.
|
virtual |
Returns the length of the buffer following the start pointer.
Implements duds::hardware::interface::ConversationPart.
Definition at line 62 of file ConversationVector.cpp.
| void duds::hardware::interface::ConversationVector::reserve | ( | std::size_t | len | ) |
Reserves space in the internal vector.
This can be used regardless of the part's flags, but makes much more sense for output parts.
Definition at line 54 of file ConversationVector.cpp.
Referenced by duds::hardware::interface::operator<<().
| void duds::hardware::interface::ConversationVector::setLength | ( | std::size_t | len | ) |
Sets a new length, including the data prior to the start pointer, for a conversation part with a varying length.
| len | The new length for the part. The offset value is not used in this operation. |
| ConversationFixedLength | This conversation part is not flagged as having a varying length. |
Definition at line 46 of file ConversationVector.cpp.
| void duds::hardware::interface::ConversationVector::setStartOffset | ( | std::int16_t | offset | ) |
Sets a new start offset, in bytes, for a variable length input part.
The pointer returned by start() will be offset bytes after the begining of the internal vector.
| offset | The number of bytes to reserve at the begining of the vector. It must be larger than the current size of the vector, and must not be negative. |
| ConversationBadOffset | The offset value was invalid. |
| ConversationFixedLength | This conversation part is not flagged as having a varying length. |
Definition at line 36 of file ConversationVector.cpp.
|
virtual |
Returns a pointer to the begining of the conversation part's buffer.
The return type is not const because use for input will require a write operation. The implementation must not make changes to the part object, so the function is const.
Implements duds::hardware::interface::ConversationPart.
Definition at line 58 of file ConversationVector.cpp.
|
related |
Insertion operator to add an integer to a ConversationVector object.
The endianess is specified by the part's MpfBigendian flag.
| Int | The integer type. |
| cv | The destination conversation part. |
| i | The integer to add to the end of cv. |
Definition at line 440 of file ConversationVector.hpp.
|
related |
Insertion operator to add an array of integers to a ConversationVector object.
The endianess is specified by the part's MpfBigendian flag.
| Int | The integer type. |
| N | The length of the array. |
| cv | The destination conversation part. |
| a | The array of integers to add to the end of cv. |
Definition at line 457 of file ConversationVector.hpp.
|
related |
Insertion operator to reserve space in a ConversationVector.
| cv | The conversation part to modify. |
| cvr | The object that specifies how much space to reserve. |
Definition at line 469 of file ConversationVector.hpp.
|
related |
Insertion operator to make the ConversationVector handle any following adds using big-endian format.
| cv | The conversation part to modify. |
Definition at line 484 of file ConversationVector.hpp.
|
related |
Insertion operator to make the ConversationVector handle any following adds using little-endian format.
| cv | The conversation part to modify. |
Definition at line 499 of file ConversationVector.hpp.
|
related |
Insertion operator to add a string as binary data to the end of an output ConversationVector.
| cv | The conversation part to modify. |
| str | The string to add. |
Definition at line 515 of file ConversationVector.hpp.
|
private |
The internal buffer.
Definition at line 68 of file ConversationVector.hpp.
Referenced by add(), length(), reserve(), setLength(), setStartOffset(), and start().