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

#include <text_buffer.h>

Inheritance diagram for dart::TextBuffer:
dart::BaseTextBuffer dart::ValueObject

Public Member Functions

 TextBuffer (intptr_t buf_size)
 
 ~TextBuffer ()
 
void Clear ()
 
void set_length (intptr_t len)
 
char * Steal ()
 
- Public Member Functions inherited from dart::BaseTextBuffer
 BaseTextBuffer ()
 
 BaseTextBuffer (char *buffer, intptr_t capacity)
 
virtual ~BaseTextBuffer ()
 
intptr_t Printf (const char *format,...) PRINTF_ATTRIBUTE(2
 
intptr_t intptr_t VPrintf (const char *format, va_list args)
 
void AddChar (char ch)
 
void AddString (const char *s)
 
void AddRaw (const uint8_t *buffer, intptr_t buffer_length)
 
void AddEscapedString (const char *s)
 
void AddEscapedUTF8 (const char *s, intptr_t len)
 
void AddEscapedLatin1 (const uint8_t *code_units, intptr_t len)
 
void AddEscapedUTF16 (const uint16_t *code_units, intptr_t len)
 
char * buffer () const
 
intptr_t length () const
 
virtual void Clear ()=0
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Additional Inherited Members

- Protected Member Functions inherited from dart::BaseTextBuffer
virtual bool EnsureCapacity (intptr_t len)=0
 
 DISALLOW_COPY_AND_ASSIGN (BaseTextBuffer)
 
- Protected Attributes inherited from dart::BaseTextBuffer
char * buffer_
 
intptr_t capacity_
 
intptr_t length_
 

Detailed Description

Definition at line 59 of file text_buffer.h.

Constructor & Destructor Documentation

◆ TextBuffer()

dart::TextBuffer::TextBuffer ( intptr_t  buf_size)
explicit

Definition at line 271 of file text_buffer.cc.

271 {
272 ASSERT(buf_size > 0);
273 buffer_ = reinterpret_cast<char*>(malloc(buf_size));
274 capacity_ = buf_size;
275 Clear();
276}
#define ASSERT(E)
void * malloc(size_t size)
Definition: allocation.cc:19

◆ ~TextBuffer()

dart::TextBuffer::~TextBuffer ( )

Definition at line 278 of file text_buffer.cc.

278 {
279 free(buffer_);
280 buffer_ = nullptr;
281}

Member Function Documentation

◆ Clear()

void dart::TextBuffer::Clear ( )
inlinevirtual

Implements dart::BaseTextBuffer.

Definition at line 65 of file text_buffer.h.

65{ set_length(0); }
void set_length(intptr_t len)
Definition: text_buffer.h:67

◆ set_length()

void dart::TextBuffer::set_length ( intptr_t  len)
inline

Definition at line 67 of file text_buffer.h.

67 {
68 ASSERT(len >= 0);
69 ASSERT(len <= length_);
70 length_ = len;
71 buffer_[len] = '\0';
72 }

◆ Steal()

char * dart::TextBuffer::Steal ( )

Definition at line 283 of file text_buffer.cc.

283 {
284 char* r = buffer_;
285 buffer_ = nullptr;
286 capacity_ = 0;
287 length_ = 0;
288 return r;
289}

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