43 template<
class ...WriterArgs>
45 : Writer(std::forward<WriterArgs>(args)...)
73 typedef enum : uint32_t { _PWS_NONE = 0u, _PWS_SPACE = 1u, _PWS_NEWL = 2u } Pws_e;
76 C4_ALWAYS_INLINE
void pend_none_() noexcept
81 C4_ALWAYS_INLINE
void pend_newl_() noexcept
86 C4_ALWAYS_INLINE
void pend_space_() noexcept
91 C4_ALWAYS_INLINE
void write_pws_and_pend_(Pws_e next=_PWS_NONE)
noexcept
93 if(m_pws == _PWS_SPACE)
97 else if(m_pws == _PWS_NEWL)
109 Pws_e pend_after_comma = _PWS_NONE;
111 C4_ALWAYS_INLINE Pws_e next_pws(
size_t col)
const noexcept
113 return (active && col >= max_cols) ? _PWS_NEWL : pend_after_comma;
115 void start(NodeType ty,
size_t max_cols_)
noexcept;
116 void stop() noexcept { active =
false; }
119 C4_NODISCARD
bool maybe_start_flow_pws_ml_(
id_type node)
noexcept;
120 C4_NODISCARD flow_pws setup_flow_pws_sl_(
id_type node)
noexcept;
126 void visit_stream_(
id_type id);
128 void visit_doc_val_(
id_type id);
129 void visit_blck_container_(
id_type id);
130 void visit_flow_container_(
id_type id);
132 void visit_flow_sl_(
id_type id);
133 void visit_flow_sl_seq_(
id_type id);
134 void visit_flow_sl_map_(
id_type id);
136 void visit_flow_ml_(
id_type id);
137 void visit_flow_ml_seq_(
id_type id);
138 void visit_flow_ml_map_(
id_type id);
141 void visit_blck_seq_(
id_type id);
142 void visit_blck_map_(
id_type id);
144 void top_open_entry_(
id_type id);
145 void top_close_entry_(
id_type id);
146 void blck_seq_open_entry_(
id_type id);
147 void blck_map_open_entry_(
id_type id);
148 void blck_close_entry_(
id_type id);
151 void flow_seq_open_entry_(
id_type id);
152 void flow_map_open_entry_(
id_type id);
153 void flow_close_entry_sl_(
id_type id,
id_type last_sibling, Pws_e pend_after);
154 void flow_close_entry_ml_(
id_type id,
id_type last_sibling, Pws_e pend_after);
166 size_t write_escaped_newlines_(
csubstr s,
size_t i);
173 bool json_maybe_write_naninf_(
csubstr s);
174 void json_writek_(
id_type id, NodeType ty);
175 void json_writev_(
id_type id, NodeType ty);
176 void json_write_scalar_dquo_(
csubstr s);
177 void json_write_number_(
csubstr s);
183 if(!tag.begins_with(
'!'))
191 if(!ref.begins_with(
'*'))
200 C4_ALWAYS_INLINE
void write_(
const char (&a)[N])
202 this->Writer::append(std::forward<
const char (&)[N]>(a));
205 C4_ALWAYS_INLINE
void write_(
csubstr s)
207 this->Writer::append(s);
210 C4_ALWAYS_INLINE
void write_(
char c)
212 this->Writer::append(c);
216 C4_ALWAYS_INLINE
void indent_(
id_type level)
218 C4_SUPPRESS_WARNING_GCC_WITH_PUSH(
"-Wuseless-cast")
219 size_t num = static_cast<
size_t>(2u * level);
220 this->Writer::append(
' ', num);
222 C4_SUPPRESS_WARNING_GCC_POP
226 C4_ALWAYS_INLINE
void newl_()
228 this->Writer::append(
'\n');
234 Tree
const* C4_RESTRICT m_tree;
245 RYML_DEPRECATED(
"create a new emitter") void
options(EmitOptions) noexcept { ; }
246 RYML_DEPRECATED(
"use .options()") void max_depth(
id_type max_depth) noexcept { m_opts.max_depth(max_depth); }
247 RYML_DEPRECATED(
"use .options()")
id_type max_depth() const noexcept {
return m_opts.max_depth(); }