Apama  10.0.0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
functions.hpp
Go to the documentation of this file.
1 /*
2  * Title: bits/functions.hpp
3  * Description: C++ header-only wrapper for C-ABI data_t type
4  * $Copyright (c) 2015-2016 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.$
5  * Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG
6  * @Version: $Id: functions.hpp 294926 2016-11-09 18:33:24Z matj $
7  */
8 
15 #ifndef _DATAT_BITS_INCLUDE_TAG
16 #error Must only be included from sag_connectivity_cpp.hpp, use that instead
17 #endif
18 
19 #include <sag_internal/convert_to.hpp>
20 
37 template<typename V>
38 inline typename V::result_type apply_visitor(const V&v, data_t& t) { return t.apply_visitor(v); }
55 template<typename V>
56 inline typename V::result_type apply_visitor(const V&v, const data_t& t) { return t.apply_visitor(v); }
57 
68 template<typename T>
69 inline typename get_details::GetVisitor<const T>::result_type get(const data_t &t) { return apply_visitor(get_details::GetVisitor<const T>(), t); }
73 template<>
74 inline const data_t &get<const data_t&>(const data_t &t) { return t; }
85 template<typename T>
86 inline typename get_details::GetVisitor<T>::result_type get(data_t &t) { return apply_visitor(get_details::GetVisitor<T>(), t); }
90 template<>
91 inline data_t &get<data_t&>(data_t &t) { return t; }
99 template<typename T>
100 inline typename get_details::GetVisitor<custom_t<T> >::result_type get_custom(data_t &t) { return apply_visitor(get_details::GetVisitor<custom_t<T> >(), t); }
108 template<typename T>
109 inline typename get_details::GetVisitor<const custom_t<T> >::result_type get_custom(const data_t &t) { return apply_visitor(get_details::GetVisitor<const custom_t<T> >(), t); }
110 
122 template<typename T>
123 inline T convert_to(const data_t &d)
124 {
125  return apply_visitor(convert_to_details::_get_or_convert<T>(d.type_name()), d);
126 }
127 
128 
129 
get_details::GetVisitor< custom_t< T > >::result_type get_custom(data_t &t)
Get the contents of the data_t as a typed custom_t.
Definition: functions.hpp:100
const char * type_name() const
Return the name of the contained type as a string (mainly useful for debugging)
Definition: data_t.hpp:131
T convert_to(const data_t &d)
Get a T from a data_t, parsing it from a string if necessary/possible.
Definition: functions.hpp:123
data_t & get< data_t & >(data_t &t)
Specialization to be a pass-through, for use in a templated context.
Definition: functions.hpp:91
V::result_type apply_visitor(const V &v) const
Apply a visitor (using the boost::static_visitor pattern) to this data_t.
A wrapper type for holding arbitrary objects inside a data_t.
Definition: custom_t.hpp:42
const data_t & get< const data_t & >(const data_t &t)
Specialization to be a pass-through, for use in a templated context.
Definition: functions.hpp:74
A variant type which can be one of the following:
Definition: data_t.hpp:42
V::result_type apply_visitor(const V &v, data_t &t)
Apply a visitor (using the boost::static_visitor pattern) to the given data_t.
Definition: functions.hpp:38