1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef TOOLS_BLINK_GC_PLUGIN_JSON_WRITER_H_
6 #define TOOLS_BLINK_GC_PLUGIN_JSON_WRITER_H_
8 #include "llvm/Support/raw_ostream.h"
10 // Helper to write information for the points-to graph.
13 static JsonWriter
* from(llvm::raw_fd_ostream
* os
) {
14 return os
? new JsonWriter(os
) : 0;
24 void OpenList(const std::string key
) {
42 void Write(const size_t val
) {
46 void Write(const std::string val
) {
48 os_
<< "\"" << val
<< "\"";
50 void Write(const std::string key
, const size_t val
) {
52 os_
<< "\"" << key
<< "\":" << val
;
54 void Write(const std::string key
, const std::string val
) {
56 os_
<< "\"" << key
<< "\":\"" << val
<< "\"";
59 JsonWriter(llvm::raw_fd_ostream
* os
) : os_(*os
) {}
69 llvm::raw_fd_ostream
& os_
;
70 std::stack
<bool> state_
;
73 #endif // TOOLS_BLINK_GC_PLUGIN_JSON_WRITER_H_