Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkJSONWriter.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8// Make sure that the PRI format string macros are defined
9#ifndef __STDC_FORMAT_MACROS
10#define __STDC_FORMAT_MACROS
11#endif
12
14
15#include <inttypes.h>
16#include <stdarg.h>
17#include <stdio.h>
18
19void SkJSONWriter::appendS64(int64_t value) {
20 this->beginValue();
21 this->appendf("%" PRId64, value);
22}
23
24void SkJSONWriter::appendU64(uint64_t value) {
25 this->beginValue();
26 this->appendf("%" PRIu64, value);
27}
28
29void SkJSONWriter::appendHexU64(uint64_t value) {
30 this->beginValue();
31 this->appendf("\"0x%" PRIx64 "\"", value);
32}
33
34void SkJSONWriter::appendf(const char* fmt, ...) {
35 const int kBufferSize = 1024;
36 char buffer[kBufferSize];
37 va_list argp;
38 va_start(argp, fmt);
39#ifdef SK_BUILD_FOR_WIN
40 int length = _vsnprintf_s(buffer, kBufferSize, _TRUNCATE, fmt, argp);
41#else
42 int length = vsnprintf(buffer, kBufferSize, fmt, argp);
43#endif
45 va_end(argp);
46 this->write(buffer, length);
47}
#define SkASSERT(cond)
Definition SkAssert.h:116
static const size_t kBufferSize
Definition SkString.cpp:27
void appendU64(uint64_t value)
void appendS64(int64_t value)
void appendHexU64(uint64_t value)
static const uint8_t buffer[]
uint8_t value
size_t length
static SkString fmt(SkColor4f c)
Definition p3.cpp:43