rapidyaml  0.8.0
parse and emit YAML, and do it fast
c4::yml::ParserState Struct Reference

#include <parser_state.hpp>

Inheritance diagram for c4::yml::ParserState:
c4::yml::EventHandlerTreeState c4::yml::EventHandlerYamlStdState

Public Member Functions

 ParserState ()=default
 
void start_parse (const char *file, id_type node_id_)
 
void reset_after_push ()
 
void reset_before_pop (ParserState const &to_pop)
 
bool at_line_beginning () const noexcept
 
bool indentation_eq () const noexcept
 
bool indentation_ge () const noexcept
 
bool indentation_gt () const noexcept
 
bool indentation_lt () const noexcept
 

Public Attributes

LineContents line_contents
 
Location pos
 
ParserFlag_t flags
 
size_t indref
 the reference indentation in the current block scope More...
 
id_type level
 
id_type node_id
 don't hold a pointer to the node as it will be relocated during tree resizes More...
 
size_t scalar_col
 
bool more_indented
 
bool has_children
 

Detailed Description

Definition at line 134 of file parser_state.hpp.

Constructor & Destructor Documentation

◆ ParserState()

c4::yml::ParserState::ParserState ( )
default

Member Function Documentation

◆ start_parse()

void c4::yml::ParserState::start_parse ( const char *  file,
id_type  node_id_ 
)
inline

Definition at line 148 of file parser_state.hpp.

149  {
150  level = 0;
151  pos.name = to_csubstr(file);
152  pos.offset = 0;
153  pos.line = 1;
154  pos.col = 1;
155  node_id = node_id_;
156  more_indented = false;
157  scalar_col = 0;
158  indref = 0;
159  has_children = false;
160  }
csubstr to_csubstr(substr s) noexcept
neutral version for use in generic code
Definition: substr.hpp:2186
size_t col
column
Definition: common.hpp:303
size_t line
line
Definition: common.hpp:301
size_t offset
number of bytes from the beginning of the source buffer
Definition: common.hpp:299
csubstr name
file name
Definition: common.hpp:305
size_t indref
the reference indentation in the current block scope
id_type node_id
don't hold a pointer to the node as it will be relocated during tree resizes

References c4::yml::Location::col, has_children, indref, level, c4::yml::Location::line, more_indented, c4::yml::Location::name, node_id, c4::yml::Location::offset, pos, scalar_col, and c4::to_csubstr().

◆ reset_after_push()

void c4::yml::ParserState::reset_after_push ( )
inline

Definition at line 162 of file parser_state.hpp.

163  {
164  node_id = NONE;
165  indref = npos;
166  more_indented = false;
167  ++level;
168  has_children = false;
169  }
@ npos
a null string position
Definition: common.hpp:267
@ NONE
an index to none
Definition: common.hpp:260

References has_children, indref, level, more_indented, node_id, c4::yml::NONE, and c4::yml::npos.

◆ reset_before_pop()

void c4::yml::ParserState::reset_before_pop ( ParserState const &  to_pop)
inline

Definition at line 171 of file parser_state.hpp.

172  {
173  pos = to_pop.pos;
174  line_contents = to_pop.line_contents;
175  }
LineContents line_contents

References line_contents, and pos.

◆ at_line_beginning()

bool c4::yml::ParserState::at_line_beginning ( ) const
inlinenoexcept

Definition at line 179 of file parser_state.hpp.

180  {
181  return line_contents.rem.str == line_contents.full.str;
182  }
substr rem
the stripped line remainder; initially starts at the first non-space character
substr full
the full line, including newlines on the right

References c4::yml::LineContents::full, line_contents, and c4::yml::LineContents::rem.

◆ indentation_eq()

bool c4::yml::ParserState::indentation_eq ( ) const
inlinenoexcept

Definition at line 183 of file parser_state.hpp.

184  {
185  RYML_ASSERT(indref != npos);
187  }
size_t indentation
the number of spaces on the beginning of the line

References c4::yml::LineContents::indentation, indref, line_contents, and c4::yml::npos.

◆ indentation_ge()

bool c4::yml::ParserState::indentation_ge ( ) const
inlinenoexcept

Definition at line 188 of file parser_state.hpp.

189  {
190  RYML_ASSERT(indref != npos);
192  }

References c4::yml::LineContents::indentation, indref, line_contents, and c4::yml::npos.

◆ indentation_gt()

bool c4::yml::ParserState::indentation_gt ( ) const
inlinenoexcept

Definition at line 193 of file parser_state.hpp.

194  {
195  RYML_ASSERT(indref != npos);
197  }

References c4::yml::LineContents::indentation, indref, line_contents, and c4::yml::npos.

◆ indentation_lt()

bool c4::yml::ParserState::indentation_lt ( ) const
inlinenoexcept

Definition at line 198 of file parser_state.hpp.

199  {
200  RYML_ASSERT(indref != npos);
202  }

References c4::yml::LineContents::indentation, indref, line_contents, and c4::yml::npos.

Member Data Documentation

◆ line_contents

LineContents c4::yml::ParserState::line_contents

◆ pos

Location c4::yml::ParserState::pos

Definition at line 137 of file parser_state.hpp.

Referenced by reset_before_pop(), and start_parse().

◆ flags

ParserFlag_t c4::yml::ParserState::flags

Definition at line 138 of file parser_state.hpp.

◆ indref

size_t c4::yml::ParserState::indref

the reference indentation in the current block scope

Definition at line 139 of file parser_state.hpp.

Referenced by indentation_eq(), indentation_ge(), indentation_gt(), indentation_lt(), reset_after_push(), and start_parse().

◆ level

id_type c4::yml::ParserState::level

Definition at line 140 of file parser_state.hpp.

Referenced by reset_after_push(), and start_parse().

◆ node_id

id_type c4::yml::ParserState::node_id

don't hold a pointer to the node as it will be relocated during tree resizes

Definition at line 141 of file parser_state.hpp.

Referenced by reset_after_push(), and start_parse().

◆ scalar_col

size_t c4::yml::ParserState::scalar_col

Definition at line 142 of file parser_state.hpp.

Referenced by start_parse().

◆ more_indented

bool c4::yml::ParserState::more_indented

Definition at line 143 of file parser_state.hpp.

Referenced by reset_after_push(), and start_parse().

◆ has_children

bool c4::yml::ParserState::has_children

Definition at line 144 of file parser_state.hpp.

Referenced by reset_after_push(), and start_parse().


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