6#ifndef ADOBE_ARG_STREAM_H
7#define ADOBE_ARG_STREAM_H
9#include <boost/function_types/function_arity.hpp>
10#include <boost/function_types/function_type.hpp>
11#include <boost/function_types/result_type.hpp>
13#include <boost/mpl/begin.hpp>
14#include <boost/mpl/deref.hpp>
15#include <boost/mpl/end.hpp>
16#include <boost/mpl/next.hpp>
23#include <boost/fusion/include/cons.hpp>
24#include <boost/fusion/include/invoke.hpp>
25#include <boost/fusion/include/push_back.hpp>
27#include <boost/utility/enable_if.hpp>
89struct has_eof_member {
112template <
class ArgStream>
114eof_check(ArgStream& as,
119template <
class ArgStream>
120static bool eof_check(
122 typename boost::disable_if_c<traits<ArgStream>::has_eof_memberfunction>
::type* dummy = 0) {
126template <
class ArgStream>
127static bool eof_check(ArgStream* as) {
128 return as ? eof_check(*as) : true;
147template <
typename ArgStream>
148bool eof(ArgStream
const& as) {
149 return detail::eof_check(as);
166template <
typename R,
typename ArgStream>
168 return as.get_next_arg<R>();
171template <
typename R,
typename ArgStream>
173 return as.get_next_arg<R>();
175template <
typename R,
typename ArgStream>
179template <
typename R,
typename ArgStream>
212 typedef typename boost::function_types::result_type<typename signature<F>::type>
::type type;
220struct remove_cv_ref : boost::remove_cv<typename boost::remove_reference<T>::type> {};
231 class From =
typename boost::mpl::begin<
232 boost::function_types::parameter_types<typename signature<F>::type>>
::type,
233 class To =
typename boost::mpl::end<
234 boost::function_types::parameter_types<typename signature<F>::type>>
::type>
237 template <
typename Args,
typename ArgStream>
240 typedef typename remove_cv_ref<typename boost::mpl::deref<From>::type>
::type arg_type;
241 typedef typename boost::mpl::next<From>::type next_iter_type;
243 return invoker<F, next_iter_type, To>::apply(
249template <
typename F,
class To>
250struct invoker<F, To, To> {
251 template <
typename Args,
typename ArgStream>
253 return boost::fusion::invoke(func, args);
268template <
typename F,
typename ArgStream>
270 return detail::invoker<F>::template apply(f, astream, boost::fusion::nil());
278template <
class T,
typename F,
typename ArgStream>
284 boost::fusion::nil args;
285 return detail::invoker<
287 typename boost::mpl::next<
typename boost::mpl::begin<boost::function_types::parameter_types<
290 typename boost::mpl::end<boost::function_types::parameter_types<
292 template apply(f, astream, boost::fusion::push_back(args, that));
305template <
typename ArgStreamFirst,
typename ArgStreamSecond>
307 template <
class ArgStream>
309 return detail::eof_check(as);
317 chain(ArgStreamFirst& first_stream, ArgStreamSecond& second_stream)
320 template <
typename T>
324 return first->get_next_arg<T>();
330 return second->get_next_arg<T>();
336template <
typename S1,
typename S2>
344template <
typename ArgStreamFirst,
typename ArgStreamSecond>
346 ArgStreamSecond& second_stream) {
354 bool eof() {
return true; }
356 template <
typename R>
383 single(
typename boost::add_reference<T const>::type t,
unsigned int count = 1)
388 template <
typename R>
391 typename boost::enable_if<boost::is_convertible<value_type, R>>
::type* dummy = 0) {
394 template <
typename R>
397 typename boost::disable_if<boost::is_convertible<value_type, R>>
::type* dummy = 0) {
402 template <
typename R>
419template <
typename ArgStream,
typename Transformer>
423 template <
typename Class>
428 template <
typename Class,
typename R,
bool>
432 template <
typename Class,
typename R>
438 template <
typename Class,
typename R>
455 template <
typename R>
457 typedef typename Transformer::template arg_stream_inverse_lookup<R>::type Rfrom;
458 return transformer.template arg_stream_transform<R>(
461 template <
typename R>
466 template <
typename R>
472template <
typename ArgStream,
typename Transformer>
An exception class thrown during ASL failures to cast.
R get_next_arg(ArgStream const &as)
arg_stream::get_next_arg<T>(argstream) returns the next arg as a T
result_type< F >::type call(F f, ArgStream &astream)
Calls function/callable-object f with function arguments supplied by the arg_stream.
bool eof(ArgStream const &as)
arg_stream::eof(argstream) returns true if there are no more args available.
boost::range_difference< InputRange >::type count(InputRange &range, T &value)
count implementation
#define ADOBE_HAS_TYPE_IMPL(TypeInQuestion)
Implementation part of ADOBE_HAS_TYPE macro. Required before using ADOBE_HAS_TYPE.
#define ADOBE_HAS_TYPE(C, TypeInQuestion)
returns true iff C has an internal type named 'TypeInQuestion'. ie returns true iff C::TypeInQuestion...
#define ADOBE_HAS_TEMPLATE1(C, TemplateInQuestion)
returns true iff C has an internal template named 'TemplateInQuestion' with 1 (nondefault) template p...
chain< ArgStreamFirst, ArgStreamSecond > make_chain(ArgStreamFirst &first_stream, ArgStreamSecond &second_stream)
given 2 arg_streams, returns an arg_stream of the 2 streams chained together
with_transform< ArgStream, Transformer > make_transforming(ArgStream &as, Transformer &transformer)
chain 2 arg_streams together by calling the first stream until depleted, then calling the second.
ArgStreamFirst first_type
ArgStreamSecond second_type
chain(ArgStreamFirst &first_stream, ArgStreamSecond &second_stream)
the empty-set arg stream has no arguments. Not sure what this might be useful for.
result_type<F>::type is the return type of the function f.
boost::function_types::result_type< typenamesignature< F >::type >::type type
returns the function signature of the callable object type F
holds a single value, and returns it as an arg n (default 1) times
R convert_or_throw(value_type &value, typename boost::disable_if< boost::is_convertible< value_type, R > >::type *dummy=0)
single(typename boost::add_reference< T const >::type t, unsigned int count=1)
R convert_or_throw(value_type &value, typename boost::enable_if< boost::is_convertible< value_type, R > >::type *dummy=0)
static const bool has_eof_memberfunction
static const bool has_eof_memberfunction
static const bool has_eof_memberfunction
defines any traits that help with the implementation of arg_stream::call() and/or helper objects like...
static const bool has_eof_member
is T::type a valid type (or a compile error?)