当前位置: 首页>>代码示例>>C++>>正文


C++ InternedString类代码示例

本文整理汇总了C++中InternedString的典型用法代码示例。如果您正苦于以下问题:C++ InternedString类的具体用法?C++ InternedString怎么用?C++ InternedString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了InternedString类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: annotations

bool RenderManShader::acceptsInput( const Plug *plug, const Plug *inputPlug ) const
{
	if( !Shader::acceptsInput( plug, inputPlug ) )
	{
		return false;
	}
	
	if( parametersPlug()->isAncestorOf( plug ) )
	{
		const Plug *sourcePlug = inputPlug->source<Plug>();
		if( plug->typeId() == Plug::staticTypeId() )
		{
			// coshader parameter - input must be another
			// renderman shader hosting a coshader.
			const RenderManShader *inputShader = sourcePlug->parent<RenderManShader>();
			if(
				!inputShader ||
				sourcePlug != inputShader->outPlug() ||
				inputShader->typePlug()->getValue() != "ri:shader"
			)
			{
				return false;
			}
			// so far all is good, but we also need to check that
			// the coshaderType annotations match if present.
			ConstCompoundDataPtr dstAnnotations = annotations();
			if( !dstAnnotations )
			{
				return true;
			}
			InternedString parameterName = plug->getName();
			if( plug->parent<GraphComponent>() != parametersPlug() )
			{
				// array parameter
				parameterName = plug->parent<GraphComponent>()->getName();
			}
			const StringData *dstType = dstAnnotations->member<StringData>( parameterName.string() + ".coshaderType" );
			if( !dstType )
			{
				return true;
			}
			ConstCompoundDataPtr srcAnnotations = inputShader->annotations();
			if( !srcAnnotations )
			{
				return false;
			}
			const StringData *srcType = srcAnnotations->member<StringData>( "coshaderType" );
			return srcType && srcType->readable() == dstType->readable();
		}
		else
		{
			// standard parameter - input must not be the
			// output of another shader.
			const Shader *inputShader = sourcePlug->ancestor<Shader>();
			return !inputShader || sourcePlug != inputShader->outPlug();
		}
	}
	
	return true;
}
开发者ID:AntiCG,项目名称:gaffer,代码行数:60,代码来源:RenderManShader.cpp

示例2: getScopeTypeOfName

 VarScopeType getScopeTypeOfName(InternedString name) override {
     if (name.isCompilerCreatedName())
         return VarScopeType::FAST;
     else if (forced_globals.find(name) != forced_globals.end())
         return VarScopeType::GLOBAL;
     else
         return VarScopeType::NAME;
 }
开发者ID:Thooms,项目名称:pyston,代码行数:8,代码来源:scoping_analysis.cpp

示例3: uniqueHandle

		InternedString uniqueHandle( const InternedString &handle )
		{
			if( m_nodes.find( handle ) == m_nodes.end() )
			{
				return handle;
			}

			string result;
			for( int i = 1; true; ++i )
			{
				result = handle.string() + std::to_string( i );
				if( m_nodes.find( result ) == m_nodes.end() )
				{
					return result;
				}
			}
		}
开发者ID:ImageEngine,项目名称:cortex,代码行数:17,代码来源:ShaderNetwork.cpp

示例4: mangleNameInPlace

static void mangleNameInPlace(InternedString& id, llvm::StringRef private_name, InternedStringPool& interned_strings) {
    if (!private_name.size())
        return;

    int len = id.s().size();
    if (len < 2 || id.s()[0] != '_' || id.s()[1] != '_')
        return;

    if ((id.s()[len - 2] == '_' && id.s()[len - 1] == '_') || id.s().find('.') != std::string::npos)
        return;

    assert(private_name.data()[private_name.size()] == '\0');
    const char* p = private_name.data();
    while (*p == '_') {
        p++;
        len--;
    }
    if (*p == '\0')
        return;

    // TODO add a twine interface to interned strings?
    id = interned_strings.get("_" + std::string(p) + std::string(id.s()));
}
开发者ID:JieyiMao,项目名称:pyston,代码行数:23,代码来源:scoping_analysis.cpp

示例5: parentPlug

