mirror of
https://github.com/biojppm/rapidyaml.git
synced 2026-01-18 21:41:18 +01:00
parse.hpp: move implementation function to parse_engine.def.hpp
This commit is contained in:
@@ -129,24 +129,6 @@ Tree parse_json_in_arena(csubstr filename, csubstr json
|
||||
Tree parse_json_in_arena( csubstr json ) { Parser::handler_type event_handler; Parser parser(&event_handler); Tree tree(parser.callbacks()); substr src = tree.copy_to_arena(json); parse_json_in_place(&parser, {} , src, &tree, tree.root_id()); return tree; }
|
||||
|
||||
|
||||
RYML_EXPORT C4_NO_INLINE size_t _find_last_newline_and_larger_indentation(csubstr s, size_t indentation) noexcept
|
||||
{
|
||||
if(indentation + 1 > s.len)
|
||||
return npos;
|
||||
for(size_t i = s.len-indentation-1; i != size_t(-1); --i)
|
||||
{
|
||||
if(s.str[i] == '\n')
|
||||
{
|
||||
csubstr rem = s.sub(i + 1);
|
||||
size_t first = rem.first_not_of(' ');
|
||||
first = (first != npos) ? first : rem.len;
|
||||
if(first > indentation)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
RYML_EXPORT id_type estimate_tree_capacity(csubstr src)
|
||||
|
||||
@@ -2859,6 +2859,24 @@ FilterResultExtending ParseEngine<EventHandler>::filter_scalar_dquoted_in_place(
|
||||
//-----------------------------------------------------------------------------
|
||||
// block filtering helpers
|
||||
|
||||
C4_NO_INLINE inline size_t _find_last_newline_and_larger_indentation(csubstr s, size_t indentation) noexcept
|
||||
{
|
||||
if(indentation + 1 > s.len)
|
||||
return npos;
|
||||
for(size_t i = s.len-indentation-1; i != size_t(-1); --i)
|
||||
{
|
||||
if(s.str[i] == '\n')
|
||||
{
|
||||
csubstr rem = s.sub(i + 1);
|
||||
size_t first = rem.first_not_of(' ');
|
||||
first = (first != npos) ? first : rem.len;
|
||||
if(first > indentation)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
template<class EventHandler>
|
||||
template<class FilterProcessor>
|
||||
void ParseEngine<EventHandler>::_filter_chomp(FilterProcessor &C4_RESTRICT proc, BlockChomp_e chomp, size_t indentation)
|
||||
@@ -3516,13 +3534,17 @@ csubstr ParseEngine<EventHandler>::_filter_scalar_dquot(substr s)
|
||||
_c4dbgpf("filtering dquo scalar: not enough space: needs {}, have {}", len, s.len);
|
||||
substr dst = m_evt_handler->alloc_arena(len, &s);
|
||||
_c4dbgpf("filtering dquo scalar: dst.len={}", dst.len);
|
||||
_RYML_CB_ASSERT(this->callbacks(), dst.len == len);
|
||||
FilterResult rsd = this->filter_scalar_dquoted(s, dst);
|
||||
_c4dbgpf("filtering dquo scalar: ... result now needs {} was {}", rsd.required_len(), len);
|
||||
_RYML_CB_ASSERT(this->callbacks(), rsd.required_len() <= len); // may be smaller!
|
||||
_RYML_CB_CHECK(m_evt_handler->m_stack.m_callbacks, rsd.valid());
|
||||
_c4dbgpf("filtering dquo scalar: success! s=[{}]~~~{}~~~", rsd.get().len, rsd.get());
|
||||
return rsd.get();
|
||||
if(dst.str)
|
||||
{
|
||||
_RYML_CB_ASSERT(this->callbacks(), dst.len == len);
|
||||
FilterResult rsd = this->filter_scalar_dquoted(s, dst);
|
||||
_c4dbgpf("filtering dquo scalar: ... result now needs {} was {}", rsd.required_len(), len);
|
||||
_RYML_CB_ASSERT(this->callbacks(), rsd.required_len() <= len); // may be smaller!
|
||||
_RYML_CB_CHECK(m_evt_handler->m_stack.m_callbacks, rsd.valid());
|
||||
_c4dbgpf("filtering dquo scalar: success! s=[{}]~~~{}~~~", rsd.get().len, rsd.get());
|
||||
return rsd.get();
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -756,10 +756,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
/** @cond dev */
|
||||
RYML_EXPORT C4_NO_INLINE size_t _find_last_newline_and_larger_indentation(csubstr s, size_t indentation) noexcept;
|
||||
/** @endcond */
|
||||
|
||||
|
||||
/** Quickly inspect the source to estimate the number of nodes the
|
||||
* resulting tree is likely have. If a tree is empty before
|
||||
|
||||
Reference in New Issue
Block a user