Files
clang-p2996/lldb/tools/argdumper/argdumper.cpp
Enrico Granata 89fdc9a61e Add a JSON producer to LLDB - this is a set of classes that encapsulate JSON objects and allow you to write them to a Stream for subsequent processing
Using this JSON producer, write a little tool that expands its own command-line arguments and dumps them to stdout as a JSON array

llvm-svn: 228636
2015-02-10 00:30:07 +00:00

39 lines
905 B
C++

//===-- argdumper.cpp --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/StreamString.h"
#include "lldb/Utility/JSON.h"
#include <iostream>
using namespace lldb_private;
int
main (int argc, char *argv[])
{
JSONArray::SP arguments(new JSONArray());
for (int i = 1;
i < argc;
i++)
{
arguments->AppendObject(JSONString::SP(new JSONString(argv[i])));
}
JSONObject::SP object(new JSONObject());
object->SetObject("arguments", arguments);
StreamString ss;
object->Write(ss);
std::cout << ss.GetData() << std::endl;
return 0;
}