MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / fill_buffer

Function fill_buffer

include/jsoncons/source.hpp:80–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78
79 template <typename CharT,typename Allocator = std::allocator<CharT>>
80 class stream_source
81 {
82 public:
83 using value_type = CharT;
84 static constexpr std::size_t default_max_buffer_size = 16384;
85 private:
86 using char_type = typename std::conditional<sizeof(CharT) == sizeof(char),char,CharT>::type;
87 using char_allocator_type = typename std::allocator_traits<Allocator>:: template rebind_alloc<value_type>;
88
89 Allocator alloc_;
90 basic_null_istream<char_type> null_is_;
91 std::basic_istream<char_type>* stream_ptr_;
92 std::basic_streambuf<char_type>* sbuf_;
93 std::size_t position_{0};
94 value_type* buffer_{nullptr};
95 std::size_t buffer_size_{0};
96 value_type* data_{nullptr};
97 std::size_t length_{0};
98 public:
99
100 const Allocator& get_allocator() const
101 {
102 return alloc_;
103 }
104
105 stream_source(const Allocator& alloc = Allocator())
106 : alloc_(alloc), stream_ptr_(&null_is_), sbuf_(null_is_.rdbuf())
107 {
108 }
109
110 // Noncopyable
111 stream_source(const stream_source&) = delete;
112
113 stream_source(stream_source&& other) noexcept
114 : alloc_(other.alloc_), stream_ptr_(&null_is_), sbuf_(null_is_.rdbuf())
115 {
116 buffer_ = other.buffer_;
117 data_ = other.data_;
118 buffer_size_ = other.buffer_size_;
119 length_ = other.length_;
120 other.buffer_ = nullptr;
121 other.data_ = nullptr;
122 other.buffer_size_ = 0;
123 other.length_ = 0;
124
125 if (other.stream_ptr_ != &other.null_is_)
126 {
127 stream_ptr_ = other.stream_ptr_;
128 sbuf_ = other.sbuf_;
129 position_ = other.position_;
130 other.stream_ptr_ = &other.null_is_;
131 other.sbuf_ = other.null_is_.rdbuf();
132 other.position_ = 0;
133 }
134 }
135
136 stream_source(stream_source&& other, const Allocator& alloc) noexcept
137 : alloc_(alloc), stream_ptr_(&null_is_), sbuf_(null_is_.rdbuf()),

Callers 4

ignoreMethod · 0.85
peekMethod · 0.85
read_bufferMethod · 0.85
readMethod · 0.85

Calls 2

eofMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected