37 #include "OscPrintReceivedElements.h"
44 #if defined(__BORLANDC__) // workaround for BCB4 release build intrinsics bug
53 std::ostream& operator<<( std::ostream & os,
54 const ReceivedMessageArgument& arg )
56 switch( arg.TypeTag() ){
69 case INFINITUM_TYPE_TAG:
74 os <<
"int32:" << arg.AsInt32Unchecked();
78 os <<
"float32:" << arg.AsFloatUnchecked();
84 s[0] = arg.AsCharUnchecked();
85 os <<
"char:'" << s <<
"'";
89 case RGBA_COLOR_TYPE_TAG:
91 uint32 color = arg.AsRgbaColorUnchecked();
94 << std::hex << std::setfill(
'0')
95 << std::setw(2) << (int)((color>>24) & 0xFF)
96 << std::setw(2) << (int)((color>>16) & 0xFF)
97 << std::setw(2) << (int)((color>>8) & 0xFF)
98 << std::setw(2) << (int)(color & 0xFF)
100 os.unsetf(std::ios::basefield);
104 case MIDI_MESSAGE_TYPE_TAG:
106 uint32 m = arg.AsMidiMessageUnchecked();
107 os <<
"midi (port, status, data1, data2):<<"
108 << std::hex << std::setfill(
'0')
109 <<
"0x" << std::setw(2) << (int)((m>>24) & 0xFF)
110 <<
" 0x" << std::setw(2) << (int)((m>>16) & 0xFF)
111 <<
" 0x" << std::setw(2) << (int)((m>>8) & 0xFF)
112 <<
" 0x" << std::setw(2) << (int)(m & 0xFF)
113 << std::setfill(
' ') <<
">>";
114 os.unsetf(std::ios::basefield);
119 os <<
"int64:" << arg.AsInt64Unchecked();
122 case TIME_TAG_TYPE_TAG:
124 os <<
"OSC-timetag:" << arg.AsTimeTagUnchecked() <<
" ";
127 (
unsigned long)( arg.AsTimeTagUnchecked() >> 32 );
129 const char *timeString = std::ctime( &t );
130 size_t len = std::strlen( timeString );
134 os.write( timeString, len - 1 );
138 case DOUBLE_TYPE_TAG:
139 os <<
"double:" << arg.AsDoubleUnchecked();
142 case STRING_TYPE_TAG:
143 os <<
"OSC-string:`" << arg.AsStringUnchecked() <<
"'";
146 case SYMBOL_TYPE_TAG:
147 os <<
"OSC-string (symbol):`" << arg.AsSymbolUnchecked() <<
"'";
153 osc_bundle_element_size_t size;
154 arg.AsBlobUnchecked( data, size );
155 os <<
"OSC-blob:<<" << std::hex << std::setfill(
'0');
156 unsigned char *p = (
unsigned char*)data;
157 for( osc_bundle_element_size_t i = 0; i < size; ++i ){
158 os <<
"0x" << std::setw(2) << int(p[i]);
162 os.unsetf(std::ios::basefield);
163 os <<
">>" << std::setfill(
' ');
167 case ARRAY_BEGIN_TYPE_TAG:
171 case ARRAY_END_TYPE_TAG:
183 std::ostream& operator<<( std::ostream & os,
const ReceivedMessage& m )
186 if( m.AddressPatternIsUInt32() )
187 os << m.AddressPatternAsUInt32();
189 os << m.AddressPattern();
192 for( ReceivedMessage::const_iterator i = m.ArgumentsBegin();
193 i != m.ArgumentsEnd(); ++i ){
210 std::ostream& operator<<( std::ostream & os,
const ReceivedBundle& b )
212 static int indent = 0;
214 for(
int j=0; j < indent; ++j )
217 if( b.TimeTag() == 1 )
225 for( ReceivedBundle::const_iterator i = b.ElementsBegin();
226 i != b.ElementsEnd(); ++i ){
228 ReceivedBundle b(*i);
231 ReceivedMessage m(*i);
232 for(
int j=0; j < indent; ++j )
240 for(
int j=0; j < indent; ++j )
248 std::ostream& operator<<( std::ostream & os,
const ReceivedPacket& p )
254 ReceivedMessage m(p);