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 
38 
39 namespace RosIntrospection{
40 
41 ROSType::ROSType(boost::string_ref name):
42  _base_name(name)
43 {
44  int pos = -1;
45  for (size_t i=0; i<name.size(); i++)
46  {
47  if(name[i] == '/'){
48  pos = i;
49  break;
50  }
51  }
52 
53  if( pos == -1)
54  {
56  }
57  else{
58  _pkg_name = boost::string_ref( _base_name.data(), pos);
59  pos++;
60  _msg_name = boost::string_ref( _base_name.data() + pos, _base_name.size() - pos);
61  }
62 
64  _hash = std::hash<std::string>{}( _base_name );
65 }
66 
68 {
69  int pos = other._pkg_name.size();
70  _base_name = other._base_name;
71  _pkg_name = boost::string_ref( _base_name.data(), pos);
72  if( pos > 0) pos++;
73  _msg_name = boost::string_ref( _base_name.data() + pos, _base_name.size() - pos);
74  _id = other._id;
75  _hash = other._hash;
76  return *this;
77 }
78 
80 {
81  int pos = other._pkg_name.size();
82  _base_name = std::move( other._base_name );
83  _pkg_name = boost::string_ref( _base_name.data(), pos);
84  if( pos > 0) pos++;
85  _msg_name = boost::string_ref( _base_name.data() + pos, _base_name.size() - pos);
86  _id = other._id;
87  _hash = other._hash;
88  return *this;
89 }
90 
91 
92 void ROSType::setPkgName(boost::string_ref new_pkg)
93 {
94  assert(_pkg_name.size() == 0);
95 
96  int pos = new_pkg.size();
97  _base_name = new_pkg.to_string() + "/" + _base_name;
98 
99  _pkg_name = boost::string_ref( _base_name.data(), pos++);
100  _msg_name = boost::string_ref( _base_name.data() + pos, _base_name.size() - pos);
101 
102  _hash = std::hash<std::string>{}( _base_name );
103 }
104 
105 
106 }
ROSType & operator=(const ROSType &other)
Definition: ros_type.cpp:67
boost::string_ref _msg_name
Definition: ros_type.hpp:104
BuiltinType toBuiltinType(const boost::string_ref &s)
Definition: ros_type.hpp:150
void setPkgName(boost::string_ref new_pkg)
Definition: ros_type.cpp:92
boost::string_ref _pkg_name
Definition: ros_type.hpp:105


ros_type_introspection
Author(s): Davide Faconti
autogenerated on Sun Sep 6 2020 03:19:54