/// \todo This mapping is very similar to the one created by the Group node. Perhaps
/// some generalisation of the two could form the basis for a nice unified HierarchyProcessor?
/// In this case I think we would have a custom mapping class rather than just pass around
/// CompoundData, and then parentAndBranchPaths() (or the future version of it) could be a method
/// on the mapping object.
IECore::ConstCompoundDataPtr BranchCreator::computeMapping( const Gaffer::Context *context ) const
{
	// get the parent. currently this is simply retrieving the value of parentPlug(),
	// but if we wanted to support multiple parents in future, here we would find the
	// parent appropriate to the current "scene:path" context entry.
	
	/// \todo We should introduce a plug type which stores its values as a ScenePath directly.
	ScenePlug::ScenePath parent;
	string parentAsString = parentPlug()->getValue();
	if( parentAsString.empty() )
	{
		// no parent specified so no mapping needed
		return static_cast<const CompoundData *>( mappingPlug()->defaultValue() );
	}
	ScenePlug::stringToPath( parentAsString, parent );
	
	// see if we're interested in creating children or not. if we're not
	// we can early out. no innuendo intended.
	
	ConstInternedStringVectorDataPtr branchChildNamesData = computeBranchChildNames( parent, ScenePath(), context );
	if( !branchChildNamesData->readable().size() )
	{
		return static_cast<const CompoundData *>( mappingPlug()->defaultValue() );
	}

	// create our result. in future it might be useful to create our datatype for this,
	// but for now we're just packing everything into a CompoundData.

	CompoundDataPtr result = new CompoundData;
	result->writable()["__BranchCreatorParent"] = new InternedStringVectorData( parent );
	
	// calculate the child names for the result. this is the full list of child names
	// immediately below the parent. we need to be careful to ensure that we rename any
	// branch names which conflict with existing children of the parent.
	
	ConstInternedStringVectorDataPtr inChildNamesData = inPlug()->childNames( parent );
	InternedStringVectorDataPtr childNamesData = new InternedStringVectorData();
	
	const vector<InternedString> &inChildNames = inChildNamesData->readable();
	const vector<InternedString> &branchChildNames = branchChildNamesData->readable();
	vector<InternedString> &childNames = childNamesData->writable();
	
	result->writable()["__BranchCreatorChildNames"] = childNamesData;
	
	set<InternedString> allNames;
	for( vector<InternedString>::const_iterator it = inChildNames.begin(); it != inChildNames.end(); ++it )
	{
		allNames.insert( *it );
		childNames.push_back( *it );
	}
	
	boost::regex namePrefixSuffixRegex( "^(.*[^0-9]+)([0-9]+)$" );
	boost::format namePrefixSuffixFormatter( "%s%d" );

	for( vector<InternedString>::const_iterator it = branchChildNames.begin(); it != branchChildNames.end(); ++it )
	{
		InternedString name = *it;
		if( allNames.find( name ) != allNames.end() )
		{
			// uniqueify the name
			string prefix = name;
			int suffix = 1;
			
			boost::cmatch match;
			if( regex_match( name.value().c_str(), match, namePrefixSuffixRegex ) )
			{
				prefix = match[1];
				suffix = boost::lexical_cast<int>( match[2] );
			}
			
			do
			{
				name = boost::str( namePrefixSuffixFormatter % prefix % suffix );
				suffix++;
			} while( allNames.find( name ) != allNames.end() );
		}
		
		allNames.insert( name );
		childNames.push_back( name );
		
		result->writable()[name] = new InternedStringData( *it );
	}
	
	return result;
}
开发者ID:UIKit0,项目名称:gaffer,代码行数:90,代码来源:BranchCreator.cpp

示例6: annotations

