fipa_acl  1.4
Public Member Functions | List of all members
fipa::acl::ByteStringPrinter Class Reference

Printer using the visitor pattern for the ByteString type. More...

#include <byte_sequence.h>

Inherits static_visitor< std::string >.

Public Member Functions

 ByteStringPrinter (std::string enc)
 
std::string operator() (const std::string &s) const
 
std::string operator() (const std::vector< unsigned char > &vector) const
 

Detailed Description

Printer using the visitor pattern for the ByteString type.

Definition at line 26 of file byte_sequence.h.

Constructor & Destructor Documentation

fipa::acl::ByteStringPrinter::ByteStringPrinter ( std::string  enc)
inline

Constructor using a given encoding, userdefined by a string representation

Definition at line 36 of file byte_sequence.h.

36 : encoding(enc) {}

Member Function Documentation

std::string fipa::acl::ByteStringPrinter::operator() ( const std::string &  s) const
inline

Build a string for the given type

Parameters
sOne of the types for the variant that this printer is implemented for

Definition at line 42 of file byte_sequence.h.

43  {
44  return s;
45  }
std::string fipa::acl::ByteStringPrinter::operator() ( const std::vector< unsigned char > &  vector) const
inline

Build a string from a raw byte sequence, i.e. the following output format will be used, embedding encoding information (dword) HEX(dword)[0a af 02 10 ... 01]

Parameters
vectorOne of the types for the variant that this printer is implemented for

Definition at line 53 of file byte_sequence.h.

54  {
55  size_t length = vector.size();
56  std::string tmp("HEX(");
57  tmp += encoding;
58  tmp +=")[";
59 
60  for(size_t i = 0; i < length; i++)
61  {
62  char currentChar[6];
63  sprintf(currentChar, "%02x", vector[i]);
64  tmp += std::string(currentChar);
65  tmp += " ";
66  }
67 
68  tmp += "]";
69 
70  return tmp;
71  }

The documentation for this class was generated from the following file: