Skip to content

Commit

Permalink
do not use std::string in the event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed May 26, 2024
1 parent 0e9c853 commit 11d7bd2
Show file tree
Hide file tree
Showing 10 changed files with 512 additions and 179 deletions.
2 changes: 1 addition & 1 deletion src/c4/yml/detail/stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace detail {
template<class T, id_type N=16>
class stack
{
//static_assert(std::is_trivially_copyable<T>::value, "T must be trivially copyable");
static_assert(std::is_trivially_copyable<T>::value, "T must be trivially copyable");
static_assert(std::is_trivially_destructible<T>::value, "T must be trivially destructible");

public:
Expand Down
4 changes: 2 additions & 2 deletions test/test_lib/test_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ void test_new_parser_events_from_yaml(ReferenceYaml const& yaml, std::string con
ParseEngine<EventHandlerYamlStd> parser(&handler);
std::string copy = yaml.parsed;
parser.parse_in_place_ev("(testyaml)", to_substr(copy));
csubstr result = sink.get();
_c4dbgpf("~~~\n{}~~~\n", sink.get());
csubstr result = sink;
_c4dbgpf("~~~\n{}~~~\n", result);
EXPECT_EQ(std::string(result.str, result.len), expected_events);
}

Expand Down
4 changes: 2 additions & 2 deletions test/test_lib/test_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ C4_NO_INLINE void test_new_parser_str_from_events(std::string const& expected_ev
handler.reset();
EventProducerFn<EventHandlerYamlStd> event_producer;
event_producer(handler);
csubstr result = sink.get();
csubstr result = sink;
_c4dbgpf("~~~\n{}~~~\n", result);
EXPECT_EQ(std::string(result.str, result.len), expected_events);
}
Expand Down Expand Up @@ -215,7 +215,7 @@ inline void _print_handler_info(EventHandlerYamlStd const& ps, csubstr stmt)
};
for(id_type i = 0; i < ps.m_stack.size(); ++i)
{
auto const& str = ps._buf_(i).get();
csubstr const& str = ps._buf_(i);
indent(i);
_dbg_printf("[{}]\n", i);
for(csubstr line : str.split('\n'))
Expand Down
6 changes: 3 additions & 3 deletions test/test_suite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ struct TestSequenceLevel
if(prev)
receive_src(*prev);
_nfo_logf("level[{}]: parsing source:\n{}", level, src_evts);
evt_str_sink.reset();
evt_str_sink.clear();
evt_handler_str_sink.reset();
evt_handler_str_sink.m_stack.m_callbacks = get_callbacks();
parser_str_sink.parse_in_place_ev(filename, to_substr(src_evts));
EXPECT_FALSE(evt_str_sink.get().empty());
EXPECT_NE(evt_str_sink.size(), 0);
events_were_generated = true;
}

Expand Down Expand Up @@ -655,7 +655,7 @@ struct TestSequenceData
for(size_t i = 0; i < num; ++i)
{
levels[i].parse_yaml_to_events();
csubstr result = levels[i].evt_str_sink.get();
csubstr result = levels[i].evt_str_sink;
events->compare_emitted_events_to_reference_events(std::string(result.str, result.len),
/*ignore_container_style*/false,
/*ignore_scalar_style*/(num>0));
Expand Down
Loading

0 comments on commit 11d7bd2

Please sign in to comment.