示例#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
//++ ------------------------------------------------------------------------------------
// 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;
}
//++
// 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('/') != std::string::npos);
  const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos);
  if (bHavePosSlash || bHaveBckSlash)
    return false;

  const size_t nPos = vrTxt.find("--");
  if (nPos != 0)
    return false;

  if (vrTxt.length() < 3)
    return false;

  const CMIUtilString strArg = vrTxt.substr(2);
  return !strArg.IsNumber();
}
//++ ------------------------------------------------------------------------------------
// 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;
}