DCCL v4
Loading...
Searching...
No Matches
analyze_dccl.cpp
1// Copyright 2011-2023:
2// GobySoft, LLC (2013-)
3// Massachusetts Institute of Technology (2007-2014)
4// Community contributors (see AUTHORS file)
5// File authors:
6// Toby Schneider <toby@gobysoft.org>
7//
8//
9// This file is part of the Dynamic Compact Control Language Library
10// ("DCCL").
11//
12// DCCL is free software: you can redistribute it and/or modify
13// it under the terms of the GNU Lesser General Public License as published by
14// the Free Software Foundation, either version 2.1 of the License, or
15// (at your option) any later version.
16//
17// DCCL is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU Lesser General Public License for more details.
21//
22// You should have received a copy of the GNU Lesser General Public License
23// along with DCCL. If not, see <http://www.gnu.org/licenses/>.
24#include <google/protobuf/descriptor.h>
25
26#include "../../codec.h"
27
28int main(int argc, char* argv[])
29{
30 std::cerr << "**** analyze_dccl is deprecated. You should consider using the newer 'dccl' tool "
31 "instead (dccl --analyze -f some_dccl.proto -I /path/to/proto) **** "
32 << std::endl;
33
34 if (argc < 2)
35 {
36 std::cerr << "usage: analyze_dccl some_dccl.proto [include_path (0-n)]" << std::endl;
37 exit(1);
38 }
39
40 dccl::dlog.connect(dccl::logger::WARN_PLUS, &std::cerr);
41
43
44 for (int i = 2; i < argc; ++i) dccl::DynamicProtobufManager::add_include_path(argv[i]);
45
46 const google::protobuf::FileDescriptor* file_desc =
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
60 {
61 dccl.load(desc);
62 }
63 catch (std::exception& e)
64 {
65 std::cerr << "Not a valid DCCL message: " << desc->full_name() << "\n"
66 << e.what() << std::endl;
67 }
68 }
69 else
70 {
71 std::cerr << "No descriptor with name " << file_desc->message_type(i)->full_name()
72 << " found!" << std::endl;
73 exit(1);
74 }
75 }
76 std::cout << dccl << std::endl;
77 }
78 else
79 {
80 std::cerr << "failed to read in: " << argv[1] << std::endl;
81 }
82}
The Dynamic CCL enCODer/DECoder. This is the main class you will use to load, encode and decode DCCL ...
Definition codec.h:63
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 void enable_compilation()
Enable on the fly compilation of .proto files on the local disk. Must be called before load_from_prot...
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.
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:214
Dynamic Compact Control Language namespace.
Definition any.h:47