Goby v2
dccl_xml_to_dccl_proto.cpp
1 // Copyright 2009-2018 Toby Schneider (http://gobysoft.org/index.wt/people/toby)
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 //
5 //
6 // This file is part of the Goby Underwater Autonomy Project Binaries
7 // ("The Goby Binaries").
8 //
9 // The Goby Binaries are free software: you can redistribute them and/or modify
10 // them under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // The Goby Binaries are distributed in the hope that they will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
21 
22 #include "goby/moos/transitional/dccl_transitional.h"
23 #include "goby/util/dynamic_protobuf_manager.h"
24 
25 int main(int argc, char* argv[])
26 {
27  std::string xml_file;
28  std::string proto_folder = "";
29 
30  switch (argc)
31  {
32  case 3: xml_file = argv[1]; proto_folder = argv[2];
33 
34  case 2: xml_file = argv[1]; break;
35 
36  default:
37  std::cerr << "usage: dccl_xml_to_dccl_proto message_xml_file.xml [directory for "
38  "generated .proto (default = pwd (.)]"
39  << std::endl;
40  exit(EXIT_FAILURE);
41  }
42 
43  goby::glog.add_stream(goby::common::protobuf::GLogConfig::VERBOSE, &std::cerr);
44 
45  std::cerr << "creating DCCLTransitionalCodec using xml file: [" << xml_file << "]" << std::endl;
46 
48 
49  goby::util::DynamicProtobufManager::enable_compilation();
50 
52  cfg.mutable_transitional_cfg()->add_message_file()->set_path(xml_file);
53  cfg.mutable_transitional_cfg()->set_generated_proto_dir(proto_folder);
54  dccl.convert_to_v2_representation(&cfg);
55 
56  std::cout << "received: " << cfg.DebugString();
57 
58  std::cerr << "wrote proto files" << std::endl;
59 }
provides an API to the Transitional Dynamic CCL Codec (looks like DCCLv1, but calls DCCLv2)...
common::FlexOstream glog
Access the Goby logger through this object.
void add_stream(logger::Verbosity verbosity=logger::VERBOSE, std::ostream *os=0)
Attach a stream object (e.g. std::cout, std::ofstream, ...) to the logger with desired verbosity...
Definition: flex_ostream.h:96