YARP
Yet Another Robot Platform
Vocab.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_VOCAB_H
11 #define YARP_OS_VOCAB_H
12 
13 #include <yarp/os/NetInt32.h>
14 
15 #include <string>
16 
17 namespace yarp {
18 namespace os {
19 
20 // We need a constexpr for efficient switching.
21 // Use as, for example, createVocab('s','e','t')
22 constexpr yarp::conf::vocab32_t createVocab(char a, char b = 0, char c = 0, char d = 0)
23 {
24  return ((yarp::conf::vocab32_t)a) +
25  ((yarp::conf::vocab32_t)b << 8) +
26  ((yarp::conf::vocab32_t)c << 16) +
27  ((yarp::conf::vocab32_t)d << 24);
28 }
29 
51 namespace Vocab {
52 
60 YARP_os_API NetInt32 encode(const std::string& str);
61 
67 YARP_os_API std::string decode(NetInt32 code);
68 
69 } // namespace Vocab
70 } // namespace os
71 } // namespace yarp
72 
73 #ifndef YARP_NO_DEPRECATED // since YARP 3.1.0
74 YARP_DEPRECATED_MSG("Use yarp::os::createVocab() instead")
75 constexpr int32_t VOCAB(char a, char b, char c, char d)
76 {
77  return yarp::os::createVocab(a, b, c, d);
78 }
79 YARP_DEPRECATED_MSG("Use yarp::os::createVocab() instead")
80 constexpr int32_t VOCAB4(char a, char b, char c, char d)
81 {
82  return yarp::os::createVocab(a, b, c, d);
83 }
84 YARP_DEPRECATED_MSG("Use yarp::os::createVocab() instead")
85 constexpr int32_t VOCAB3(char a, char b, char c)
86 {
87  return yarp::os::createVocab(a, b, c, 0);
88 }
89 YARP_DEPRECATED_MSG("Use yarp::os::createVocab() instead")
90 constexpr int32_t VOCAB2(char a, char b)
91 {
92  return yarp::os::createVocab(a, b, 0, 0);
93 }
94 YARP_DEPRECATED_MSG("Use yarp::os::createVocab() instead")
95 constexpr int32_t VOCAB1(char a)
96 {
97  return yarp::os::createVocab(a, 0, 0, 0);
98 }
99 #endif // YARP_NO_DEPRECATED
100 
101 #endif // YARP_OS_VOCAB_H
yarp::os::createVocab
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:22
NetInt32.h
YARP_os_API
#define YARP_os_API
Definition: api.h:19
yarp::os::Vocab::decode
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
Definition: Vocab.cpp:36
VOCAB
constexpr int32_t VOCAB(char a, char b, char c, char d)
Definition: Vocab.h:75
yarp::os::Vocab::encode
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
Definition: Vocab.cpp:14
VOCAB2
constexpr int32_t VOCAB2(char a, char b)
Definition: Vocab.h:90
VOCAB4
constexpr int32_t VOCAB4(char a, char b, char c, char d)
Definition: Vocab.h:80
YARP_DEPRECATED_MSG
#define YARP_DEPRECATED_MSG(MSG)
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
Definition: compiler.h:2883
VOCAB3
constexpr int32_t VOCAB3(char a, char b, char c)
Definition: Vocab.h:85
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::conf::vocab32_t
std::int32_t vocab32_t
Definition: numeric.h:52
VOCAB1
constexpr int32_t VOCAB1(char a)
Definition: Vocab.h:95
yarp::os::NetInt32
std::int32_t NetInt32
Definition of the NetInt32 type.
Definition: NetInt32.h:33