@@ -140,16 +140,16 @@ void LiveBlocking::Subscribe(std::string_view sub_msg,
140140databento::Metadata LiveBlocking::Start () {
141141 client_.WriteAll (" start_session\n " );
142142 client_.ReadExact (buffer_.WriteBegin (), kMetadataPreludeSize );
143- buffer_.WriteBegin () += kMetadataPreludeSize ;
143+ buffer_.Fill ( kMetadataPreludeSize ) ;
144144 const auto [version, size] = DbnDecoder::DecodeMetadataVersionAndSize (
145145 buffer_.ReadBegin (), kMetadataPreludeSize );
146- buffer_.ReadBegin () += kMetadataPreludeSize ;
146+ buffer_.Consume ( kMetadataPreludeSize ) ;
147147 buffer_.Reserve (size);
148148 client_.ReadExact (buffer_.WriteBegin (), size);
149- buffer_.WriteBegin () += size;
149+ buffer_.Fill ( size) ;
150150 auto metadata = DbnDecoder::DecodeMetadataFields (version, buffer_.ReadBegin (),
151151 buffer_.ReadEnd ());
152- buffer_.ReadBegin () += size;
152+ buffer_.Consume ( size) ;
153153 // Metadata may leave buffer misaligned. Shift records to ensure 8-byte
154154 // alignment
155155 buffer_.Shift ();
@@ -184,7 +184,7 @@ const databento::Record* LiveBlocking::NextRecord(
184184 }
185185 }
186186 current_record_ = Record{BufferRecordHeader ()};
187- buffer_.ReadBegin () += current_record_.Size ();
187+ buffer_.Consume ( current_record_.Size () );
188188 current_record_ =
189189 DbnDecoder::DecodeRecordCompat (version_, upgrade_policy_, send_ts_out_,
190190 &compat_buffer_, current_record_);
@@ -223,7 +223,7 @@ std::string LiveBlocking::DecodeChallenge() {
223223 if (read_size == 0 ) {
224224 throw LiveApiError{" Gateway closed socket during authentication" };
225225 }
226- buffer_.WriteBegin () += read_size;
226+ buffer_.Fill ( read_size) ;
227227 // first line is version
228228 std::string response{reinterpret_cast <const char *>(buffer_.ReadBegin ()),
229229 buffer_.ReadCapacity ()};
@@ -243,9 +243,8 @@ std::string LiveBlocking::DecodeChallenge() {
243243 : response.find (' \n ' , find_start);
244244 while (next_nl_pos == std::string::npos) {
245245 // read more
246- buffer_.WriteBegin () +=
247- client_.ReadSome (buffer_.WriteBegin (), buffer_.WriteCapacity ())
248- .read_size ;
246+ buffer_.Fill (client_.ReadSome (buffer_.WriteBegin (), buffer_.WriteCapacity ())
247+ .read_size );
249248 if (buffer_.ReadCapacity () == 0 ) {
250249 throw LiveApiError{" Gateway closed socket during authentication" };
251250 }
@@ -335,7 +334,7 @@ std::uint64_t LiveBlocking::DecodeAuthResp() {
335334 " Unexpected end of message received from server after replying to "
336335 " CRAM" };
337336 }
338- buffer_.WriteBegin () += read_size;
337+ buffer_.Fill ( read_size) ;
339338 newline_ptr = std::find (buffer_.ReadBegin (), buffer_.ReadEnd (),
340339 static_cast <std::byte>(' \n ' ));
341340 } while (newline_ptr == buffer_.ReadEnd ());
@@ -349,7 +348,7 @@ std::uint64_t LiveBlocking::DecodeAuthResp() {
349348 log_receiver_->Receive (LogLevel::Debug, log_ss.str ());
350349 }
351350 // set in case Read call also read records. One beyond newline
352- buffer_.ReadBegin () += response.length () + 1 ;
351+ buffer_.Consume ( response.length () + 1 ) ;
353352
354353 std::size_t pos{};
355354 bool found_success{};
@@ -411,7 +410,7 @@ databento::detail::TcpClient::Result LiveBlocking::FillBuffer(
411410 buffer_.Shift ();
412411 const auto read_res =
413412 client_.ReadSome (buffer_.WriteBegin (), buffer_.WriteCapacity (), timeout);
414- buffer_.WriteBegin () += read_res.read_size ;
413+ buffer_.Fill ( read_res.read_size ) ;
415414 return read_res;
416415}
417416
0 commit comments