bool RenderManShader::acceptsInput( const Plug *plug, const Plug *inputPlug ) const
{
	if( !Shader::acceptsInput( plug, inputPlug ) )
	{
		return false;
	}
	
	if( parametersPlug()->isAncestorOf( plug ) )
	{
		const Plug *sourcePlug = inputPlug->source<Plug>();
		
		if( plug->typeId() == Plug::staticTypeId() )
		{
		
			const Node* sourceNode = inputPlug->node();
			if( runTimeCast<const Box>( sourceNode ) )
			{
				// looks like we're exposing this input via a box, or
				// connecting it to an unconnected output on a box. At
				// the moment, we're just accepting this and trusting
				// the user not to connect something nonsensical to inputPlug.
				// \todo: make it so we can't make illegal connections to inputPlug
				return true;
			}
			
			// coshader parameter - input must be another
			// renderman shader hosting a coshader.
			const RenderManShader *inputShader = sourcePlug->parent<RenderManShader>();
			if(
				!inputShader ||
				sourcePlug != inputShader->outPlug() ||
				inputShader->typePlug()->getValue() != "ri:shader"
			)
			{
				return false;
			}
			// so far all is good, but we also need to check that
			// the coshaderType annotations match if present.
			ConstCompoundDataPtr dstAnnotations = annotations();
			if( !dstAnnotations )
			{
				return true;
			}
			InternedString parameterName = plug->getName();
			if( plug->parent<GraphComponent>() != parametersPlug() )
			{
				// array parameter
				parameterName = plug->parent<GraphComponent>()->getName();
			}
			const StringData *dstType = dstAnnotations->member<StringData>( parameterName.string() + ".coshaderType" );
			if( !dstType )
			{
				return true;
			}
			ConstCompoundDataPtr srcAnnotations = inputShader->annotations();
			if( !srcAnnotations )
			{
				return false;
			}
			const StringData *srcType = srcAnnotations->member<StringData>( "coshaderType" );
			return srcType && srcType->readable() == dstType->readable();
		}
		else
		{
			// standard parameter - input must not be the
			// output of another shader.
			const Shader *inputShader = sourcePlug->ancestor<Shader>();
			return !inputShader || sourcePlug != inputShader->outPlug();
		}
	}
	
	return true;
}
开发者ID:danieldresser,项目名称:gaffer,代码行数:73,代码来源:RenderManShader.cpp

示例7: CompoundObject

IECore::ObjectPtr Group::computeMapping( const Gaffer::Context *context ) const
{
	/// \todo It might be more optimal to make our own Object subclass better tailored
	/// for passing the information we want.
	CompoundObjectPtr result = new CompoundObject();

	InternedStringVectorDataPtr childNamesData = new InternedStringVectorData();
	vector<InternedString> &childNames = childNamesData->writable();
	result->members()["__GroupChildNames"] = childNamesData;

	ObjectVectorPtr forwardMappings = new ObjectVector;
	result->members()["__GroupForwardMappings"] = forwardMappings;

	boost::regex namePrefixSuffixRegex( "^(.*[^0-9]+)([0-9]+)$" );
	boost::format namePrefixSuffixFormatter( "%s%d" );

	set<InternedString> allNames;
	for( ScenePlugIterator it( inPlugs() ); it != it.end(); ++it )
	{
		ConstInternedStringVectorDataPtr inChildNamesData = (*it)->childNames( ScenePath() );
		CompoundDataPtr forwardMapping = new CompoundData;
		forwardMappings->members().push_back( forwardMapping );

		const vector<InternedString> &inChildNames = inChildNamesData->readable();
		for( vector<InternedString>::const_iterator cIt = inChildNames.begin(), ceIt = inChildNames.end(); cIt!=ceIt; cIt++ )
		{
			InternedString name = *cIt;
			if( allNames.find( name ) != allNames.end() )
			{
				// uniqueify the name
				/// \todo This code is almost identical to code in GraphComponent::setName(),
				/// is there a sensible place it can be shared? The primary obstacle is that
				/// each use has a different method of storing the existing names.
				string prefix = name;
				int suffix = 1;

				boost::cmatch match;
				if( regex_match( name.value().c_str(), match, namePrefixSuffixRegex ) )
				{
					prefix = match[1];
					suffix = boost::lexical_cast<int>( match[2] );
				}

				do
				{
					name = boost::str( namePrefixSuffixFormatter % prefix % suffix );
					suffix++;
				} while( allNames.find( name ) != allNames.end() );
			}

			allNames.insert( name );
			childNames.push_back( name );
			forwardMapping->writable()[*cIt] = new InternedStringData( name );

			CompoundObjectPtr entry = new CompoundObject;
			entry->members()["n"] = new InternedStringData( *cIt );
			entry->members()["i"] = new IntData( it.base() - inPlugs()->children().begin() );
			result->members()[name] = entry;
		}
	}

	return result;
}
开发者ID:mor-vfx,项目名称:gaffer,代码行数:63,代码来源:Group.cpp

示例8: hash

static size_t hash( const InternedString &str )
{
	return boost::hash<const char *>()( str.c_str() );
}
开发者ID:ImageEngine,项目名称:cortex,代码行数:4,代码来源:InternedStringBinding.cpp

