本文整理汇总了C++中ContextPtr::substitute方法的典型用法代码示例。如果您正苦于以下问题:C++ ContextPtr::substitute方法的具体用法?C++ ContextPtr::substitute怎么用?C++ ContextPtr::substitute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContextPtr
的用法示例。
在下文中一共展示了ContextPtr::substitute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testManyEnvironmentSubstitutions
// Useful for assessing the performance of environment variable substitutions.
void GafferTest::testManyEnvironmentSubstitutions()
{
ContextPtr context = new Context();
const std::string phrase( "${GAFFER_ROOT}" );
const std::string expectedResult( getenv( "GAFFER_ROOT") );
Timer t;
for( int i = 0; i < 1000000; ++i )
{
const std::string s = context->substitute( phrase );
GAFFERTEST_ASSERT( s == expectedResult );
}
// uncomment to get timing information
//std::cerr << t.stop() << std::endl;
}
示例2: testManySubstitutions
// Useful for assessing the performance of substitutions.
void GafferTest::testManySubstitutions()
{
ContextPtr context = new Context();
context->set( "foodType", std::string( "kipper" ) );
context->set( "cookingMethod", std::string( "smoke" ) );
const std::string phrase( "${cookingMethod} me a ${foodType}" );
const std::string expectedResult( "smoke me a kipper" );
Timer t;
for( int i = 0; i < 100000; ++i )
{
const std::string s = context->substitute( phrase );
GAFFERTEST_ASSERT( s == expectedResult );
}
// uncomment to get timing information
//std::cerr << t.stop() << std::endl;
}
示例3: executeSequence
void SceneWriter::executeSequence( const std::vector<float> &frames ) const
{
const ScenePlug *scene = inPlug()->getInput<ScenePlug>();
if( !scene )
{
throw IECore::Exception( "No input scene" );
}
ContextPtr context = new Context( *Context::current(), Context::Borrowed );
Context::Scope scopedContext( context.get() );
std::string fileName = context->substitute( fileNamePlug()->getValue() );
createDirectories( fileName );
SceneInterfacePtr output = SceneInterface::create( fileName, IndexedIO::Write );
for ( std::vector<float>::const_iterator it = frames.begin(); it != frames.end(); ++it )
{
context->setFrame( *it );
double time = *it / g_frameRate;
writeLocation( scene, ScenePlug::ScenePath(), context.get(), output.get(), time );
}
}