コード例 #1
0
// -----------------------------------------------------------------------------
// Is passed string one of those listed in ActionList in ccetestconfigurations.h
// -----------------------------------------------------------------------------
//
TBool CConfigurationHandler::IsConfigRequest( TDesC8& aValue )
	{
	HBufC8* result = GetTokenValue(aValue, KId);

	if( !result )
		{
		return EFalse;
		}
		
	if( FindActionIndex(*result)==KErrNotFound )
		{
		delete result;
		return EFalse;
		}

	delete result;
	return ETrue;
	}
コード例 #2
0
// -----------------------------------------------------------------------------
// parse passed data
// ID + RETURN or LEAVE has to be found
// -----------------------------------------------------------------------------
//
TBool CConfigurationHandler::ParseData( TDesC8& aData, 
										CONFIGURATION_ITEM& aItem )
	{
	// get value for ID=
	HBufC8* id = GetTokenValue(aData, KId);

	if( !id )
		{
		RDebug::Print(_L("[TESTPLUGIN] CConfigurationHandler::ParseData ID= not found") );
		delete id;
		return EFalse;
		}

	// store index to action array
	aItem.iActionIndex = FindActionIndex(*id);
	delete id;


	// get value for TYPE=
	HBufC8* type = GetTokenValue(aData, KType);
	if( !type )
		{
		RDebug::Print(_L("[TESTPLUGIN] CConfigurationHandler::ParseData TYPE= not found") );
		delete type;
		return EFalse;
		}
	
	// todo is numeric check when needed
	// get value for RETURN=
	aItem.iIsLeaveValue = EFalse;
	HBufC8* strvalue = GetTokenValue(aData, KReturn);
	if( !strvalue )
		{
		delete strvalue; strvalue = NULL;
		// get value for LEAVE= as return value was not found
		strvalue = GetTokenValue(aData, KLeave);
		aItem.iIsLeaveValue = ETrue;
		}

	if( !strvalue )
		{
		RDebug::Print(_L("[TESTPLUGIN] CConfigurationHandler::ParseData: No RETURN= or LEAVE= found") );
		return EFalse;
		}


	// optional parameter
	HBufC8* persistant = GetTokenValue(aData, KPersistant );
	if( persistant )
		{
		TBool b;
		TLex8 l(*persistant);
		l.Val(b); 
		aItem.iIsPersistant = b;
		}
	else
		{
		aItem.iIsPersistant = EFalse;
		}
	delete persistant;
	
	if( type->Compare(_L8("TInt"))==KErrNone )
		{
		TInt v = 0;
		TLex8 lex(*strvalue);
		lex.Val(v);
		aItem.iValuePtr = new TInt(v); 
		}
	else if( type->Compare(_L8("TUint"))==KErrNone )
		{
		TUint v = 0;
		TLex8 lex(*strvalue);
		lex.Val(v);
		aItem.iValuePtr = new TUint(v); 
		}
	else if( type->Compare(_L8("TUid"))==KErrNone )
		{
		TInt v = 0;
		TLex8 lex(*strvalue);
		lex.Val(v);

		TUid u;
		u.iUid = v;
		aItem.iValuePtr = new TUid(u); 
		}
	else if( type->Compare(_L8("TBool"))==KErrNone )
		{
		TBool b;
		TLex8 l(*strvalue);
		l.Val(b); 
		aItem.iValuePtr = new TBool(b); 
		}
	else if( type->Compare(_L8("TDesC8"))==KErrNone )
		{
		HBufC8* buf = HBufC8::NewL(strvalue->Length()); 
		TPtr8 des = buf->Des();
		des.Append(*strvalue);
		aItem.iValuePtr = buf;
		}
	else if( type->Compare(_L8("CCCPCallParameters"))==KErrNone )
		{
		//CCCPCallParameters		
		}
	else
		{
		RDebug::Print(_L("[TESTPLUGIN] CConfigurationHandler::ParseData: No valid type found") );
		return EFalse;
		}


	delete type;
	delete strvalue;
	
	return ETrue;
	}
