1 #ifndef C4_YML_PARSER_STATE_HPP_
2 #define C4_YML_PARSER_STATE_HPP_
4 #ifndef C4_YML_ERROR_HPP_
68 RYML_ASSERT_BASIC_(start <= buf.len);
71 while((end < buf.len) && (buf.str[end] !=
'\n'))
75 RYML_ASSERT_BASIC_(buf[end] ==
'\n');
76 full = buf.
range(start, end + 1);
77 rem = buf.
range(start, end);
82 full = rem = buf.
sub(start);
85 rem.
len = (pos !=
npos) ? pos + 1 : 0;
87 RYML_ASSERT_BASIC_(rem.
find(
'\r') ==
npos);
94 RYML_ASSERT_BASIC_(rem.
str >= full.
str);
95 return static_cast<size_t>(rem.
str - full.
str);
100 RYML_ASSERT_BASIC_(s.str >= full.
str);
101 RYML_ASSERT_BASIC_(s.str <= rem.
end());
102 return static_cast<size_t>(s.str - full.
str);
105 static_assert(std::is_standard_layout<LineContents>::value,
"LineContents not standard");
134 more_indented =
false;
137 has_children =
false;
144 more_indented =
false;
146 has_children =
false;
168 RYML_ASSERT_BASIC_(indref !=
npos);
174 RYML_ASSERT_BASIC_(indref !=
npos);
180 RYML_ASSERT_BASIC_(indref !=
npos);
186 RYML_ASSERT_BASIC_(indref !=
npos);
192 RYML_ASSERT_BASIC_(indref !=
npos);
198 RYML_ASSERT_BASIC_(indref !=
npos);
204 RYML_ASSERT_BASIC_(indref !=
npos);
209 RYML_ASSERT_BASIC_(indref !=
npos);
214 static_assert(std::is_standard_layout<ParserState>::value,
"ParserState not standard");
Helper to control the line contents while parsing a buffer.
reading unknown state (when starting): must determine whether scalar, map or seq
size_t offset
number of bytes from the beginning of the source buffer
reading in unknown style mode - must determine FLOW or BLCK reading an implicit map nested in an expl...
size_t indref
the reference indentation in the current block scope
bool indentation_gt() const noexcept
csubstr name
name of the file
C * str
a restricted pointer to the first character of the substring
LineContents line_contents
ParserState_e
Enumeration of the state flags for the parser.
a non-owning string-view, consisting of a character pointer and a length.
bool at_line_beginning() const noexcept
size_t num_cols
number of columns in the line, excluding newline < characters (ie the initial size of rem) ...
reading is inside explicit flow chars: [] or {}
size_t current_col() const RYML_NOEXCEPT
size_t indentation
number of spaces on the beginning of the line.
bool indentation_lt() const noexcept
size_t last_not_of(const C c) const
RYML_ID_TYPE id_type
The type of a node id in the YAML tree; to override the default type, define the macro RYML_ID_TYPE t...
substr full
full line, including newline characters \n and \r
bool indentation_ge() const noexcept
basic_substring sub(size_t first) const noexcept
return [first,len[
id_type node_id
don't hold a pointer to the node as it will be relocated during tree resizes
bool at_first_token() const noexcept
csubstr to_csubstr(const char(&s)[N]) noexcept
#define RYML_NOEXCEPT
Conditionally expands to noexcept when RYML_USE_ASSERT is 0 and is empty otherwise.
size_t current_col(csubstr s) const RYML_NOEXCEPT
holds a source or yaml file position, for example when an error is detected; See also location_format...
reading the key colon (ie the : after the key in the map)
bool indentation_eq_extra() const noexcept
bool indentation_gt_extra() const noexcept
void start_parse(const char *file, id_type node_id_)
void reset_before_pop(ParserState const &to_pop)
reading an explicit key (? key)
basic_substring range(size_t first, size_t last=npos) const noexcept
return [first,last[.
size_t len
the length of the substring
Error utilities used by ryml.
bool indentation_ge_extra() const noexcept
substr rem
current line remainder, without newline characters
bool indentation_eq() const noexcept
bool indentation_lt_extra() const noexcept
size_t find(const C c, size_t start_pos=0) const
LineContents() RYML_NOEXCEPT=default
size_t first_not_of(const C c) const
void reset_with_next_line(substr buf, size_t start) RYML_NOEXCEPT
the (implicit) map being read is a !!set.
int ParserFlag_t
data type for ParserState_e
no document mode. a document has ended and another has not started yet.