Go to the documentation of this file.
25 #ifndef GOBY_MOOS_TRANSITIONAL_DCCL_CONSTANTS_H
26 #define GOBY_MOOS_TRANSITIONAL_DCCL_CONSTANTS_H
45 namespace transitional
111 "cannot directly map DCCLv1 XML type to Protobuf Type"));
146 "_ccl_id",
"_id",
"_time",
"_src_id",
"_dest_id",
"_multimessage_flag",
147 "_broadcast_flag",
"_unused",
173 std::stringstream ss;
174 for (
unsigned int i = 0; i < n; i++)
175 ss << std::hex << std::setw(2) << std::setfill(
'0') <<
static_cast<unsigned int>(c[i]);
184 for (
unsigned int i = 0; i < n; i++)
186 std::stringstream ss;
188 ss << s.substr(2 * i, 2);
189 ss >> std::hex >> in;
190 c[i] =
static_cast<unsigned char>(in);
199 for (
unsigned int i = 0; i < bits; i++)
201 s[bits - i - 1] = (l & 1) ?
'1' :
'0';
205 return (std::string)s;
212 auto bytes = (
unsigned int)(std::ceil(bs.length() / 8.0));
213 unsigned char c[bytes];
215 for (
size_t i = 0; i < bytes; ++i)
217 std::bitset<8> b(bs.substr(i * 8, 8));
218 c[i] = (
char)b.to_ulong();
231 int bytes = bs.length() / 2;
232 unsigned char c[bytes];
238 for (
size_t i = 0; i < (size_t)bytes; i++) hs +=
long2binary_string((
unsigned long)c[i], 8);
248 std::stringstream ss;
260 template <
typename T>
bool number2hex_string(std::string& s,
const T& t,
unsigned int width = 2)
262 std::stringstream ss;
263 ss << std::hex << std::setw(width) << std::setfill('0') << static_cast<unsigned int>(t);
The global namespace for the Goby project.
const std::string DCCL_HEADER_NAMES[]
std::string hex_string2binary_string(const std::string &bs)
converts a hex string ("8AAA") into a binary string ("1000101010101010")
unsigned nibs2bytes(unsigned nibs)
std::string to_str(DCCLHeaderPart p)
std::string long2binary_string(unsigned long l, unsigned short bits)
return a string represented the binary value of l for bits number of bits which reads MSB -> LSB
bool hex_string2char_array(unsigned char *c, const std::string &s, const unsigned int n)
turns a string of hex chars ABCDEF into a character array reading each byte 0xAB,0xCD,...
DCCLType
Enumeration of DCCL types used for sending messages. dccl_enum and dccl_string primarily map to cpp_s...
unsigned bytes2nibs(unsigned bytes)
const unsigned DCCL_NUM_HEADER_PARTS
bool hex_string2number(const std::string &s, T &t)
attempts to convert a hex string into a numerical representation (of type T)
const unsigned DCCL_NUM_HEADER_BYTES
unsigned bits2bytes(unsigned bits)
unsigned bytes2bits(unsigned bytes)
std::string type_to_protobuf_type(DCCLType type)
type
Generic JSON types used in JWTs.
std::string binary_string2hex_string(const std::string &bs)
converts a binary string ("1000101010101010") into a hex string ("8AAA")
bool number2hex_string(std::string &s, const T &t, unsigned int width=2)
converts a decimal number of type T into a hex string
std::string type_to_string(DCCLType type)
DCCLCppType
Enumeration of C++ types used in DCCL.
bool char_array2hex_string(const unsigned char *c, std::string &s, const unsigned int n)
converts a char (byte) array into a hex string
dccl::Exception DCCLException