wreport::buffers::CrexInput Struct Reference

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.
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.
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.
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.
void | read_word (char *buf, size_t len)
| Read a word into buf.
void | parse_value (int len, int is_signed, const char **d_start, const char **d_end)
| Parse a data value from the input buffer.
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).
size_t | offset
| File offset of the start of the message.
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.

## Detailed Description

Text input buffer.

## Constructor & Destructor Documentation

## CrexInput()

wreport::buffers::CrexInput::CrexInput | ( | const std::string & | in,
|  | const char * | fname,
|  | size_t | offset )

Wrap a string into a CrexInput.

Parameters

  in | The string with the data to read

References fname, and offset.

## Member Function Documentation

## check_available_data()

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.

Parameters

  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

References check_available_data().

Referenced by check_available_data().

## check_eof()

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.

Parameters

  expected | name of what we are about to decode, used for generating nice error messages

References check_eof().

Referenced by check_eof().

## mark_section_start()

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.

References mark_section_start().

Referenced by mark_section_start().

## parse_value()

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.

Parameters

  len | Length in characters of the value to parse
  is_signed | True if the value can be preceded by a + or - sign

Return values

  d_start | Start of the parsed token
  d_end | End of the parsed token

References parse_value().

Referenced by parse_value().

## read_word()

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.

Parameters

  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.

References read_word().

Referenced by read_word().

## Field Documentation

## fname

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.

Referenced by CrexInput().

## offset

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.

Referenced by CrexInput().

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

- crex.h