ArrayTypeTraits.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2014 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
23 #ifndef VARIANT_TOPIC_TOOLS_ARRAY_TYPE_TRAITS_H
24 #define VARIANT_TOPIC_TOOLS_ARRAY_TYPE_TRAITS_H
25 
26 #include <vector>
27 
28 #include <boost/array.hpp>
29 #include <boost/type_traits.hpp>
30 
33 
34 namespace variant_topic_tools {
35  namespace type_traits {
36  template <typename T> struct IsArray :
37  public boost::false_type {
38  };
39 
40  template <typename T> struct IsArray<T[]> :
41  public boost::true_type {
42  };
43 
44  template <typename T, size_t N> struct IsArray<T[N]> :
45  public boost::true_type {
46  };
47 
48  template <size_t N> struct IsArray<char[N]> :
49  public boost::false_type {
50  };
51 
52  template <typename T, typename D = void> struct ArrayMemberType {
53  typedef T ValueType;
54  };
55 
56  template <typename D> struct ArrayMemberType<bool, D> {
57  typedef uint8_t ValueType;
58  };
59 
60  template <typename T> struct ArrayType;
61 
62  template <typename T> struct ArrayType<T[]> {
63  typedef T MemberType;
65  typedef std::vector<MemberValueType> ValueType;
66  static const size_t NumMembers = 0;
67  typedef boost::true_type IsDynamic;
70  };
71 
72  template <typename T, size_t N> struct ArrayType<T[N]> {
73  typedef T MemberType;
75  typedef boost::array<MemberValueType, N> ValueType;
76  static const size_t NumMembers = N;
77  typedef boost::false_type IsDynamic;
80  };
81 
82  template <typename T> struct ToArrayType {
83  typedef T ArrayType;
84  };
85 
86  template <typename T> struct ToArrayType<std::vector<T> > {
87  typedef T ArrayType[];
88  };
89 
90  template <typename T, size_t N> struct ToArrayType<boost::array<T, N> > {
91  typedef T ArrayType[N];
92  };
93  };
94 };
95 
96 #endif
ros::message_traits::IsSimple< ValueType > IsSimple
ArrayMemberType< T >::ValueType MemberValueType
Header file providing the built-in type traits.
ros::message_traits::IsFixedSize< ValueType > IsFixedSize
ArrayMemberType< T >::ValueType MemberValueType
Header file providing the message type traits.
ros::message_traits::IsSimple< ValueType > IsSimple
ros::message_traits::IsFixedSize< ValueType > IsFixedSize
boost::array< MemberValueType, N > ValueType


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:49