30 #include <initializer_list>
60 std::function<void(msg_t, RtData)>
cb;
63 static void scat(
char *dest,
const char *src);
97 Ports(std::initializer_list<Port> l)
115 if(!loc || !loc_size) {
117 if(rtosc_match(port.name,m))
118 port.cb(m,{NULL,0,v});
129 while(*old_end) ++old_end;
132 if(!rtosc_match(port.name, m))
136 if(index(port.name,
'#')) {
139 while(*msg && *msg !=
'/')
143 scat(loc, port.name);
146 port.cb(m,{loc,loc_size,v});
150 while(*tmp) *tmp++=0;
162 const char *_needle = name,
163 *_haystack = port.
name;
164 while(*_needle && *_needle==*_haystack)_needle++,_haystack++;
166 if(*_needle == 0 && *_haystack ==
':') {
176 while(*m && *m !=
'/') ++m;
183 if(path && path[0] ==
'/')
187 if(index(port.name,
'/') && rtosc_match_path(port.name,path))
188 return (index(path,
'/')[1]==0) ? &port :
192 for(
const Port &port: ports)
193 if(*path && strstr(port.name, path)==port.name)
204 static void scat(
char *dest,
const char *src)
208 while(*src && *src!=
':') *dest++ = *src++;
215 void walk_ports(
const Ports *base,
221 if(name_buffer[0] == 0)
222 name_buffer[0] =
'/';
224 char *old_end = name_buffer;
225 while(*old_end) ++old_end;
227 for(
const Port &p: *base) {
228 if(index(p.name,
'/')) {
229 if(index(p.name,
'#')) {
230 const char *name = p.name;
232 while(*name !=
'#') *pos++ = *name++;
233 const unsigned max = atoi(name+1);
235 for(
unsigned i=0; i<max; ++i)
240 if(rindex(name_buffer,
'/')[1] !=
'/')
241 strcat(name_buffer,
"/");
244 walk_ports(p.ports, name_buffer, buffer_size, walker);
248 scat(name_buffer, p.name);
251 walk_ports(p.ports, name_buffer, buffer_size, walker);
255 scat(name_buffer, p.name);
258 walker(&p, name_buffer);
263 while(*tmp) *tmp++=0;