rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
IntsParser Struct Reference

Public Member Functions

 IntsParser () noexcept
bool parse_in_place (const char *filename, c4::substr yaml, IntsResult *result)
bool parse_or_resize_and_then_parse (const char *filename, c4::csubstr yaml, IntsResult *result)

Public Attributes

c4::yml::extra::EventHandlerInts handler
c4::yml::ParseEngine< c4::yml::extra::EventHandlerIntsparser

Detailed Description

Definition at line 49 of file quickstart-ints.cpp.

Constructor & Destructor Documentation

◆ IntsParser()

IntsParser::IntsParser ( )
inlinenoexcept

Definition at line 54 of file quickstart-ints.cpp.

54: handler(), parser(&handler) {}
c4::yml::ParseEngine< c4::yml::extra::EventHandlerInts > parser
c4::yml::extra::EventHandlerInts handler

Member Function Documentation

◆ parse_in_place()

bool IntsParser::parse_in_place ( const char * filename,
c4::substr yaml,
IntsResult * result )
inline

Definition at line 56 of file quickstart-ints.cpp.

57 {
58 handler.reset(yaml, c4::to_substr(result->arena),
59 result->events.data(), static_cast<c4::yml::extra::evt_size>(result->events.size()));
60 parser.parse_in_place_ev(filename, yaml); // we're parsing in place on the original YAML
61 // the YAML was successfully parsed, but it may happen that it
62 // requires more events than may fit in the buffers. so we
63 // need to check that it actually fits (this is mandatory):
64 if(handler.fits_buffers())
65 result->resize_buffers(handler); // trim the events buffer to the required size
66 return handler.fits_buffers();
67 }
int32_t evt_size
data type for integer events size.
substr to_substr(char(&s)[N]) noexcept
Definition substr.hpp:2376
std::vector< evt_bits > events
result buffer with events
std::vector< char > arena
arena to place out-of-source filtered scalars or tags
void resize_buffers(c4::yml::extra::evt_size esz, size_t arena_size)

Referenced by parse_or_resize_and_then_parse().

◆ parse_or_resize_and_then_parse()

bool IntsParser::parse_or_resize_and_then_parse ( const char * filename,
c4::csubstr yaml,
IntsResult * result )
inline

Definition at line 69 of file quickstart-ints.cpp.

70 {
71 // the buffer is not mutable. we'll need to parse a copy
72 result->reset_yaml(yaml);
73 // attempt the parse
74 if(this->parse_in_place(filename, c4::to_substr(result->yaml), result))
75 return true;
76 // events or arena buffers were too small. need to resize and parse again.
77 result->resize_buffers(handler);
78 // copy the source again! we need to do this because the
79 // buffer was parsed in place, and may have been modified
80 // during the parse.
81 result->reset_yaml(yaml);
82 // parse again!
83 return this->parse_in_place(filename, c4::to_substr(result->yaml), result);
84 }
bool parse_in_place(const char *filename, c4::substr yaml, IntsResult *result)
std::vector< char > yaml
source buffer
void reset_yaml(c4::csubstr yaml_)

Member Data Documentation

◆ handler

c4::yml::extra::EventHandlerInts IntsParser::handler

Definition at line 51 of file quickstart-ints.cpp.

Referenced by IntsParser(), parse_in_place(), and parse_or_resize_and_then_parse().

◆ parser

Definition at line 52 of file quickstart-ints.cpp.

Referenced by IntsParser(), and parse_in_place().


The documentation for this struct was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/latest/samples/quickstart-ints.cpp