Skip to content

Commit 3020650

Browse files
committed
cbor_cursor
1 parent 849e89c commit 3020650

File tree

2 files changed

+129
-46
lines changed

2 files changed

+129
-46
lines changed

include/jsoncons_ext/cbor/cbor_cursor.hpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class basic_cbor_cursor : public basic_staj_cursor<char>, private virtual ser_co
5353
cursor_visitor_(accept_all),
5454
cursor_handler_adaptor_(cursor_visitor_, alloc)
5555
{
56+
parser_.cursor_mode(true);
5657
if (!done())
5758
{
5859
next();
@@ -92,6 +93,7 @@ class basic_cbor_cursor : public basic_staj_cursor<char>, private virtual ser_co
9293
cursor_handler_adaptor_(cursor_visitor_, alloc),
9394
eof_(false)
9495
{
96+
parser_.cursor_mode(true);
9597
if (!done())
9698
{
9799
next(ec);
@@ -186,9 +188,23 @@ class basic_cbor_cursor : public basic_staj_cursor<char>, private virtual ser_co
186188
void read_to(basic_json_visitor<char_type>& visitor,
187189
std::error_code& ec) override
188190
{
189-
if (cursor_visitor_.dump(visitor, *this, ec))
191+
if (is_begin_container(current().event_type()))
190192
{
191-
read_next(visitor, ec);
193+
parser_.cursor_mode(false);
194+
parser_.mark_level(parser_.level());
195+
if (cursor_visitor_.event().send_json_event(visitor, *this, ec))
196+
{
197+
read_next(visitor, ec);
198+
}
199+
parser_.cursor_mode(true);
200+
parser_.mark_level(0);
201+
}
202+
else
203+
{
204+
if (cursor_visitor_.event().send_json_event(visitor, *this, ec))
205+
{
206+
read_next(visitor, ec);
207+
}
192208
}
193209
}
194210

0 commit comments

Comments
 (0)