DCCL v3
analyze_dccl.cpp
1 // Copyright 2009-2017 Toby Schneider (http://gobysoft.org/index.wt/people/toby)
2 // GobySoft, LLC (for 2013-)
3 // Massachusetts Institute of Technology (for 2007-2014)
4 // Community contributors (see AUTHORS file)
5 //
6 //
7 // This file is part of the Dynamic Compact Control Language Library
8 // ("DCCL").
9 //
10 // DCCL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 2.1 of the License, or
13 // (at your option) any later version.
14 //
15 // DCCL is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with DCCL. If not, see <http://www.gnu.org/licenses/>.
22 #include <google/protobuf/descriptor.h>
23 
24 #include "dccl/codec.h"
25 
26 
27 
28 int main(int argc, char* argv[])
29 {
30  std::cerr << "**** analyze_dccl is deprecated. You should consider using the newer 'dccl' tool instead (dccl --analyze -f some_dccl.proto -I /path/to/proto) **** " << std::endl;
31 
32  if(argc < 2)
33  {
34  std::cerr << "usage: analyze_dccl some_dccl.proto [include_path (0-n)]" << std::endl;
35  exit(1);
36  }
37 
38  dccl::dlog.connect(dccl::logger::WARN_PLUS, &std::cerr);
39 
41 
42  for(int i = 2; i < argc; ++i)
44 
45  const google::protobuf::FileDescriptor* file_desc =
47 
48 
50  if(file_desc)
51  {
52  std::cout << "read in: " << argv[1] << std::endl;
53  for(int i = 0, n = file_desc->message_type_count(); i < n; ++i)
54  {
55  const google::protobuf::Descriptor* desc = file_desc->message_type(i);
56 
57  if(desc)
58  {
59  try { dccl.load(desc); }
60  catch(std::exception& e)
61  {
62  std::cerr << "Not a valid DCCL message: " << desc->full_name() << "\n" << e.what() << std::endl;
63  }
64  }
65  else
66  {
67  std::cerr << "No descriptor with name " <<
68  file_desc->message_type(i)->full_name() << " found!" << std::endl;
69  exit(1);
70  }
71  }
72  std::cout << dccl << std::endl;
73  }
74  else
75  {
76  std::cerr << "failed to read in: " << argv[1] << std::endl;
77  }
78 }
The Dynamic CCL enCODer/DECoder. This is the main class you will use to load, encode and decode DCCL ...
Definition: codec.h:56
static void enable_compilation()
Enable on the fly compilation of .proto files on the local disk. Must be called before load_from_prot...
void load()
All messages must be explicited loaded and validated (size checks, option extensions checks...
Definition: codec.h:96
void connect(int verbosity_mask, Slot slot)
Connect the output of one or more given verbosities to a slot (function pointer or similar) ...
Definition: logger.h:161
Dynamic Compact Control Language namespace.
static void add_include_path(const std::string &path)
Add a path for searching for import messages when loading .proto files using load_from_proto_file() ...
static const google::protobuf::FileDescriptor * load_from_proto_file(const std::string &protofile_absolute_path)
Load a message from a .proto file on the disk. enable_compilation() must be called first...