29 if (len >= remaining) {
67 const uint8_t* cursor =
reinterpret_cast<const uint8_t*
>(
s);
68 const uint8_t*
end = cursor + len;
71 while (cursor <
end) {
72 uint8_t codeunit = *cursor++;
73 if (codeunit >= 0x80) {
76 needed += EscapedCodeUnitLength(codeunit);
82 cursor =
reinterpret_cast<const uint8_t*
>(
s);
83 while (cursor <
end) {
84 uint8_t codeunit = *cursor++;
85 if (codeunit >= 0x80) {
88 EscapeAndAddCodeUnit(codeunit);
95 const uint8_t* cursor =
s;
96 const uint8_t*
end = cursor + len;
99 while (cursor <
end) {
100 needed += EscapedCodeUnitLength(*cursor++);
106 while (cursor <
end) {
107 EscapeAndAddCodeUnit(*cursor++);
113 for (
const uint16_t*
end =
s + len;
s <
end;
s++) {
116 uint16_t code_unit = *
s;
118 EscapeAndAddUTF16CodeUnit(code_unit);
121 EscapeAndAddUTF16CodeUnit(code_unit);
123 uint16_t next_code_unit = *(
s + 1);
126 EscapeAndAddCodeUnit(decoded);
129 EscapeAndAddUTF16CodeUnit(code_unit);
133 EscapeAndAddCodeUnit(code_unit);
140intptr_t BaseTextBuffer::EscapedCodeUnitLength(uint32_t codeunit) {
152 if (codeunit < 0x20) {
167static uint8_t
Hex(uint8_t value) {
174void BaseTextBuffer::EscapeAndAddCodeUnit(uint32_t codeunit) {
218 constexpr int kMask = ~(1 << 6);
219 if (codeunit < 0x20) {
252void BaseTextBuffer::EscapeAndAddUTF16CodeUnit(uint16_t codeunit) {
264 AddRaw(
reinterpret_cast<const uint8_t*
>(
s), strlen(
s));
291bool TextBuffer::EnsureCapacity(intptr_t len) {
293 if (remaining <= len) {
296 char* new_buf =
reinterpret_cast<char*
>(
realloc(
buffer_, new_size));
static constexpr uint64_t kMask
void AddString(const char *s)
intptr_t Printf(const char *format,...) PRINTF_ATTRIBUTE(2
void AddEscapedLatin1(const uint8_t *code_units, intptr_t len)
intptr_t intptr_t VPrintf(const char *format, va_list args)
void AddEscapedString(const char *s)
void AddRaw(const uint8_t *buffer, intptr_t buffer_length)
void AddEscapedUTF8(const char *s, intptr_t len)
void AddEscapedUTF16(const uint16_t *code_units, intptr_t len)
virtual bool EnsureCapacity(intptr_t len)=0
TextBuffer(intptr_t buf_size)
static int32_t Decode(uint16_t lead, uint16_t trail)
static bool IsLeadSurrogate(uint32_t ch)
static bool IsTrailSurrogate(uint32_t ch)
static constexpr int32_t kMaxTwoByteChar
static constexpr int32_t kMaxFourByteChar
static constexpr int32_t kMaxThreeByteChar
static constexpr int32_t kMaxOneByteChar
static constexpr T Maximum(T x, T y)
static int static int VSNPrint(char *str, size_t size, const char *format, va_list args)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static const uint8_t buffer[]
uint32_t uint32_t * format
void * malloc(size_t size)
static uint8_t Hex(uint8_t value)
void * realloc(void *ptr, size_t size)