rapidyaml  0.16.0
parseandemitYAML,anddoitfast
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::EventHandlerInts > parser
 

Detailed Description

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

Constructor & Destructor Documentation

IntsParser::IntsParser ( )
inlinenoexcept

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

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

Member Function Documentation

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

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

Referenced by main().

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  }
void reset(substr str, substr arena, ievt::evt_bits *dst, evt_size dst_size)
std::vector< evt_bits > events
result buffer with events
c4::yml::extra::EventHandlerInts handler
substr to_substr(char(&s)[N]) noexcept
Definition: substr.hpp:2376
bool fits_buffers() const
Predicate to test if the event and arena buffers successfully accomodated all the parse events...
void parse_in_place_ev(csubstr filename, substr src)
parse YAML in place, emitting events to the current handler
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)
int32_t evt_size
data type for integer events size.
c4::yml::ParseEngine< c4::yml::extra::EventHandlerInts > parser
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.

Referenced by main().

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)
c4::yml::extra::EventHandlerInts handler
void reset_yaml(c4::csubstr yaml_)
substr to_substr(char(&s)[N]) noexcept
Definition: substr.hpp:2376
void resize_buffers(c4::yml::extra::evt_size esz, size_t arena_size)
std::vector< char > yaml
source buffer

Member Data Documentation

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

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

Referenced by main().

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


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