YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
yarp::os::Vocab64 Namespace Reference

Short readable codes. More...

Functions

NetInt64 encode64 (const std::string &str)
 Convert a string into a vocabulary identifier.
 
std::string decode64 (NetInt64 code)
 Convert a vocabulary identifier into a string.
 

Detailed Description

Short readable codes.

They are integers, for efficient switching, but have a readable (and writable) string representation. Codes are limited to 8 characters long (to fit in a 64 bit network integer, NetInt64). This is a compromise to allow the creation of messages that can be parsed very efficiently by machine but nevertheless are human readable and writable.

switch(code) {
case createVocab('s','e','t'): // switch on "set"
...
case createVocab('s','t','o','p'): // switch on "stop"
...
}
A mini-server for performing network communication in the background.

Your program will be efficient, and the codes used if they traverse the network will be human readable/writable.

Function Documentation

◆ decode64()

std::string yarp::os::Vocab64::decode64 ( NetInt64  code)

Convert a vocabulary identifier into a string.

Parameters
codethe vocabulary identifier to convert
Returns
the string equivalent of the integer form of the identifier

Definition at line 48 of file Vocab64.cpp.

◆ encode64()

NetInt64 yarp::os::Vocab64::encode64 ( const std::string &  str)

Convert a string into a vocabulary identifier.

If the string is longer than four characters, only the first four characters are used.

Parameters
strthe string to convert
Returns
the integer equivalent of the string form of the identifier

Definition at line 10 of file Vocab64.cpp.