rapidyaml  0.16.0
parseandemitYAML,anddoitfast
c4::yml::ParserState Struct Reference

#include <parser_state.hpp>

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 at_first_token () const noexcept
 
bool indentation_eq () const noexcept
 
bool indentation_eq_extra () const noexcept
 
bool indentation_ge () const noexcept
 
bool indentation_ge_extra () const noexcept
 
bool indentation_gt () const noexcept
 
bool indentation_gt_extra () const noexcept
 
bool indentation_lt () const noexcept
 
bool indentation_lt_extra () 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 112 of file parser_state.hpp.

Constructor & Destructor Documentation

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

Member Function Documentation

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

Definition at line 126 of file parser_state.hpp.

127  {
128  level = 0;
129  pos.name = to_csubstr(file);
130  pos.offset = 0;
131  pos.line = 1;
132  pos.col = 1;
133  node_id = node_id_;
134  more_indented = false;
135  scalar_col = 0;
136  indref = 0;
137  has_children = false;
138  }
size_t offset
number of bytes from the beginning of the source buffer
Definition: common.hpp:230
size_t indref
the reference indentation in the current block scope
size_t col
column
Definition: common.hpp:232
csubstr name
name of the file
Definition: common.hpp:233
id_type node_id
don't hold a pointer to the node as it will be relocated during tree resizes
csubstr to_csubstr(const char(&s)[N]) noexcept
Definition: substr.hpp:2380
size_t line
line
Definition: common.hpp:231
void c4::yml::ParserState::reset_after_push ( )
inline

Definition at line 140 of file parser_state.hpp.

141  {
142  node_id = NONE;
143  indref = npos;
144  more_indented = false;
145  ++level;
146  has_children = false;
147  }
an index to none
Definition: common.hpp:131
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
a null string position
Definition: common.hpp:138
void c4::yml::ParserState::reset_before_pop ( ParserState const &  to_pop)
inline

Definition at line 149 of file parser_state.hpp.

150  {
151  pos = to_pop.pos;
152  line_contents = to_pop.line_contents;
153  }
LineContents line_contents
bool c4::yml::ParserState::at_line_beginning ( ) const
inlinenoexcept

Definition at line 157 of file parser_state.hpp.

158  {
160  }
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
LineContents line_contents
substr full
full line, including newline characters \n and \r
substr rem
current line remainder, without newline characters
bool c4::yml::ParserState::at_first_token ( ) const
inlinenoexcept

Definition at line 161 of file parser_state.hpp.

162  {
163  RYML_ASSERT_BASIC_(line_contents.indentation != npos);
164  return pos.col == line_contents.indentation + 1;
165  }
size_t col
column
Definition: common.hpp:232
LineContents line_contents
size_t indentation
number of spaces on the beginning of the line.
a null string position
Definition: common.hpp:138
bool c4::yml::ParserState::indentation_eq ( ) const
inlinenoexcept

Definition at line 166 of file parser_state.hpp.

167  {
168  RYML_ASSERT_BASIC_(indref != npos);
169  return line_contents.indentation != npos
171  }
size_t indref
the reference indentation in the current block scope
LineContents line_contents
size_t indentation
number of spaces on the beginning of the line.
a null string position
Definition: common.hpp:138
bool c4::yml::ParserState::indentation_eq_extra ( ) const
inlinenoexcept

Definition at line 172 of file parser_state.hpp.

173  {
174  RYML_ASSERT_BASIC_(indref != npos);
175  return line_contents.indentation != npos
176  && line_contents.indentation == indref + 1u;
177  }
size_t indref
the reference indentation in the current block scope
LineContents line_contents
size_t indentation
number of spaces on the beginning of the line.
a null string position
Definition: common.hpp:138
bool c4::yml::ParserState::indentation_ge ( ) const
inlinenoexcept

Definition at line 178 of file parser_state.hpp.

179  {
180  RYML_ASSERT_BASIC_(indref != npos);
181  return line_contents.indentation != npos
183  }
size_t indref
the reference indentation in the current block scope
LineContents line_contents
size_t indentation
number of spaces on the beginning of the line.
a null string position
Definition: common.hpp:138
bool c4::yml::ParserState::indentation_ge_extra ( ) const
inlinenoexcept

Definition at line 184 of file parser_state.hpp.

185  {
186  RYML_ASSERT_BASIC_(indref != npos);
187  return line_contents.indentation != npos
188  && line_contents.indentation >= indref + 1u;
189  }
size_t indref
the reference indentation in the current block scope
LineContents line_contents
size_t indentation
number of spaces on the beginning of the line.
a null string position
Definition: common.hpp:138
bool c4::yml::ParserState::indentation_gt ( ) const
inlinenoexcept

Definition at line 190 of file parser_state.hpp.

191  {
192  RYML_ASSERT_BASIC_(indref != npos);
193  return line_contents.indentation != npos
195  }
size_t indref
the reference indentation in the current block scope
LineContents line_contents
size_t indentation
number of spaces on the beginning of the line.
a null string position
Definition: common.hpp:138
bool c4::yml::ParserState::indentation_gt_extra ( ) const
inlinenoexcept

Definition at line 196 of file parser_state.hpp.

197  {
198  RYML_ASSERT_BASIC_(indref != npos);
199  return line_contents.indentation != npos
200  && line_contents.indentation > indref + 1u;
201  }
size_t indref
the reference indentation in the current block scope
LineContents line_contents
size_t indentation
number of spaces on the beginning of the line.
a null string position
Definition: common.hpp:138
bool c4::yml::ParserState::indentation_lt ( ) const
inlinenoexcept

Definition at line 202 of file parser_state.hpp.

203  {
204  RYML_ASSERT_BASIC_(indref != npos);
206  }
size_t indref
the reference indentation in the current block scope
LineContents line_contents
size_t indentation
number of spaces on the beginning of the line.
a null string position
Definition: common.hpp:138
bool c4::yml::ParserState::indentation_lt_extra ( ) const
inlinenoexcept

Definition at line 207 of file parser_state.hpp.

208  {
209  RYML_ASSERT_BASIC_(indref != npos);
210  return line_contents.indentation != npos
211  && line_contents.indentation < indref + 1u;
212  }
size_t indref
the reference indentation in the current block scope
LineContents line_contents
size_t indentation
number of spaces on the beginning of the line.
a null string position
Definition: common.hpp:138

Member Data Documentation

LineContents c4::yml::ParserState::line_contents

Definition at line 114 of file parser_state.hpp.

Referenced by reset_before_pop().

Location c4::yml::ParserState::pos

Definition at line 115 of file parser_state.hpp.

Referenced by reset_before_pop().

ParserFlag_t c4::yml::ParserState::flags

Definition at line 116 of file parser_state.hpp.

size_t c4::yml::ParserState::indref

the reference indentation in the current block scope

Definition at line 117 of file parser_state.hpp.

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

id_type c4::yml::ParserState::level

Definition at line 118 of file parser_state.hpp.

Referenced by reset_after_push().

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 119 of file parser_state.hpp.

size_t c4::yml::ParserState::scalar_col

Definition at line 120 of file parser_state.hpp.

bool c4::yml::ParserState::more_indented

Definition at line 121 of file parser_state.hpp.

bool c4::yml::ParserState::has_children

Definition at line 122 of file parser_state.hpp.


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