rmw_fastrtps_shared_cpp  master
Code shared on static and dynamic type support of rmw_fastrtps_cpp.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
names.hpp
Go to the documentation of this file.
1 // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RMW_FASTRTPS_SHARED_CPP__NAMES_HPP_
16 #define RMW_FASTRTPS_SHARED_CPP__NAMES_HPP_
17 
18 #include <string>
19 
20 #include "fastrtps/utils/fixed_size_string.hpp"
21 #include "rmw/types.h"
22 #include "namespace_prefix.hpp"
23 
25 
30 inline
31 eprosima::fastrtps::string_255
33  const char * prefix,
34  const char * base,
35  const char * suffix = nullptr)
36 {
37  std::ostringstream topicName;
38  if (prefix) {
39  topicName << prefix;
40  }
41  topicName << base;
42  if (suffix) {
43  topicName << suffix;
44  }
45  return topicName.str();
46 }
47 
49 
55 inline
56 eprosima::fastrtps::string_255
58  const rmw_qos_profile_t * qos_profile,
59  const char * prefix,
60  const char * base,
61  const char * suffix = nullptr)
62 {
63  assert(qos_profile);
64  assert(base);
65  if (qos_profile->avoid_ros_namespace_conventions) {
66  prefix = nullptr;
67  }
68  return _mangle_topic_name(prefix, base, suffix);
69 }
70 
71 #endif // RMW_FASTRTPS_SHARED_CPP__NAMES_HPP_
_create_topic_name
eprosima::fastrtps::string_255 _create_topic_name(const rmw_qos_profile_t *qos_profile, const char *prefix, const char *base, const char *suffix=nullptr)
Construct a topic name according to proper conventions.
Definition: names.hpp:57
_mangle_topic_name
eprosima::fastrtps::string_255 _mangle_topic_name(const char *prefix, const char *base, const char *suffix=nullptr)
Construct a topic name.
Definition: names.hpp:32
rmw_qos_profile_t::avoid_ros_namespace_conventions
bool avoid_ros_namespace_conventions
namespace_prefix.hpp
std::ostringstream
rmw_qos_profile_t
std::ostringstream::str
T str(T... args)
types.h