• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion ----------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implements a simple driver to print a C++ program from a protobuf.
10 //
11 //===----------------------------------------------------------------------===//
12 #include <fstream>
13 #include <iostream>
14 #include <streambuf>
15 #include <string>
16 
17 #include "proto_to_cxx.h"
18 
main(int argc,char ** argv)19 int main(int argc, char **argv) {
20   for (int i = 1; i < argc; i++) {
21     std::fstream in(argv[i]);
22     std::string str((std::istreambuf_iterator<char>(in)),
23                     std::istreambuf_iterator<char>());
24     std::cout << "// " << argv[i] << std::endl;
25     std::cout << clang_fuzzer::ProtoToCxx(
26         reinterpret_cast<const uint8_t *>(str.data()), str.size());
27   }
28 }
29 
30