示例9: repr

static string repr( const InternedString &str )
{
	stringstream s;
	s << "IECore.InternedString(\"" << str.value() << "\")";
	return s.str();
}
开发者ID:ImageEngine,项目名称:cortex,代码行数:6,代码来源:InternedStringBinding.cpp

示例10: annotations

bool RenderManShader::acceptsInput( const Plug *plug, const Plug *inputPlug ) const
{
	if( !Shader::acceptsInput( plug, inputPlug ) )
	{
		return false;
	}

	if( !inputPlug )
	{
		return true;
	}

	if( parametersPlug()->isAncestorOf( plug ) )
	{
		const Plug *sourcePlug = inputPlug->source<Plug>();

		if( plug->typeId() == Plug::staticTypeId() )
		{
			// coshader parameter - source must be another
			// renderman shader hosting a coshader, or a box,
			// shader switch or dot with a currently dangling connection.
			// in the latter cases, we will be called again when the
			// box or switch is connected to something, so we can check
			// that the indirect connection is to our liking.
			const Node* sourceNode = sourcePlug->node();

			if(
				runTimeCast<const Box>( sourceNode ) ||
				runTimeCast<const ShaderSwitch>( sourceNode ) ||
				runTimeCast<const Dot>( sourceNode )
			)
			{
				return true;
			}

			const RenderManShader *inputShader = sourcePlug->parent<RenderManShader>();
			if(
				!inputShader ||
				sourcePlug != inputShader->outPlug() ||
				inputShader->typePlug()->getValue() != "ri:shader"
			)
			{
				return false;
			}
			// so far all is good, but we also need to check that
			// the coshaderType annotations match if present.
			ConstCompoundDataPtr dstAnnotations = annotations();
			if( !dstAnnotations )
			{
				return true;
			}
			InternedString parameterName = plug->getName();
			if( plug->parent<GraphComponent>() != parametersPlug() )
			{
				// array parameter
				parameterName = plug->parent<GraphComponent>()->getName();
			}
			const StringData *dstType = dstAnnotations->member<StringData>( parameterName.string() + ".coshaderType" );
			if( !dstType )
			{
				return true;
			}
			ConstCompoundDataPtr srcAnnotations = inputShader->annotations();
			if( !srcAnnotations )
			{
				return false;
			}
			const StringData *srcType = srcAnnotations->member<StringData>( "coshaderType" );
			if( !srcType )
			{
				return false;
			}

			// we accept a space (or comma) separated list of source types, so that a coshader
			// can belong to multiple types.
			typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
			Tokenizer srcTypes( srcType->readable(), boost::char_separator<char>( " ," ) );
			return find( srcTypes.begin(), srcTypes.end(), dstType->readable() ) != srcTypes.end();
		}
		else
		{
			// standard parameter - input must not be the
			// output of another shader.
			const Shader *inputShader = sourcePlug->ancestor<Shader>();
			return !inputShader || sourcePlug != inputShader->outPlug();
		}
	}

	return true;
}
开发者ID:cwmartin,项目名称:gaffer,代码行数:90,代码来源:RenderManShader.cpp

示例11: repr

string repr( InternedString &x )
{
	return "\"" + x.value() + "\"";
}
开发者ID:AtomicFiction,项目名称:cortex,代码行数:4,代码来源:SimpleTypedDataBinding.cpp

示例12: str

string str( InternedString &x )
{
	return x.value();
}
开发者ID:AtomicFiction,项目名称:cortex,代码行数:4,代码来源:SimpleTypedDataBinding.cpp

示例13: if

OP_Node *HoudiniScene::locateContent( OP_Node *node ) const
{
	OBJ_Node *objNode = node->castToOBJNode();
	if ( node->isManager() || ( objNode && objNode->getObjectType() == OBJ_SUBNET ) )
	{
		for ( int i=0; i < node->getNchildren(); ++i )
		{
			OP_Node *child = node->getChild( i );
			if ( child->getName().equal( contentName.c_str() ) )
			{
				return child;
			}
		}
	}
	else if ( objNode && objNode->getObjectType() == OBJ_GEOMETRY )
	{
		return objNode;
	}
	
	return 0;
}
开发者ID:danieldresser,项目名称:cortex,代码行数:21,代码来源:HoudiniScene.cpp


注:本文中的InternedString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。