libsdfio 1.0.0
Reader and writer for ISO 25178-71 SDF surface data files in C
Loading...
Searching...
No Matches
trailer.h File Reference

Parsing of the fields of a trailer text. More...

#include <sdfio/sdfio_export.h>
#include <stdbool.h>
#include <stddef.h>

Go to the source code of this file.

Functions

bool sdfio_trailer_next_field (const char *text, size_t size, size_t *position, size_t *name_at, size_t *name_size, size_t *value_at, size_t *value_size)
 Finds the next field of a trailer text, a line of the form Name = Value, which ISO-2.0 expects.
bool sdfio_trailer_find_field (const char *text, size_t size, const char *name, size_t *value_at, size_t *value_size)
 Finds the value of the field of a name in a trailer text.

Detailed Description

Parsing of the fields of a trailer text.

Function Documentation

◆ sdfio_trailer_find_field()

bool sdfio_trailer_find_field ( const char * text,
size_t size,
const char * name,
size_t * value_at,
size_t * value_size )

Finds the value of the field of a name in a trailer text.

The name is compared without regard to case, as the standard has it for field names. If the text has several fields of the name, the first one counts. The rules of sdfio_trailer_next_field() apply.

Parameters
[in]textThe text of the trailer.
sizeThe length of the text in bytes.
[in]nameThe name of the field.
[out]value_atReceives the offset of the value from the start of text, or 0 if there is no such field.
[out]value_sizeReceives the length of the value, or 0.
Returns
True if the field was found. False if there is none, or if a pointer is null.
Examples
read_heights.c.

◆ sdfio_trailer_next_field()

bool sdfio_trailer_next_field ( const char * text,
size_t size,
size_t * position,
size_t * name_at,
size_t * name_size,
size_t * value_at,
size_t * value_size )

Finds the next field of a trailer text, a line of the form Name = Value, which ISO-2.0 expects.

The text is the text that sdfio_read_trailer() returned, or any text with LF or CRLF as line ends. The lines that are not fields are skipped.

The name consists of letters, digits and _. White space around the name, the separator and the value is not part of them. A value ends at the end of the line, so it can contain =, and it can be empty. The name and the value are given as offsets from the start of text and as lengths, so the bytes are text + name_at and text + value_at. The text is bytes, not terminated, and its encoding is not checked.

Parameters
[in]textThe text of the trailer.
sizeThe length of the text in bytes.
[in,out]positionThe offset of the line to start with: 0 for the start of the text. The function sets it behind the line that it found, so the next call continues there.
[out]name_atReceives the offset of the name.
[out]name_sizeReceives the length of the name.
[out]value_atReceives the offset of the value.
[out]value_sizeReceives the length of the value.
Returns
True if a field was found. False at the end of the text, or if a pointer is null.
Examples
read_heights.c.