示例#1
0
//++ ------------------------------------------------------------------------------------
// Details: Extract the thread group number from the thread group argument.
// Type:    Method.
// Args:    vrTxt   - (R) Some text.
// Return:  MIstatus::success - Functional succeeded.
//          MIstatus::failure - Functional failed.
// Throws:  None.
//--
bool
CMICmdArgValThreadGrp::ExtractNumber(const CMIUtilString &vrTxt)
{
    const CMIUtilString strNum = vrTxt.substr(1);
    MIint64 nNumber = 0;
    bool bOk = strNum.ExtractNumber(nNumber);
    if (bOk)
    {
        m_nThreadGrp = static_cast<MIuint>(nNumber);
    }

    return bOk;
}
示例#2
0
//++ ------------------------------------------------------------------------------------
// Details:	Given a file name directory path, strip off the filename and return the path.
//			It look for either backslash or forward slash.
// Type:	Method.
// Args:	vDirectoryPath	- (R) Text directory path.
// Return:	CMIUtilString - Directory path.
// Throws:	None.
//--
CMIUtilString CMIUtilFileStd::StripOffFileName( const CMIUtilString & vDirectoryPath ) const
{
	const MIint nPos = vDirectoryPath.rfind( '\\' );
	MIint nPos2 = vDirectoryPath.rfind( '/' );
	if( (nPos == (MIint) std::string::npos) && (nPos2 == (MIint) std::string::npos) )
		return vDirectoryPath;

	if( nPos > nPos2 )
		nPos2 = nPos;

	const CMIUtilString strPath( vDirectoryPath.substr( 0, nPos2 ).c_str() );
	return strPath;
}
示例#3
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('i');
    if (nPos != 0)
        return false;

    const CMIUtilString strNum = vrTxt.substr(1);
    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();
}
示例#5
0
//++ ------------------------------------------------------------------------------------
// Details:	Parse the command's argument options string and try to extract all the words
//			between quotes then delimited by the next space. If there any string format
//			characters '\\' used to embed quotes these are ignored i.e. "\\\"%5d\\\""
//			becomes "%5d". Can fall through to ValidateQuotedText().
// Type:	Method.
// Args:	vrwArgContext	- (RW) The command's argument options string.
// Return:	MIstatus::success - Functional succeeded.
//			MIstatus::failure - Functional failed.
// Throws:	None.
//--
bool CMICmdArgValString::ValidateQuotedTextEmbedded( CMICmdArgContext & vrwArgContext )
{
	// CODETAG_QUOTEDTEXT_SIMILAR_CODE
	CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
	const MIchar cBckSlash = '\\'; 
	const MIint nPos = strOptions.find( cBckSlash );
	if( nPos == (MIint) std::string::npos )
		return ValidateQuotedText( vrwArgContext );

	// Back slash must be the first character in the string or be preceeded by a space
	// or '\\'
	const MIchar cSpace = ' ';
	if( (nPos > 0) && (strOptions[ nPos - 1 ] != cSpace) )
		return MIstatus::failure;

	// Need to find the other back slash
	const MIint nPos2 = strOptions.rfind( cBckSlash );
	if( nPos2 == (MIint) std::string::npos )
		return MIstatus::failure;

	// Make sure not same back slash, need two slashs
	if( nPos == nPos2 )
		return MIstatus::failure;

	// Look for the two quotes
	const MIint nLen = strOptions.length();
	const MIchar cQuote = '"';
	const MIint nPosQuote1 = nPos + 1;
	const MIint nPosQuote2 = (nPos2 < nLen) ? nPos2 + 1 : nPos2;
	if( (nPosQuote1 != nPosQuote2) && 
		(strOptions[ nPosQuote1 ] != cQuote) && (strOptions[ nPosQuote2 ] != cQuote) )
		return MIstatus::failure;

	// Extract quoted text
	const CMIUtilString strQuotedTxt = strOptions.substr( nPos, nPosQuote2 - nPos + 1 ).c_str();
	if( vrwArgContext.RemoveArg( strQuotedTxt ) )
	{
		m_bFound = true;
		m_bValid = true;
		m_argValue = strQuotedTxt;	
		return MIstatus::success;
	}

	return MIstatus::failure;
}
示例#6
0
//++ ------------------------------------------------------------------------------------
// Details:	Does the command entered match the criteria for a MI command format.
//			The format to validate against is 'nnA' where there can be 1 to n digits.
//			'A' represents any non numeric token. I.e. '1source .gdbinit'.
//			Is the execution token present? The command token is entered into the
//			command meta data structure whether correct or not for reporting or later
//			command execution purposes.
// Type:	Method.
// Args:	vTextLine	- (R) Text data to interpret.
// Return:	bool  - True = yes command token present, false = command not recognised.
// Throws:	None.
//--
bool CMICmdInterpreter::MiHasCmdTokenEndingAlpha( const CMIUtilString & vTextLine )
{
    MIchar cChar = vTextLine[ 0 ];
    MIuint i = 0;
    while( ::isdigit( cChar ) != 0 )
    {
        cChar = vTextLine[ ++i ];
    }
    if( ::isalpha( cChar ) == 0 )
        return false;
    if( i == 0 )
        return false;

    const std::string strNum = vTextLine.substr( 0, i );
    m_miCmdData.strMiCmdToken = strNum.c_str();
    m_miCmdData.bMIOldStyle = true;

    return true;
}
示例#7
0
//++ ------------------------------------------------------------------------------------
// Details:	Does the command entered match the criteria for a MI command format.
//			The format to validate against is 'nn-' where there can be 1 to n digits.
//			I.e. '2-gdb-exit'.
//			Is the execution token present? The command token is entered into the
//			command meta data structure whether correct or not for reporting or later
//			command execution purposes.
// Type:	Method.
// Args:	vTextLine	- (R) Text data to interpret.
// Return:	bool  - True = yes command token present, false = command not recognised.
// Throws:	None.
//--
bool CMICmdInterpreter::MiHasCmdTokenEndingHypthen( const CMIUtilString & vTextLine )
{
    // The hythen is mandatory
    const MIint nPos = vTextLine.find( "-", 0 );
    if( (nPos == (MIint) std::string::npos) )
        return false;

    if( MiHasCmdTokenPresent( vTextLine ) )
    {
        const std::string strNum = vTextLine.substr( 0, nPos );
        if( !CMIUtilString( strNum.c_str() ).IsNumber() )
            return false;

        m_miCmdData.strMiCmdToken = strNum.c_str();
    }

    m_miCmdData.bMIOldStyle = 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_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;
}
//++
// Details: Does the argument name of the argument being parsed ATM match the
// name of
//          *this argument object.
// Type:    Method.
// Args:    vrTxt   - (R) Some text.
// Return:  bool    - True = yes arg name matched, false = no.
// Throws:  None.
//--
bool CMICmdArgValOptionLong::ArgNameMatch(const CMIUtilString &vrTxt) const {
  const CMIUtilString strArg = vrTxt.substr(2);
  return (strArg == GetName());
}