Bond
 
Loading...
Searching...
No Matches
pass_through.h
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#pragma once
5
6#include <bond/core/config.h>
7
8#include <bond/core/traits.h>
9#include <bond/stream/stream_interface.h>
10
11namespace bond
12{
13namespace detail
14{
15
16// Fast pass-through is implemented by calling protocol reader to skip the value
17// and then writing the skipped data as a single blob to protocol writer.
18template <typename T, typename Reader, typename Writer>
19void PassThrough(bonded<T, Reader&>& value, Reader& reader, Writer& writer)
20{
21 BOOST_STATIC_ASSERT((is_protocol_same<Reader, Writer>::value));
22
23 auto before = GetCurrentBuffer(reader.GetBuffer());
24
25 value.Skip();
26
27 auto after = GetCurrentBuffer(reader.GetBuffer());
28
29 writer.GetBuffer().Write(GetBufferRange(before, after));
30}
31
32}
33}
namespace bond
Definition: apply.h:17