JayBeams
0.1
Another project to have fun coding.
|
A helper type to define short (and fixed sized) string fields. More...
#include <short_string_field.hpp>
Public Types | |
typedef value_validator | value_validator_t |
The type of validator. More... | |
Public Member Functions | |
short_string_field (value_validator_t const &validator=value_validator_t()) | |
Constructor. More... | |
short_string_field (std::string const &rhs, value_validator_t const &validator=value_validator_t()) | |
Constructor from a std::string. More... | |
char const * | c_str () const |
Return the C-string representation. More... | |
Base comparison operators | |
bool | operator== (short_string_field const &rhs) const |
compare vs another short_string_field More... | |
bool | operator< (short_string_field const &rhs) const |
compare vs another short_string_field More... | |
bool | operator== (char const *rhs) const |
compare vs a C string More... | |
bool | operator< (char const *rhs) const |
compare vs a C string More... | |
default assignment and copy operators | |
short_string_field (short_string_field const &rhs)=default | |
short_string_field (short_string_field &&rhs)=default | |
short_string_field & | operator= (short_string_field const &rhs)=default |
short_string_field & | operator= (short_string_field &&rhs)=default |
Static Public Attributes | |
static constexpr std::size_t | wire_size = wire_size_value |
The size of the field on the wire. More... | |
static constexpr std::size_t | buffer_size = jb::p2ceil(wire_size_value) |
The size of the field in memory. More... | |
Private Member Functions | |
void | assign (char const *buf) |
Assignment from a character buffer. More... | |
void | nul_terminate () |
NUL terminate the string. More... | |
void | validate () const |
Validate the value using the functor. More... | |
Private Attributes | |
char | buffer_ [buffer_size] |
The in-memory representation. More... | |
value_validator_t | value_validator_ |
The validator. More... | |
Friends | |
struct | jb::itch5::decoder< true, short_string_field > |
struct | jb::itch5::decoder< false, short_string_field > |
A helper type to define short (and fixed sized) string fields.
The ITCH-5.0 protocol uses many fields that are short strings, that is, fixed-length alpha numeric fields. While it is normally easy to treat these fields as character strings, the fields may not be NUL terminated. In fact, the protocol spec specifically states that the fields will be left justified, and padded with spaces.
We want an in-memory representation that is NUL terminated (for compatibility with all the C/C++ libraries), and we do not wish to allocate memory for these fields (as we would do if we used std::string).
wire_size_value | the size of the field on the wire, in bytes. |
value_validator | a functor to validate the value for those fields that are only supposed to assume a known set of values. |
Definition at line 39 of file short_string_field.hpp.
typedef value_validator jb::itch5::short_string_field< wire_size_value, value_validator >::value_validator_t |
The type of validator.
Definition at line 56 of file short_string_field.hpp.
|
inlineexplicit |
Constructor.
Definition at line 59 of file short_string_field.hpp.
Referenced by jb::itch5::short_string_field< 8 >::operator<().
|
inlineexplicit |
Constructor from a std::string.
Definition at line 66 of file short_string_field.hpp.
|
default |
|
default |
|
inlineprivate |
Assignment from a character buffer.
Definition at line 117 of file short_string_field.hpp.
Referenced by jb::itch5::decoder< validate, short_string_field< wsize, F > >::r().
|
inline |
Return the C-string representation.
Definition at line 76 of file short_string_field.hpp.
Referenced by jb::itch5::hash_value().
|
inlineprivate |
NUL terminate the string.
Definition at line 123 of file short_string_field.hpp.
Referenced by jb::itch5::short_string_field< 8 >::assign(), and jb::itch5::short_string_field< 8 >::short_string_field().
|
inline |
compare vs another short_string_field
Definition at line 90 of file short_string_field.hpp.
|
inline |
compare vs a C string
Definition at line 100 of file short_string_field.hpp.
|
default |
Referenced by jb::itch5::short_string_field< 8 >::operator<().
|
default |
|
inline |
compare vs another short_string_field
Definition at line 85 of file short_string_field.hpp.
|
inline |
compare vs a C string
Definition at line 95 of file short_string_field.hpp.
|
inlineprivate |
Validate the value using the functor.
enabled | if false, disable all validation |
Definition at line 144 of file short_string_field.hpp.
Referenced by jb::itch5::decoder< validate, short_string_field< wsize, F > >::r().
|
friend |
Definition at line 115 of file short_string_field.hpp.
|
friend |
Definition at line 114 of file short_string_field.hpp.
|
private |
The in-memory representation.
Definition at line 152 of file short_string_field.hpp.
Referenced by jb::itch5::short_string_field< 8 >::assign(), jb::itch5::short_string_field< 8 >::c_str(), jb::itch5::short_string_field< 8 >::nul_terminate(), jb::itch5::short_string_field< 8 >::operator<(), jb::itch5::short_string_field< 8 >::operator==(), jb::itch5::short_string_field< 8 >::short_string_field(), and jb::itch5::short_string_field< 8 >::validate().
|
static |
The size of the field in memory.
Definition at line 53 of file short_string_field.hpp.
|
private |
The validator.
Definition at line 155 of file short_string_field.hpp.
Referenced by jb::itch5::short_string_field< 8 >::validate().
|
static |
The size of the field on the wire.
Definition at line 50 of file short_string_field.hpp.
Referenced by jb::itch5::short_string_field< 8 >::nul_terminate(), and jb::itch5::short_string_field< 8 >::short_string_field().