@@ -93,7 +93,7 @@ std::int32_t ofxOscMessage::getArgAsInt32( int index ) const
9393 if ( getArgType ( index ) == OFXOSC_TYPE_FLOAT )
9494 {
9595 ofLogWarning (" ofxOscMessage" ) << " getArgAsInt32(): converting float to int32 for argument " << index;
96- return ( std::int32_t )(( ofxOscArgFloat*) args[index])->get ();
96+ return reinterpret_cast < std::int32_t > ( dynamic_cast < ofxOscArgFloat*> args[index])->get ();
9797 }
9898 else
9999 {
@@ -102,17 +102,17 @@ std::int32_t ofxOscMessage::getArgAsInt32( int index ) const
102102 }
103103 }
104104 else
105- return (( ofxOscArgInt32*) args[index])->get ();
105+ return (dynamic_cast < ofxOscArgInt32*> args[index])->get ();
106106}
107107
108108std::int64_t ofxOscMessage::getArgAsInt64 ( int index ) const
109109{
110110 if ( getArgType (index) != OFXOSC_TYPE_INT64 )
111111 {
112- if ( getArgType ( index ) == OFXOSC_TYPE_FLOAT )
112+ if ( getArgType ( index ) == OFXOSC_TYPE_FLOAT )
113113 {
114- ofLogWarning (" ofxOscMessage" ) << " getArgAsInt64(): converting float to int64 for argument " << index;
115- return ( std::int64_t )(( ofxOscArgFloat*) args[index])->get ();
114+ ofLogWarning (" ofxOscMessage" ) << " getArgAsInt64(): converting float to int64 for argument " << index;
115+ return reinterpret_cast < std::int64_t > ( dynamic_cast < ofxOscArgFloat*> args[index])->get ();
116116 }
117117 else
118118 {
@@ -121,7 +121,7 @@ std::int64_t ofxOscMessage::getArgAsInt64( int index ) const
121121 }
122122 }
123123 else
124- return (( ofxOscArgInt64*) args[index])->get ();
124+ return (dynamic_cast < ofxOscArgInt64*> args[index])->get ();
125125}
126126
127127float ofxOscMessage::getArgAsFloat ( int index ) const
@@ -131,7 +131,7 @@ float ofxOscMessage::getArgAsFloat( int index ) const
131131 if ( getArgType ( index ) == OFXOSC_TYPE_INT32 )
132132 {
133133 ofLogWarning (" ofxOscMessage" ) << " getArgAsFloat(): converting int32 to float for argument " << index;
134- return ( float )(( ofxOscArgInt32*) args[index])->get ();
134+ return reinterpret_cast < float >( dynamic_cast < ofxOscArgInt32*> args[index])->get ();
135135 }
136136 else
137137 {
@@ -140,7 +140,7 @@ float ofxOscMessage::getArgAsFloat( int index ) const
140140 }
141141 }
142142 else
143- return (( ofxOscArgFloat*) args[index])->get ();
143+ return (dynamic_cast < ofxOscArgFloat*> args[index])->get ();
144144}
145145
146146double ofxOscMessage::getArgAsDouble ( int index ) const
@@ -150,7 +150,7 @@ double ofxOscMessage::getArgAsDouble( int index ) const
150150 if ( getArgType ( index ) == OFXOSC_TYPE_INT32 )
151151 {
152152 ofLogWarning (" ofxOscMessage" ) << " getArgAsDouble(): converting int32 to double for argument " << index;
153- return ( double )(( ofxOscArgInt32*) args[index])->get ();
153+ return reinterpret_cast < double > ( dynamic_cast < ofxOscArgInt32*> args[index])->get ();
154154 }
155155 else
156156 {
@@ -159,7 +159,7 @@ double ofxOscMessage::getArgAsDouble( int index ) const
159159 }
160160 }
161161 else
162- return (( ofxOscArgDouble*) args[index])->get ();
162+ return (dynamic_cast < ofxOscArgDouble*> args[index])->get ();
163163}
164164
165165std::string ofxOscMessage::getArgAsString ( int index ) const
@@ -169,14 +169,14 @@ std::string ofxOscMessage::getArgAsString( int index ) const
169169 if ( getArgType ( index ) == OFXOSC_TYPE_FLOAT )
170170 {
171171 char buf[1024 ];
172- sprintf (buf," %f" ,(( ofxOscArgFloat*) args[index])->get () );
172+ sprintf (buf," %f" ,(dynamic_cast < ofxOscArgFloat*> args[index])->get () );
173173 ofLogWarning (" ofxOscMessage" ) << " getArgAsString(): converting float to string for argument " << index;
174174 return buf;
175175 }
176176 else if ( getArgType ( index ) == OFXOSC_TYPE_INT32 )
177177 {
178178 char buf[1024 ];
179- sprintf (buf," %i" ,(( ofxOscArgInt32*) args[index])->get () );
179+ sprintf (buf," %i" ,(dynamic_cast < ofxOscArgInt32*> args[index])->get () );
180180 ofLogWarning (" ofxOscMessage" ) << " getArgAsString(): converting int32 to string for argument " << index;
181181 return buf;
182182 }
@@ -187,7 +187,7 @@ std::string ofxOscMessage::getArgAsString( int index ) const
187187 }
188188 }
189189 else
190- return (( ofxOscArgString*) args[index])->get ();
190+ return (dynamic_cast < ofxOscArgString*> args[index])->get ();
191191}
192192
193193std::string ofxOscMessage::getArgAsSymbol (int index) const
@@ -197,14 +197,14 @@ std::string ofxOscMessage::getArgAsSymbol(int index) const
197197 if ( getArgType ( index ) == OFXOSC_TYPE_FLOAT )
198198 {
199199 char buf[1024 ];
200- sprintf (buf," %f" ,(( ofxOscArgFloat*) args[index])->get () );
200+ sprintf (buf," %f" ,(dynamic_cast < ofxOscArgFloat*> args[index])->get () );
201201 ofLogWarning (" ofxOscMessage" ) << " getArgAsSymbol(): converting float to symbol (string) for argument " << index;
202202 return buf;
203203 }
204204 else if ( getArgType ( index ) == OFXOSC_TYPE_INT32 )
205205 {
206206 char buf[1024 ];
207- sprintf (buf," %i" ,(( ofxOscArgInt32*) args[index])->get () );
207+ sprintf (buf," %i" ,(dynamic_cast < ofxOscArgInt32*> args[index])->get () );
208208 ofLogWarning (" ofxOscMessage" ) << " getArgAsSymbol(): converting int32 to symbol (string) for argument " << index;
209209 return buf;
210210 }
@@ -215,14 +215,14 @@ std::string ofxOscMessage::getArgAsSymbol(int index) const
215215 }
216216 }
217217 else
218- return (( ofxOscArgSymbol*) args[index])->get ();
218+ return (dynamic_cast < ofxOscArgSymbol*> args[index])->get ();
219219}
220220
221221char ofxOscMessage::getArgAsChar (int index) const
222222{
223223 if ( getArgType (index) == OFXOSC_TYPE_CHAR )
224224 {
225- return (( ofxOscArgChar*) args[index])->get ();
225+ return (dynamic_cast < ofxOscArgChar*> args[index])->get ();
226226 }
227227 else
228228 {
@@ -238,7 +238,7 @@ std::int32_t ofxOscMessage::getArgAsMidiMessage(int index) const
238238 if ( getArgType ( index ) == OFXOSC_TYPE_FLOAT )
239239 {
240240 ofLogWarning (" ofxOscMessage" ) << " getArgAsInt32(): converting float to int32 for argument " << index;
241- return ( std::int32_t )(( ofxOscArgFloat*) args[index])->get ();
241+ return reinterpret_cast < std::int32_t > ( dynamic_cast < ofxOscArgFloat*> args[index])->get ();
242242 }
243243 else
244244 {
@@ -247,35 +247,35 @@ std::int32_t ofxOscMessage::getArgAsMidiMessage(int index) const
247247 }
248248 }
249249 else
250- return (( ofxOscArgInt32*) args[index])->get ();
250+ return (dynamic_cast < ofxOscArgInt32*> args[index])->get ();
251251}
252252
253253bool ofxOscMessage::getArgAsBool (int index) const
254254{
255255 ofxOscArgType incomingArgType = getArgType ( index );
256256 if (incomingArgType == OFXOSC_TYPE_TRUE || incomingArgType == OFXOSC_TYPE_FALSE)
257257 {
258- return (( ofxOscArgBool*) args[index])->get ();
258+ return (dynamic_cast < ofxOscArgBool*> args[index])->get ();
259259 }
260260 else if (incomingArgType == OFXOSC_TYPE_INT32)
261261 {
262- return (( ofxOscArgInt32*) args[index])->get () > 0 ;
262+ return (dynamic_cast < ofxOscArgInt32*> args[index])->get () > 0 ;
263263 }
264264 else if (incomingArgType == OFXOSC_TYPE_INT64)
265265 {
266- return (( ofxOscArgInt64*) args[index])->get () > 0 ;
266+ return (dynamic_cast < ofxOscArgInt64*> args[index])->get () > 0 ;
267267 }
268268 else if (incomingArgType == OFXOSC_TYPE_FLOAT)
269269 {
270- return (( ofxOscArgFloat*) args[index])->get () > 0 ;
270+ return (dynamic_cast < ofxOscArgFloat*> args[index])->get () > 0 ;
271271 }
272272 else if (incomingArgType == OFXOSC_TYPE_DOUBLE)
273273 {
274- return (( ofxOscArgDouble*) args[index])->get () > 0 ;
274+ return (dynamic_cast < ofxOscArgDouble*> args[index])->get () > 0 ;
275275 }
276276 else if (incomingArgType == OFXOSC_TYPE_STRING || incomingArgType == OFXOSC_TYPE_SYMBOL)
277277 {
278- return (( ofxOscArgString*) args[index])->get () == " true" ;
278+ return (dynamic_cast < ofxOscArgString*> args[index])->get () == " true" ;
279279 }
280280 else
281281 {
@@ -292,7 +292,7 @@ bool ofxOscMessage::getArgAsTrigger(int index) const
292292 return NULL ;
293293 }
294294 else
295- return (( ofxOscArgTrigger*) args[index])->get ();
295+ return (dynamic_cast < ofxOscArgTrigger*> args[index])->get ();
296296}
297297
298298bool ofxOscMessage::getArgAsImpulse (int index) const
@@ -312,7 +312,7 @@ std::int64_t ofxOscMessage::getArgAsTimetag(int index) const
312312 if ( getArgType ( index ) == OFXOSC_TYPE_DOUBLE )
313313 {
314314 ofLogWarning (" ofxOscMessage" ) << " getArgAsTimetag(): converting double to Timetag for argument " << index;
315- return ( std::int32_t )(( ofxOscArgFloat*) args[index])->get ();
315+ return reinterpret_cast < std::int32_t >( dynamic_cast < ofxOscArgFloat*> args[index])->get ();
316316 }
317317 else
318318 {
@@ -321,7 +321,7 @@ std::int64_t ofxOscMessage::getArgAsTimetag(int index) const
321321 }
322322 }
323323 else
324- return (( ofxOscArgTimetag*) args[index])->get ();
324+ return (dynamic_cast < ofxOscArgTimetag*> args[index])->get ();
325325}
326326
327327ofBuffer ofxOscMessage::getArgAsBlob ( int index ) const
@@ -332,7 +332,7 @@ ofBuffer ofxOscMessage::getArgAsBlob( int index ) const
332332 return ofBuffer ();
333333 }
334334 else
335- return (( ofxOscArgBlob*) args[index])->get ();
335+ return (dynamic_cast < ofxOscArgBlob*> args[index])->get ();
336336}
337337
338338std::int32_t ofxOscMessage::getArgAsRgbaColor ( int index ) const
@@ -343,7 +343,7 @@ std::int32_t ofxOscMessage::getArgAsRgbaColor( int index ) const
343343 return 0 ;
344344 }
345345 else
346- return (( ofxOscArgRgbaColor*) args[index])->get ();
346+ return (dynamic_cast < ofxOscArgRgbaColor*> args[index])->get ();
347347}
348348
349349/*
0 commit comments