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


C++ VariableList::rend方法代码示例

本文整理汇总了C++中VariableList::rend方法的典型用法代码示例。如果您正苦于以下问题:C++ VariableList::rend方法的具体用法?C++ VariableList::rend怎么用?C++ VariableList::rend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VariableList的用法示例。


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

示例1: if

bool
EngineParser::getTypeNameAndScopeByToken (ExpressionResult &result, 
    									  string &token,
    									  string &op,
    									  const string& full_file_path, 
    									  unsigned long linenum,
    									  const string& above_text,
    									  string &out_type_name, 
    									  string &out_type_scope)
{
	if (result.m_isaType) 
	{
		DEBUG_PRINT ("*** Found a cast expression");
		/*
		 * Handle type (usually when casting is found)
		 */
		if (result.m_isPtr && op == ".") 
		{
			DEBUG_PRINT ("Did you mean to use '->' instead of '.' ?");
			return false;
		}
		
		if (!result.m_isPtr && op == "->") 
		{
			DEBUG_PRINT ("Can not use '->' operator on a non pointer object");
			return false;
		}

		out_type_scope = result.m_scope.empty() ? "" : result.m_scope.c_str();
		out_type_name = result.m_name.c_str();
		return true;
	} 
	else if (result.m_isThis) 
	{
		DEBUG_PRINT ("*** Found 'this'");
		
		/* special handle for 'this' keyword */
		if (op == "::") 
		{
			DEBUG_PRINT ("'this' can not be used with operator ::");
			return false;
		}

		if (result.m_isPtr && op == ".") 
		{
			DEBUG_PRINT ("Did you mean to use '->' instead of '.' ?");
			return false;
		}
			
		if (!result.m_isPtr && op == "->") 
		{
			DEBUG_PRINT ("Can not use '->' operator on a non pointer object");
			return false;
		}

		/* reaching this point we are quite sure that the easiest tests about "this"
		 * calling are passed. Go on finding for the first symbol of type class that
		 * is reachable through the scopes chain.
		 */	

		/* will we find a good class scope? */
		out_type_scope = result.m_scope.empty() ? "" : result.m_scope.c_str();
		out_type_name = ""; 

		getNearestClassInCurrentScopeChainByFileLine (full_file_path.c_str (), linenum, out_type_name);
		if (out_type_name.empty ()) 
		{
			DEBUG_PRINT ("'this' has not a type name");
			return false;
		}
		
		return true;
	}
	else if (op == "::")
	{
		out_type_name = token;
		out_type_scope = result.m_scope.empty() ? "" : result.m_scope.c_str();
		return true;
	}
	else 
	{
		/*
		 * Found an identifier (can be a local variable, a global one etc)
		 */			
		DEBUG_PRINT ("*** Found an identifier or local variable...");

		/* optimize scope'll clear the scopes leaving the local variables */
		string optimized_scope = optimizeScope(above_text);

		VariableList li;
		std::map<std::string, std::string> ignoreTokens;
		get_variables(optimized_scope, li, ignoreTokens, false);

		/* here the trick is to start from the end of the found variables
		 * up to the begin. This because the local variable declaration should be found
		 * just above to the statement line 
		 */
		for (VariableList::reverse_iterator iter = li.rbegin(); iter != li.rend(); iter++) 
		{
			Variable var = (*iter);
//.........这里部分代码省略.........
开发者ID:VujinovM,项目名称:anjuta,代码行数:101,代码来源:engine-parser.cpp


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