From f461ebc411c514c82c2623ea1a0c8a50fecb0ea1 Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Sun, 21 Feb 2016 10:02:30 +0200 Subject: [PATCH] idl-compiler: Add pos and rollback to serialize vector This adds the ability to store a position of a serialized vector and to rollback to that stored position afterwards. Signed-off-by: Amnon Heiman Message-Id: <1456041750-1505-3-git-send-email-amnon@scylladb.com> --- idl-compiler.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/idl-compiler.py b/idl-compiler.py index 374da54156..f4cd032afa 100755 --- a/idl-compiler.py +++ b/idl-compiler.py @@ -338,6 +338,15 @@ def vector_add_method(current, base_state): after_${basestate}__$name end_$name() && { _size.set(_out, _count); return { _out, std::move(_state) }; + } + + vector_position pos() const { + return vector_position{_out.pos(), _count}; + } + + void rollback(const vector_position& vp) { + _out.retract(vp.pos); + _count = vp.count; }""").substitute({'name': current["name"], 'basestate' : base_state}) def add_param_writer_basic_type(name, base_state, typ, var_type = "", var_index = None, root_node = False):