DCCL v4
quick.cpp
1 // Copyright 2014-2017:
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 "dccl.h"
25 #include "navreport.pb.h"
26 #include <iostream>
27 
28 int main()
29 {
30  std::string encoded_bytes;
31  dccl::Codec codec;
32  codec.load<NavigationReport>();
33  // SENDER
34  {
35  NavigationReport r_out;
36  r_out.set_x(450);
37  r_out.set_y(550);
38  r_out.set_z(-100);
39  r_out.set_veh_class(NavigationReport::AUV);
40  r_out.set_battery_ok(true);
41 
42  codec.encode(&encoded_bytes, r_out);
43  }
44  // send encoded_bytes across your link
45 
46  // RECEIVER
47  if (codec.id(encoded_bytes) == codec.id<NavigationReport>())
48  {
49  NavigationReport r_in;
50  codec.decode(encoded_bytes, &r_in);
51  std::cout << r_in.ShortDebugString() << std::endl;
52  }
53 }
dccl::Codec
The Dynamic CCL enCODer/DECoder. This is the main class you will use to load, encode and decode DCCL ...
Definition: codec.h:62