Gazebo Transport

API Reference

11.4.1
gz/transport/Helpers.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GZ_TRANSPORT_HELPERS_HH_
19 #define GZ_TRANSPORT_HELPERS_HH_
20 
21 #include <zmq.hpp>
22 
23 #include <cstdint>
24 #include <cstdio>
25 #include <cstring>
26 #include <limits>
27 #include <string>
28 #include <vector>
29 
30 #include "gz/transport/config.hh"
31 #include "gz/transport/Export.hh"
32 
33 // Avoid using deprecated message send/receive function when possible.
34 #if ZMQ_VERSION > ZMQ_MAKE_VERSION(4, 3, 1)
35  #define IGN_ZMQ_POST_4_3_1
36 #endif
37 
38 // Avoid using deprecated set function when possible
39 #if CPPZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 7, 0)
40  // Ubuntu Focal (20.04) packages a different "4.7.0"
41  // And so does apparently Debian Bullseye
42  #if !defined(UBUNTU_FOCAL) && !defined(DEBIAN_BULLSEYE)
43  #define IGN_CPPZMQ_POST_4_7_0
44  #endif
45 #endif
46 
47 namespace ignition
48 {
49  namespace transport
50  {
51  // Inline bracket to help doxygen filtering.
52  inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
53  //
56 
61  bool IGNITION_TRANSPORT_VISIBLE env(const std::string &_name,
62  std::string &_value);
63 
68  std::vector<std::string> IGNITION_TRANSPORT_VISIBLE split(
69  const std::string &_orig,
70  char _delim);
71 
74  unsigned int IGNITION_TRANSPORT_VISIBLE getProcessId();
75 
76  // Use safer functions on Windows
77  #ifdef _MSC_VER
78  #define ign_strcat strcat_s
79  #define ign_strcpy strcpy_s
80  #define ign_sprintf sprintf_s
81  #define ign_strdup _strdup
82  #else
83  #define ign_strcat std::strcat
84  #define ign_strcpy std::strcpy
85  #define ign_sprintf std::sprintf
86  #define ign_strdup strdup
87  #endif
88  }
89  }
90 }
91 
92 // IGN_TRANSPORT_HELPERS_HH_
93 #endif
Definition: gz/transport/AdvertiseOptions.hh:28
STL class.
std::vector< std::string > split(const std::string &_orig, char _delim)
split at a one character delimiter to get a vector of something
unsigned int getProcessId()
Portable function to get the id of the current process.
static const uint64_t kUnthrottled
Constant used when not interested in throttling.
Definition: gz/transport/Helpers.hh:55
bool env(const std::string &_name, std::string &_value)
Find the environment variable '_name' and return its value.
T max(T... args)