Wolframe, 0.0.3

traits_getCategory.hpp
Go to the documentation of this file.
1 /************************************************************************
2 Copyright (C) 2011 - 2014 Project Wolframe.
3 All rights reserved.
4 
5 This file is part of Project Wolframe.
6 
7 Commercial Usage
8 Licensees holding valid Project Wolframe Commercial licenses may
9 use this file in accordance with the Project Wolframe
10 Commercial License Agreement provided with the Software or,
11 alternatively, in accordance with the terms contained
12 in a written agreement between the licensee and Project Wolframe.
13 
14 GNU General Public License Usage
15 Alternatively, you can redistribute this file and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19 
20 Wolframe is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24 
25 You should have received a copy of the GNU General Public License
26 along with Wolframe. If not, see <http://www.gnu.org/licenses/>.
27 
28 If you have questions regarding the use of this file, please contact
29 Project Wolframe.
30 
31 ************************************************************************/
34 
35 #ifndef _Wolframe_SERIALIZE_STRUCT_TRAITS_GET_CATEGORY_HPP_INCLUDED
36 #define _Wolframe_SERIALIZE_STRUCT_TRAITS_GET_CATEGORY_HPP_INCLUDED
38 #include "logger/logLevel.hpp"
39 #include "types/datetime.hpp"
40 #include "types/bignumber.hpp"
41 #include <boost/lexical_cast.hpp>
42 #include <boost/utility/enable_if.hpp>
43 #include <boost/type_traits.hpp>
44 #include <boost/detail/select_type.hpp>
45 #include <boost/type_traits/function_traits.hpp>
46 #include <vector>
47 #include <string>
48 
49 namespace _Wolframe {
50 namespace serialize {
51 namespace traits {
52 
53 struct struct_ {};
54 struct vector_ {};
55 struct atomic_ {};
56 
59 template<typename T,bool is_class_type=boost::is_class<T>::value>
60 struct has_description_method: boost::false_type {};
61 
62 template<typename T>
64 {
65  typedef char small_type;
66  struct large_type {small_type dummy[2];};
67 
68  template<const StructDescriptionBase* (*)()> struct tester_static_signature;
69 
70  template<typename U>
72  template<typename U>
73  static large_type has_matching_member(...);
74 
76  static const bool value=sizeof(has_matching_member<T>(0))==sizeof(small_type);
77 };
78 
79 template<typename T>
80 struct has_description_method<T,true>:
81  boost::integral_constant<bool, has_description_method_noprm<T>::value>
82 {};
83 
84 
87 template <typename T>
88 typename boost::enable_if_c<
89  boost::is_same< std::vector< typename T::value_type> ,T>::value && !boost::is_same<std::string,T>::value
90  ,const vector_&>::type getCategory( const T&) { static vector_ rt; return rt;}
91 
94 template <typename T>
95 typename boost::enable_if_c<
96  has_description_method<T>::value
97  ,const struct_&>::type getCategory( const T&) { static struct_ rt; return rt;}
98 
101 template <typename T>
102 typename boost::enable_if_c<
103  boost::is_arithmetic<T>::value
104  || boost::is_same<std::string,T>::value
105  || boost::is_same<types::DateTime,T>::value
106  || boost::is_same<types::BigNumber,T>::value
107  ,const atomic_&>::type getCategory( const T&) { static atomic_ rt; return rt;}
108 
109 }}}// end namespace
110 #endif
char small_type
Definition: traits_getCategory.hpp:65
Type for representing arbitrary precision fixed point numbers and big integers as binary coded decima...
category tag for a structure with named elements
Definition: traits_getCategory.hpp:53
category tag for a std::vector of any type
Definition: traits_getCategory.hpp:54
Defines allowed log levels of the logger.
category tag for an atomic type
Definition: traits_getCategory.hpp:55
conditional template for detecting if a type is a class with a static/member method getStructDescript...
Definition: traits_getCategory.hpp:60
Date and datetime value type.
static const bool value
value with the boolean property corresponding has getStructDescription static/member method without p...
Definition: traits_getCategory.hpp:76
small_type dummy[2]
Definition: traits_getCategory.hpp:66
Defines the non intrusive base class of serialization/deserialization of objects interfaced as TypedI...
static small_type has_matching_member(tester_static_signature<&U::getStructDescription > *)
boost::enable_if_c< boost::is_same< std::vector< typename T::value_type >,T >::value &&!boost::is_same< std::string, T >::value,const vector_ & >::type getCategory(const T &)
get category vector_ for a type
Definition: traits_getCategory.hpp:90