コード例 #3
0
ファイル: nxssetreader.cpp プロジェクト: rforge/phylobase
/*----------------------------------------------------------------------------------------------------------------------
|	Reads in a set from a NEXUS data file. Returns true if the set was terminated by a semicolon, false otherwise.
*/
bool NxsSetReader::Run()
	{
	bool ok;
	bool retval = false;

	unsigned rangeBegin = UINT_MAX;
	unsigned rangeEnd = rangeBegin;
	bool insideRange = false;
	unsigned modValue = 0;

	for (;;)
		{
		// Next token should be one of the following:
		//   ';'        --> set definition finished
		//   '-'        --> range being defined
		//   <integer>  --> member of set (or beginning or end of a range)
		//   '.'        --> signifies the number max
		//   '\'        --> signifies modulus value coming next
		//
		token.GetNextToken();

		if (token.Equals("-"))
			{
			// We should not be inside a range when we encounter a hyphenation symbol.
			// The hyphen is what _puts_ us inside a range!
			//
			if (insideRange)
				{
				block.errormsg = "The symbol '-' is out of place here";
				throw NxsException(block.errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
				}
			insideRange = true;
			}

		else if (token.Equals("."))
			{
			// We _should_ be inside a range if we encounter a period, as this
			// is a range termination character
			//
			if (!insideRange)
				{
				block.errormsg = "The symbol '.' can only be used to specify the end of a range";
				throw NxsException(block.errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
				}
			rangeEnd = max;
			}

		else if (token.Equals("\\"))
			{
			// The backslash character is used to specify a modulus to a range, and
			// thus should only be encountered if currently inside a range
			//
			if (!insideRange)
				{
				block.errormsg = "The symbol '\\' can only be used after the end of a range has been specified";
				throw NxsException(block.errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
				}

			// This should be the modulus value
			//
			modValue = NxsToken::DemandPositiveInt(token, block.errormsg, "The modulus value");
			}

		else if (insideRange && rangeEnd == UINT_MAX)
			{
			// The beginning of the range and the hyphen symbol have been read
			// already, just need to store the end of the range at this point
			//
			rangeEnd = GetTokenValue();
			}

		else if (insideRange)
			{
			// If insideRange is true, we must have already stored the beginning
			// of the range and read in the hyphen character. We would not have
			// made it this far if we had also not already stored the range end.
			// Thus, we can go ahead and add the range.
			//
			ok = AddRange(rangeBegin, rangeEnd, modValue);

			if (!ok)
				{
				block.errormsg = "Character number out of range (or range incorrectly specified) in set specification";
				throw NxsException(block.errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
				}

			// We have actually already read in the next token, so deal with it
			// now so that we don't end up skipping a token
			//
			if (token.Equals(";"))
				{
				retval = true;
				break;
				}
			else if (token.Equals(","))
				{
				break;
				}

			rangeBegin = GetTokenValue();
			rangeEnd = UINT_MAX;
			insideRange = false;
			}

		else if (rangeBegin != UINT_MAX)
			{
			// If we were inside a range, we would have not gotten this far.
			// If not in a range, we are either getting ready to begin a new
			// range or have previously read in a single value. Handle the
			// latter possibility here.
			//
			ok = AddRange(rangeBegin, rangeBegin, modValue);

			if (!ok)
				{
				block.errormsg = "Character number out of range (or range incorrectly specified) in set specification";
				throw NxsException(block.errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
				}

			if (token.Equals(";"))
				{
				retval = true;
				break;
				}
			else if (token.Equals(","))
				{
				break;
				}

			rangeBegin = GetTokenValue();
			rangeEnd = UINT_MAX;
			}

		else if (token.Equals(";"))
			{
			retval = true;
			break;
			}

		else if (token.Equals(","))
			{
			break;
			}

		else if (token.Equals("ALL"))
			{
			rangeBegin = 1;
			rangeEnd = max;
			ok = AddRange(rangeBegin, rangeEnd);
			}

		else
			{
			// Can only get here if rangeBegin still equals UINT_MAX and thus we
			// are reading in the very first token and that token is neither
			// the word "all" nor is it a semicolon
			//
			rangeBegin = GetTokenValue();
			rangeEnd = UINT_MAX;
			}
		}

	return retval;
	}