YARP
Yet Another Robot Platform
Vocab.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 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 #include <string>
15 
16 
39 namespace yarp {
40 namespace os {
41 // We need a constexpr for efficient switching.
42 // Use as, for example, createVocab('s','e','t')
43 constexpr yarp::conf::vocab32_t createVocab(char a, char b = 0, char c = 0, char d = 0) {
44  return ((yarp::conf::vocab32_t)a) +
45  ((yarp::conf::vocab32_t)b<<8) +
46  ((yarp::conf::vocab32_t)c<<16)+
47  ((yarp::conf::vocab32_t)d<<24);
48 }
49 
50 namespace Vocab {
58  YARP_OS_API NetInt32 encode(const std::string& str);
59 
65  YARP_OS_API std::string decode(NetInt32 code);
66 } // Vocab
67 } // os
68 } // yarp
69 
70 #ifndef YARP_NO_DEPRECATED // since YARP 3.1.0
71 YARP_DEPRECATED_MSG("Use yarp::os::createVocab() instead")
72 constexpr int32_t VOCAB(char a, char b, char c, char d) { return yarp::os::createVocab(a,b,c,d); }
73 YARP_DEPRECATED_MSG("Use yarp::os::createVocab() instead")
74 constexpr int32_t VOCAB4(char a, char b, char c, char d) { return yarp::os::createVocab(a,b,c,d); }
75 YARP_DEPRECATED_MSG("Use yarp::os::createVocab() instead")
76 constexpr int32_t VOCAB3(char a, char b, char c) { return yarp::os::createVocab(a,b,c,0); }
77 YARP_DEPRECATED_MSG("Use yarp::os::createVocab() instead")
78 constexpr int32_t VOCAB2(char a, char b) { return yarp::os::createVocab(a,b,0,0); }
79 YARP_DEPRECATED_MSG("Use yarp::os::createVocab() instead")
80 constexpr int32_t VOCAB1(char a) { return yarp::os::createVocab(a,0,0,0); }
81 #endif // YARP_NO_DEPRECATED
82 
83 #endif // YARP_OS_VOCAB_H
constexpr int32_t VOCAB4(char a, char b, char c, char d)
Definition: Vocab.h:74
constexpr int32_t VOCAB2(char a, char b)
Definition: Vocab.h:78
#define YARP_OS_API
Definition: api.h:19
std::int32_t vocab32_t
Definition: numeric.h:52
The main, catch-all namespace for YARP.
Definition: numeric.h:47
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
Definition: Vocab.cpp:35
constexpr int32_t VOCAB(char a, char b, char c, char d)
Definition: Vocab.h:72
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
Definition: Vocab.cpp:14
std::int32_t NetInt32
Definition of the NetInt32 type.
Definition: NetInt32.h:32
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:43
constexpr int32_t VOCAB3(char a, char b, char c)
Definition: Vocab.h:76
constexpr int32_t VOCAB1(char a)
Definition: Vocab.h:80
#define YARP_DEPRECATED_MSG(MSG)
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
Definition: compiler.h:2838