ros_type.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright 2016-2017 Davide Faconti
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 * *******************************************************************/
34 
35 
39 
40 namespace RosIntrospection{
41 
43  _base_name(name)
44 {
45  int pos = -1;
46  for (size_t i=0; i<name.size(); i++)
47  {
48  if(name[i] == '/'){
49  pos = i;
50  break;
51  }
52  }
53 
54  if( pos == -1)
55  {
57  }
58  else{
59  _pkg_name = absl::string_view( _base_name.data(), pos);
60  pos++;
61  _msg_name = absl::string_view( _base_name.data() + pos, _base_name.size() - pos);
62  }
63 
65  _hash = std::hash<std::string>{}( _base_name );
66 }
67 
69 {
70  int pos = other._pkg_name.size();
71  _base_name = other._base_name;
72  _pkg_name = absl::string_view( _base_name.data(), pos);
73  if( pos > 0) pos++;
74  _msg_name = absl::string_view( _base_name.data() + pos, _base_name.size() - pos);
75  _id = other._id;
76  _hash = other._hash;
77  return *this;
78 }
79 
81 {
82  int pos = other._pkg_name.size();
83  _base_name = std::move( other._base_name );
84  _pkg_name = absl::string_view( _base_name.data(), pos);
85  if( pos > 0) pos++;
86  _msg_name = absl::string_view( _base_name.data() + pos, _base_name.size() - pos);
87  _id = other._id;
88  _hash = other._hash;
89  return *this;
90 }
91 
92 
94 {
95  assert(_pkg_name.size() == 0);
96 
97  int pos = new_pkg.size();
98  _base_name = absl::Substitute("$0/$1", new_pkg, _base_name);
99 
100  _pkg_name = absl::string_view( _base_name.data(), pos++);
101  _msg_name = absl::string_view( _base_name.data() + pos, _base_name.size() - pos);
102 
103  _hash = std::hash<std::string>{}( _base_name );
104 }
105 
106 
107 }
BuiltinType toBuiltinType(const absl::string_view &s)
Definition: ros_type.hpp:150
absl::string_view _msg_name
Definition: ros_type.hpp:104
ROSType & operator=(const ROSType &other)
Definition: ros_type.cpp:68
absl::string_view _pkg_name
Definition: ros_type.hpp:105
constexpr size_type size() const noexcept
void setPkgName(absl::string_view new_pkg)
Definition: ros_type.cpp:93
int i
ABSL_MUST_USE_RESULT std::string Substitute(absl::string_view format)


ros_type_introspection
Author(s): Davide Faconti
autogenerated on Thu May 16 2019 02:39:09