McStas Readout Master 0.3.3
Loading...
Searching...
No Matches
TypeDescriptionParser.h File Reference

Parser for C struct type descriptions into a runtime type schema. More...

#include <string>
#include <vector>
#include <stdexcept>
Include dependency graph for TypeDescriptionParser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SchemaField
 A single field in a parsed struct description. More...
 
class  TypeSchema
 Complete description of a parsed struct. More...
 
class  TypeDescriptionError
 Exception thrown for parse errors. More...
 

Functions

RL_API TypeSchema parse_type_description (const std::string &description)
 Parse a C struct type description string into a TypeSchema.
 

Detailed Description

Parser for C struct type descriptions into a runtime type schema.

Accepts valid C struct syntax, e.g.: "struct { int count; double energy; uint16_t values[10]; }" and produces a TypeSchema describing field names, types, offsets, and sizes.

Definition in file TypeDescriptionParser.h.

Macro Definition Documentation

◆ RL_API

#define RL_API

Definition at line 32 of file TypeDescriptionParser.h.

Function Documentation

◆ parse_type_description()

RL_API TypeSchema parse_type_description ( const std::string &  description)

Parse a C struct type description string into a TypeSchema.

Accepted formats: "struct { int x; double y; }" "struct name { int x; double y; }" "{ int x; double y; }" (struct keyword optional) "int x; double y;" (braces optional)

Supported types: char, short, int, long, long long (and unsigned variants) float, double int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t size_t

Static arrays supported: "int arr[10];" Pointers and nested structs are NOT supported.

Exceptions
TypeDescriptionErroron parse failure

Referenced by Collector::Collector().