コード例 #1
0
//++ ------------------------------------------------------------------------------------
// Details:	Examine the string and determine if it is a valid string type argument or 
//			option value. If the string looks like a long option, short option, a thread
//			group ID or just a number it is rejected as a string type value. There is an
//			option to allow the string to accept a number as a string type.
// Type:	Method.
// Args:	vrTxt	- (R) Some text.
// Return:	bool -	True = yes valid argument value, false = something else.
// Throws:	None.
//--
bool CMICmdArgValString::IsStringArgSingleText( const CMIUtilString & vrTxt ) const
{
	if( !m_bHandleDirPaths )
	{
		// Look for directory file paths, if found reject
		const bool bHavePosSlash = (vrTxt.find_first_of( "/" ) != std::string::npos);
		const bool bHaveBckSlash = (vrTxt.find_first_of( "\\" ) != std::string::npos);
		if( bHavePosSlash || bHaveBckSlash )
			return false;
	}

	// Look for --someLongOption, if found reject
	if( 0 == vrTxt.find( "--" ) )
		return false;
	
	// Look for -f type short options, if found reject
	if( (0 == vrTxt.find( "-" )) && (vrTxt.length() == 2 ) )
		return false;
		
	// Look for thread group i1 i2 i3...., if found reject
	if( (vrTxt.find( "i" ) == 0) && (::isdigit( vrTxt[ 1 ] )) )
		return false;
	
	// Look for numbers, if found reject
	if( !m_bAcceptNumbers && vrTxt.IsNumber() )
		return false;

	return true;
}
コード例 #2
0
ファイル: MICmdArgValFile.cpp プロジェクト: Jean-Daniel/lldb
//++ ------------------------------------------------------------------------------------
// Details:	Examine the string and determine if it is a valid file name path.
// Type:	Method.
// Args:	vrFileNamePath	- (R) File's name and directory path.
// Return:	bool -	True = yes valid file path, false = no.
// Throws:	None.
//--
bool CMICmdArgValFile::IsFilePath( const CMIUtilString & vrFileNamePath ) const
{
	const bool bHavePosSlash = (vrFileNamePath.find_first_of( "/" ) != std::string::npos);
	const bool bHaveBckSlash = (vrFileNamePath.find_first_of( "\\" ) != std::string::npos);
	
	// Look for --someLongOption
	MIint nPos = vrFileNamePath.find_first_of( "--" );
	const bool bLong = (nPos == 0);
	if( bLong )
		return false;
	
	// Look for -f type short parameters
	nPos = vrFileNamePath.find_first_of( "-" );
	const bool bShort = (nPos == 0);
	if( bShort )
		return false;
	
	// Look for i1 i2 i3....
	nPos = vrFileNamePath.find_first_of( "i" );
	const bool bFoundI1 = ((nPos == 0) && (::isdigit( vrFileNamePath[ 1 ] )) );
	if( bFoundI1 )
		return false;
	
	const bool bValidChars = CMIUtilString::IsAllValidAlphaAndNumeric( *vrFileNamePath.c_str() );
	if( bValidChars || bHavePosSlash || bHaveBckSlash )
		return true;

	return false;
}
コード例 #3
0
//++ ------------------------------------------------------------------------------------
// Details:	Examine the string and determine if it is a valid long type option argument.
//			Long type argument looks like --someLongOption.
// Type:	Method.
// Args:	vrTxt	- (R) Some text.
// Return:	bool -	True = yes valid arg, false = no.
// Throws:	None.
//--
bool CMICmdArgValOptionLong::IsArgLongOption( const CMIUtilString & vrTxt ) const
{
	const bool bHavePosSlash = (vrTxt.find_first_of( "/" ) != std::string::npos);
	const bool bHaveBckSlash = (vrTxt.find_first_of( "\\" ) != std::string::npos);
	if( bHavePosSlash || bHaveBckSlash )
		return false;

	const MIint nPos = vrTxt.find_first_of( "--" );
	if( nPos != 0 )
		return false;
	
	if( vrTxt.length() < 3 )
		return false;

	const CMIUtilString strArg = vrTxt.substr( 2 ).c_str();
	if( strArg.IsNumber() )
		return false;

	return true;
}
コード例 #4
0
ファイル: MICmdArgValThreadGrp.cpp プロジェクト: chee-z/lldb
//++ ------------------------------------------------------------------------------------
// Details:	Examine the string and determine if it is a valid string type argument.
// Type:	Method.
// Args:	vrTxt	- (R) Some text.
// Return:	bool -	True = yes valid arg, false = no.
// Throws:	None.
//--
bool CMICmdArgValThreadGrp::IsArgThreadGrp( const CMIUtilString & vrTxt ) const
{
	// Look for i1 i2 i3....
	const MIint nPos = vrTxt.find_first_of( "i" );
	if( nPos != 0 )
		return false;
	
	const CMIUtilString strNum = vrTxt.substr( 1 ).c_str();
	if( !strNum.IsNumber() )
		return false;

	return true;
}