YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Vocab.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_OS_VOCAB_H
8#define YARP_OS_VOCAB_H
9
10#include <yarp/os/NetInt32.h>
11
12#include <string>
13
14namespace yarp::os {
15
16// We need a constexpr for efficient switching.
27constexpr yarp::conf::vocab32_t createVocab32(char a, char b = 0, char c = 0, char d = 0)
28{
29 return (static_cast<yarp::conf::vocab32_t>(a)) +
30 (static_cast<yarp::conf::vocab32_t>(b) << 8) +
31 (static_cast<yarp::conf::vocab32_t>(c) << 16) +
32 (static_cast<yarp::conf::vocab32_t>(d) << 24);
33}
34
56namespace Vocab32 {
57
65YARP_os_API NetInt32 encode(const std::string& str);
66
72YARP_os_API std::string decode(NetInt32 code);
73
74} // namespace Vocab32
75
76} // namespace yarp::os
77
78#endif // YARP_OS_VOCAB_H
A mini-server for performing network communication in the background.
std::int32_t vocab32_t
Definition numeric.h:78
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
Definition Vocab.cpp:11
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
Definition Vocab.cpp:33
An interface to the operating system, including Port based communication.
std::int32_t NetInt32
Definition of the NetInt32 type.
Definition NetInt32.h:29
constexpr yarp::conf::vocab32_t createVocab32(char a, char b=0, char c=0, char d=0)
Create a vocab from chars.
Definition Vocab.h:27
#define YARP_os_API
Definition api.h:18