1#ifndef RTOSC_TYPED_MESSAGE_H
2#define RTOSC_TYPED_MESSAGE_H
3#include <rtosc/typestring.hh>
13template<
class... Types>
class rtMsg;
19 rtMsg(
const char *arg = NULL,
const char *spec=NULL,
bool _=
false)
27 operator bool(
void){
return this->msg;}
36struct advance_size<irqus::typestring<C...>> :
public std::false_type {};
39bool valid_char(
char) {
return false;}
42bool valid_char<const char*>(
char c) {
return c==
's' || c==
'S'; };
45bool valid_char<int32_t>(
char c) {
return c==
'i'; };
48bool valid_char<float>(
char c) {
return c==
'f'; };
51bool validate(
const char *arg)
57bool match_path(std::false_type,
const char *arg)
63bool match_path(std::true_type,
const char *)
68template<
int i,
class This,
class... Rest>
69bool validate(
const char *arg)
71 advance_size<This> size;
72 if(size && !valid_char<This>(
rtosc_type(arg,i)))
74 else if(!size && !match_path<This>(size, arg))
77 return validate<i+size.value,Rest...>(arg);
81template<
class This,
class... Rest>
87 rtMsg(
const char *arg = NULL,
const char *spec=NULL)
90 if(this->msg && !validate<0,This,Rest...>(this->msg))
94 rtMsg(
const char *arg,
const char *spec,
bool)
105template<
class This,
class... Rest>
112template <
size_t Index,
class This,
class... Rest>
119T rt_get_impl(
const char *msg,
size_t i);
122const char *rt_get_impl(
const char *msg,
size_t i)
128int32_t rt_get_impl(
const char *msg,
size_t i)
134template<
size_t Index,
class... Types>
inline
135 typename osc_element<Index, rtMsg<Types...>>::type
136get(rtMsg<Types...>& Tuple)
139 throw std::invalid_argument(
"Message Does Not Match Spec");
140 typedef typename std::remove_reference<
typename osc_element<Index, rtMsg<Types...>>::type>::type T;
141 return rt_get_impl<T>(Tuple.msg, Index);
144template<
class... Types>
inline
145 typename osc_element<0, rtMsg<Types...>>::type
146first(rtMsg<Types...>&Tuple)
148 return get<0>(Tuple);
151template<
class... Types>
inline
152 typename osc_element<1, rtMsg<Types...>>::type
153second(rtMsg<Types...>&Tuple)
155 return get<1>(Tuple);
Definition typed-message.h:13
Functions handling messages and arguments.
unsigned rtosc_narguments(const char *msg)
Returns the number of arguments found in a given message.
rtosc_arg_t rtosc_argument(const char *msg, unsigned i)
Blob data may be safely written to.
char rtosc_type(const char *msg, unsigned i)
const char * rtosc_match_path(const char *pattern, const char *msg, const char **path_end)
Attempt to match a rtosc style path while ignoring arguments.
Definition typed-message.h:33
Definition typed-message.h:10
Definition typed-message.h:11
Definition typed-message.h:102