11 #ifndef _STRUS_ANALYZER_FUNCTION_VIEW_HPP_INCLUDED
12 #define _STRUS_ANALYZER_FUNCTION_VIEW_HPP_INCLUDED
13 #include "strus/base/enable_if.hpp"
14 #include "strus/base/type_traits.hpp"
15 #include "strus/numericVariant.hpp"
38 :m_name(o.m_name),m_parameter(o.m_parameter){}
42 FunctionView(
const std::string& name_,
const std::vector<NamedParameter>& params_)
43 :m_name(name_),m_parameter(params_){}
48 :m_name(name_),m_parameter(){}
51 template<
typename type>
54 typename strus::enable_if<
55 strus::is_arithmetic<type>::value
56 || strus::is_same<bool,type>::value
57 || strus::is_same<std::string,type>::value
58 || strus::is_same<char*,type>::value
66 template <
typename value_type>
69 std::ostringstream out;
78 template <
typename value_type>
79 typename strus::enable_if<is_atomic<value_type>::value,
FunctionView&>::type
operator()(
const char* name_,
const std::map<std::string,value_type>& value_)
81 typename std::map<std::string,value_type>::const_iterator vi = value_.begin(), ve = value_.end();
82 for (; vi != ve; ++vi)
84 std::ostringstream out;
86 m_parameter.push_back(
NamedParameter( std::string(name_)+
"::"+vi->first, out.str()));
94 template <
typename value_type>
95 typename strus::enable_if<is_atomic<value_type>::value,
FunctionView&>::type
operator()(
const char* name_,
const std::vector<value_type>& value_)
97 typename std::vector<value_type>::const_iterator vi = value_.begin(), ve = value_.end();
98 for (; vi != ve; ++vi)
100 std::ostringstream out;
102 m_parameter.push_back(
NamedParameter( std::string(
"[]")+name_, out.str()));
110 template <
typename value_type>
113 std::ostringstream out;
114 out << value_.tostring().c_str();
121 const std::string&
name()
const {
return m_name;}
126 const std::vector<NamedParameter>&
parameter()
const {
return m_parameter;}
130 std::vector<NamedParameter> m_parameter;
std::pair< std::string, std::string > NamedParameter
Definition: functionView.hpp:32
strus::enable_if< is_atomic< value_type >::value, FunctionView & >::type operator()(const char *name_, const std::map< std::string, value_type > &value_)
Operator to build parameter list (for map of string to atomic value type)
Definition: functionView.hpp:79
strus::enable_if< is_atomic< value_type >::value, FunctionView & >::type operator()(const char *name_, const value_type &value_)
Operator to build parameter list (for atomic value type)
Definition: functionView.hpp:67
FunctionView(const std::string &name_)
Constructor.
Definition: functionView.hpp:47
Structure describing the internal representation of a normalizer/tokenizer/aggregator function in the...
Definition: functionView.hpp:29
FunctionView(const FunctionView &o)
Copy constructor.
Definition: functionView.hpp:37
strus::enable_if< is_atomic< value_type >::value, FunctionView & >::type operator()(const char *name_, const std::vector< value_type > &value_)
Operator to build parameter list (for map of string to atomic value type)
Definition: functionView.hpp:95
strus::enable_if< strus::is_arithmetic< type >::value||strus::is_same< bool, type >::value||strus::is_same< std::string, type >::value||strus::is_same< char *, type >::value,bool > value_type
Definition: functionView.hpp:59
strus::enable_if< strus::is_same< NumericVariant, value_type >::value, FunctionView & >::type operator()(const char *name_, const value_type &value_)
Operator to build parameter list (for value type numeric variant)
Definition: functionView.hpp:111
Definition: functionView.hpp:60
FunctionView(const std::string &name_, const std::vector< NamedParameter > ¶ms_)
Constructor.
Definition: functionView.hpp:42
const std::string & name() const
Get the name of the function.
Definition: functionView.hpp:121
FunctionView()
Default constructor.
Definition: functionView.hpp:35
const std::vector< NamedParameter > & parameter() const
Get the internal representation of the named parameters of the function.
Definition: functionView.hpp:126
Conditional for atomic type.
Definition: functionView.hpp:52