|
libwreport
3.29
|
Text input buffer. More...
#include <crex.h>
Public Member Functions | |
| CrexInput (const std::string &in, const char *fname, size_t offset) | |
| Wrap a string into a CrexInput. More... | |
| bool | eof () const |
| Return true if the cursor is at the end of the buffer. | |
| unsigned | remaining () const |
| Return the number of remaining characters until the end of the buffer. | |
| void | parse_error (const char *fmt,...) const WREPORT_THROWF_ATTRS(2 |
| Throw an error_parse at the current decoding location. | |
| void void | check_eof (const char *expected) const |
| Check if the decoding cursor has reached the end of buffer, throw error_parse otherwise. More... | |
| void | check_available_data (unsigned datalen, const char *expected) const |
| Check that the input buffer contains at least datalen characters after the cursor, throw error_parse otherwise. More... | |
| void | skip_spaces () |
| Move the cursor to the next non-space character. | |
| void | skip_data_and_spaces (unsigned datalen) |
| Skip datalen characters and all spaces after them. | |
| void | mark_section_start (unsigned num) |
| Mark the start of the given section. More... | |
| void | read_word (char *buf, size_t len) |
| Read a word into buf. More... | |
| void | parse_value (int len, int is_signed, const char **d_start, const char **d_end) |
| Parse a data value from the input buffer. More... | |
| void | debug_dump_next (const char *desc) const |
| Dump to stderr the contents of the next bit of buffer. | |
Data Fields | |
| const char * | data |
| Input buffer. | |
| size_t | data_len |
| Input buffer size. | |
| const char * | fname |
| Input file name (optional). More... | |
| size_t | offset |
| File offset of the start of the message. More... | |
| unsigned | sec [5] |
| Character offsets of the starts of CREX sections. | |
| const char * | cur |
| Cursor inside in.data() used for decoding. | |
| int | has_check_digit |
| True if the CREX message uses the check digit feature. | |
| int | expected_check_digit |
| Value of the next expected check digit. | |
Text input buffer.
| wreport::buffers::CrexInput::CrexInput | ( | const std::string & | in, |
| const char * | fname, | ||
| size_t | offset | ||
| ) |
Wrap a string into a CrexInput.
| in | The string with the data to read |
| void wreport::buffers::CrexInput::check_available_data | ( | unsigned | datalen, |
| const char * | expected | ||
| ) | const |
Check that the input buffer contains at least datalen characters after the cursor, throw error_parse otherwise.
| datalen | number of bytes expected to still be available at the current location |
| expected | name of what we are about to decode, used for generating nice error messages |
| void void wreport::buffers::CrexInput::check_eof | ( | const char * | expected | ) | const |
Check if the decoding cursor has reached the end of buffer, throw error_parse otherwise.
| expected | name of what we are about to decode, used for generating nice error messages |
| void wreport::buffers::CrexInput::mark_section_start | ( | unsigned | num | ) |
Mark the start of the given section.
This sets sec[num] to the position pointed by the current cursor, and throws error_parse if the section starts at the end of the buffer.
There is no need to mark the start of section 0, as it is always at offset 0.
| void wreport::buffers::CrexInput::parse_value | ( | int | len, |
| int | is_signed, | ||
| const char ** | d_start, | ||
| const char ** | d_end | ||
| ) |
Parse a data value from the input buffer.
| len | Length in characters of the value to parse |
| is_signed | True if the value can be preceded by a + or - sign |
| d_start | Start of the parsed token |
| d_end | End of the parsed token |
| void wreport::buffers::CrexInput::read_word | ( | char * | buf, |
| size_t | len | ||
| ) |
Read a word into buf.
A word ends at the first whitespace or at the end of buffer.
Whitespace after the word is skipped.
| buf | The buffer that will hold the word. It will always be zero-terminated. |
| len | Length of the buffer. Since the buffer will always be zero-terminated, the word will be at most len-1 characters long. |
| const char* wreport::buffers::CrexInput::fname |
Input file name (optional).
If available, it will be used to generate better error messages.
If not available, it is NULL.
| size_t wreport::buffers::CrexInput::offset |
File offset of the start of the message.
If available, it will be used to generate better error messages.
If not available, it is 0.