/src/skia/src/utils/SkJSONWriter.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
13 | | #include <inttypes.h> |
14 | | #include <stdarg.h> |
15 | | |
16 | | #include "src/utils/SkJSONWriter.h" |
17 | | |
18 | 0 | void SkJSONWriter::appendS64(int64_t value) { |
19 | 0 | this->beginValue(); |
20 | 0 | this->appendf("%" PRId64, value); |
21 | 0 | } |
22 | | |
23 | 0 | void SkJSONWriter::appendU64(uint64_t value) { |
24 | 0 | this->beginValue(); |
25 | 0 | this->appendf("%" PRIu64, value); |
26 | 0 | } |
27 | | |
28 | 0 | void SkJSONWriter::appendHexU64(uint64_t value) { |
29 | 0 | this->beginValue(); |
30 | 0 | this->appendf("\"0x%" PRIx64 "\"", value); |
31 | 0 | } |
32 | | |
33 | 0 | void SkJSONWriter::appendf(const char* fmt, ...) { |
34 | 0 | const int kBufferSize = 1024; |
35 | 0 | char buffer[kBufferSize]; |
36 | 0 | va_list argp; |
37 | 0 | va_start(argp, fmt); |
38 | | #ifdef SK_BUILD_FOR_WIN |
39 | | int length = _vsnprintf_s(buffer, kBufferSize, _TRUNCATE, fmt, argp); |
40 | | #else |
41 | 0 | int length = vsnprintf(buffer, kBufferSize, fmt, argp); |
42 | 0 | #endif |
43 | 0 | SkASSERT(length >= 0 && length < kBufferSize); |
44 | 0 | va_end(argp); |
45 | 0 | this->write(buffer, length); |
46 | 0 | } Unexecuted instantiation: SkJSONWriter::appendf(char const*, ...) Unexecuted instantiation: SkJSONWriter::appendf(char const*, ...) |