stringtree.hpp
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 #pragma once
36 
37 #include <vector>
38 #include <map>
39 #include <iostream>
40 #include <boost/container/small_vector.hpp>
41 #include <boost/container/static_vector.hpp>
42 #include <boost/utility/string_ref.hpp>
44 #include <fastcdr/FastBuffer.h>
45 
46 namespace Ros2Introspection{
47 
48 using StringView = boost::string_ref;
49 
50 struct BufferView {
51  const char* data;
52  size_t size;
53  BufferView(): data(nullptr), size(0) {}
54  BufferView(const char* _data, size_t _size): data(_data), size(_size) {}
55 };
56 
58 
60 
80 
82 
84 
85  boost::container::static_vector<uint16_t,8> index_array;
86 
88  int toStr(std::string &destination) const;
89 
90  std::string toStdString() const {
91  std::string out;
92  toStr(out);
93  return out;
94  }
95 
96  constexpr static const char SEPARATOR = '/';
97  constexpr static const char NUM_PLACEHOLDER = '#';
98 };
99 
100 void CreateStringFromTreeLeaf(const StringTreeLeaf& leaf, bool skip_root, std::string &out);
101 
102 //---------------------------------
103 
104 inline std::ostream& operator<<(std::ostream &os, const StringTreeLeaf& leaf )
105 {
106  std::string dest;
107  leaf.toStr(dest);
108  os << dest;
109  return os;
110 }
111 
113 { }
114 
115 
116 
117 
118 }
119 
120 
BufferView(const char *_data, size_t _size)
Definition: stringtree.hpp:54
#define nullptr
std::ostream & operator<<(std::ostream &os, const StringTreeLeaf &leaf)
Definition: stringtree.hpp:104
The StringTreeLeaf is, as the name suggests, a leaf (terminal node) of a StringTree. It provides the pointer to the node and a list of numbers that represent the index that corresponds to the placeholder "#".
Definition: stringtree.hpp:79
std::add_lvalue_reference< decltype(std::declval< FormatContext >).out())>::type out
const StringTreeNode * node_ptr
Definition: stringtree.hpp:83
boost::container::static_vector< uint16_t, 8 > index_array
Definition: stringtree.hpp:85
Element of the tree. it has a single parent and N >= 0 children.
void CreateStringFromTreeLeaf(const StringTreeLeaf &leaf, bool skip_root, std::string &out)
boost::string_ref StringView
Definition: stringtree.hpp:48
std::string toStdString() const
Definition: stringtree.hpp:90
int toStr(std::string &destination) const
Utility functions to print the entire branch.
Definition: stringtree.cpp:73
const char * toStr(const BuiltinType &c)
char * dest


plotjuggler_ros
Author(s): Davide Faconti
autogenerated on Fri Jun 23 2023 02:28:04