Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::JSONBase64String Class Reference

#include <json_stream.h>

Inheritance diagram for dart::JSONBase64String:
dart::ValueObject

Public Member Functions

 JSONBase64String (JSONStream *stream)
 
 ~JSONBase64String ()
 
void AppendBytes (const uint8_t *bytes, intptr_t length)
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 537 of file json_stream.h.

Constructor & Destructor Documentation

◆ JSONBase64String()

dart::JSONBase64String::JSONBase64String ( JSONStream stream)
inlineexplicit

Definition at line 539 of file json_stream.h.

540 : stream_(stream), queued_bytes_(), num_queued_bytes_(0) {
541 stream_->AppendBytes(reinterpret_cast<const uint8_t*>("\""), 1);
542 }
void AppendBytes(const uint8_t *buffer, intptr_t buffer_length)
Definition: json_stream.h:160

◆ ~JSONBase64String()

dart::JSONBase64String::~JSONBase64String ( )
inline

Definition at line 543 of file json_stream.h.

543 {
544 stream_->AppendBytesInBase64(queued_bytes_, num_queued_bytes_);
545 stream_->AppendBytes(reinterpret_cast<const uint8_t*>("\""), 1);
546 }

Member Function Documentation

◆ AppendBytes()

void dart::JSONBase64String::AppendBytes ( const uint8_t *  bytes,
intptr_t  length 
)

Definition at line 603 of file json_stream.cc.

603 {
604 ASSERT(bytes != nullptr);
605
606 if (num_queued_bytes_ > 0) {
607 while (length > 0) {
608 queued_bytes_[num_queued_bytes_++] = bytes[0];
609 bytes++;
610 length--;
611 if (num_queued_bytes_ == 3) {
612 break;
613 }
614 }
615 if (num_queued_bytes_ < 3) {
616 return;
617 }
618 stream_->AppendBytesInBase64(queued_bytes_, 3);
619 num_queued_bytes_ = 0;
620 }
621
622 intptr_t length_mod_3 = length % 3;
623 intptr_t largest_multiple_of_3_less_than_or_equal_to_length =
624 length - length_mod_3;
625 if (largest_multiple_of_3_less_than_or_equal_to_length > 0) {
626 stream_->AppendBytesInBase64(
627 bytes, largest_multiple_of_3_less_than_or_equal_to_length);
628 }
629
630 for (intptr_t i = 0; i < length_mod_3; ++i) {
631 queued_bytes_[i] =
632 bytes[largest_multiple_of_3_less_than_or_equal_to_length + i];
633 }
634 num_queued_bytes_ = length_mod_3;
635}
#define ASSERT(E)
size_t length

The documentation for this class was generated from the following files: