MCPcopy Create free account
hub / github.com/ImageEngine/cortex / CompoundDataVariableProvider

Class CompoundDataVariableProvider

src/IECore/StringAlgo.cpp:238–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238struct CompoundDataVariableProvider : public StringAlgo::VariableProvider
239{
240
241 CompoundDataVariableProvider( const CompoundData *variables )
242 : m_variables( variables )
243 {
244 }
245
246 int frame() const override
247 {
248 const Data *d = m_variables->member( "frame" );
249 if( !d )
250 {
251 return 1;
252 }
253 switch( d->typeId() )
254 {
255 case IntDataTypeId :
256 return static_cast<const IntData *>( d )->readable();
257 case FloatDataTypeId :
258 return (int)round( static_cast<const FloatData *>( d )->readable() );
259 default :
260 throw IECore::Exception(
261 string( "Unexpected data type \"" ) + d->typeName() +
262 "\" for frame : expected IntData or FloatData"
263 );
264 }
265 }
266
267 const std::string &variable( const boost::string_view &name, bool &recurse ) const override
268 {
269 const IECore::Data *d = m_variables->member<IECore::Data>( name );
270 if( d )
271 {
272 switch( d->typeId() )
273 {
274 case IECore::StringDataTypeId :
275 recurse = true;
276 return static_cast<const IECore::StringData *>( d )->readable();
277 case IECore::FloatDataTypeId :
278 m_formattedString = boost::lexical_cast<std::string>(
279 static_cast<const IECore::FloatData *>( d )->readable()
280 );
281 return m_formattedString;
282 case IECore::IntDataTypeId :
283 m_formattedString = boost::lexical_cast<std::string>(
284 static_cast<const IECore::IntData *>( d )->readable()
285 );
286 return m_formattedString;
287 default :
288 break;
289 }
290 }
291 m_formattedString.clear();
292 return m_formattedString;
293 }
294
295 private :

Callers 1

substituteFunction · 0.85

Calls 3

typeIdMethod · 0.80
readableMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected