os/kernelhwsrv/kernel/eka/euser/us_lex8.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/us_lex8.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,881 @@
     1.4 +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\euser\us_lex8.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "us_std.h"
    1.22 +
    1.23 +
    1.24 +
    1.25 +
    1.26 +EXPORT_C TLex8::TLex8()
    1.27 +	: iNext(NULL),iBuf(NULL),iEnd(NULL),iMark(NULL)
    1.28 +/**
    1.29 +Default constructor.
    1.30 +
    1.31 +Constructs a TLex8, initialising its members to NULL.
    1.32 +*/
    1.33 +	{}
    1.34 +
    1.35 +
    1.36 +
    1.37 +
    1.38 +EXPORT_C void TLex8::Assign(const TUint8 *aString)
    1.39 +/**
    1.40 +Assigns a string to this object from another string.
    1.41 +
    1.42 +@param aString A pointer to a string to be assigned.
    1.43 +*/
    1.44 +	{
    1.45 +
    1.46 +	iMark.iPtr=iNext=iBuf=aString;
    1.47 +	iEnd=iBuf+User::StringLength(aString);
    1.48 +	}
    1.49 +
    1.50 +
    1.51 +
    1.52 +
    1.53 +EXPORT_C void TLex8::Assign(const TDesC8 &aDes)
    1.54 +/**
    1.55 +Assigns a string to this object from a descriptor.
    1.56 +
    1.57 +@param aDes The descriptor to be assigned.
    1.58 +*/
    1.59 +	{
    1.60 +
    1.61 +	iMark.iPtr=iNext=iBuf=aDes.Ptr();
    1.62 +	iEnd=iBuf+aDes.Length();
    1.63 +	}
    1.64 +
    1.65 +
    1.66 +
    1.67 +
    1.68 +EXPORT_C void TLex8::UnGet()
    1.69 +/**
    1.70 +Decrements the next character position, allowing a previously "got" character 
    1.71 +to be re-read.
    1.72 +
    1.73 +@panic USER 59, if the previous character is before the start of the string.
    1.74 +*/
    1.75 +	{
    1.76 +
    1.77 +	__ASSERT_ALWAYS(iNext>iBuf,Panic(ETLex8UnGetUnderflow));
    1.78 +	iNext--;
    1.79 +	}
    1.80 +
    1.81 +
    1.82 +
    1.83 +
    1.84 +EXPORT_C void TLex8::UnGetToMark(const TLexMark8 aMark)
    1.85 +/**
    1.86 +Sets the next character position to the supplied extraction mark position.
    1.87 +
    1.88 +@param aMark Mark to copy to the next character position.
    1.89 +
    1.90 +@panic USER 63, if the extraction mark is before the start or beyond the end
    1.91 +       of the string.
    1.92 +*/
    1.93 +	{
    1.94 +
    1.95 +	ValidateMark(aMark);
    1.96 +	iNext=aMark.iPtr;
    1.97 +	}
    1.98 +
    1.99 +
   1.100 +
   1.101 +
   1.102 +EXPORT_C void TLex8::Inc(TInt aNumber)
   1.103 +/**
   1.104 +Increments the next character position by aNumber.
   1.105 +
   1.106 +@param aNumber The number of characters to increment the next character position 
   1.107 +               by. 
   1.108 +               
   1.109 +@panic USER 60, if the increment puts the next character position before the
   1.110 +                start or beyond the end of the string.
   1.111 +*/
   1.112 +	{
   1.113 +
   1.114 +	iNext+=aNumber;
   1.115 +	__ASSERT_ALWAYS(iNext>=iBuf && iNext<=iEnd,Panic(ETLex8IncOutOfRange));
   1.116 +	}
   1.117 +
   1.118 +
   1.119 +
   1.120 +
   1.121 +EXPORT_C void TLex8::Inc()
   1.122 +/**
   1.123 +Increments to the next character position.
   1.124 + 
   1.125 +@panic USER 60, if the increment puts the next character position beyond the
   1.126 +       end of the string.
   1.127 +*/
   1.128 +	{
   1.129 +
   1.130 +	if (!Eos())
   1.131 +		iNext++;
   1.132 +	__ASSERT_ALWAYS(iNext<=iEnd,Panic(ETLex8IncOutOfRange));
   1.133 +	}
   1.134 +
   1.135 +
   1.136 +
   1.137 +
   1.138 +EXPORT_C TChar TLex8::Get()
   1.139 +/**
   1.140 +Gets the next character in the string, and increments the next
   1.141 +character position.
   1.142 +
   1.143 +@return Next character to be read.0 if at the end of the string.
   1.144 +*/
   1.145 +	{
   1.146 +
   1.147 +	if (Eos())
   1.148 +		return(0);
   1.149 +	return(*iNext++);
   1.150 +	}
   1.151 +
   1.152 +
   1.153 +
   1.154 +
   1.155 +EXPORT_C TChar TLex8::Peek() const
   1.156 +/**
   1.157 +Shows the next character to be returned by Get().
   1.158 +
   1.159 +@return Character to be returned by the next call to Get(). 0 if at the
   1.160 +        end of the string.
   1.161 +      
   1.162 +@see TLex8::Get
   1.163 +*/
   1.164 +	{
   1.165 +
   1.166 +	if (Eos())
   1.167 +		return(0);
   1.168 +	return(*iNext);
   1.169 +	}
   1.170 +
   1.171 +
   1.172 +
   1.173 +
   1.174 +EXPORT_C void TLex8::SkipSpace()
   1.175 +/** 
   1.176 +Moves the next character position past any white space (space or separator).
   1.177 + 
   1.178 +Stops if at the end of string.
   1.179 +*/
   1.180 +	{
   1.181 +
   1.182 +	while (!Eos() && Peek().IsSpace())
   1.183 +		iNext++;
   1.184 +	}
   1.185 +
   1.186 +
   1.187 +
   1.188 +
   1.189 +EXPORT_C void TLex8::SkipAndMark(TInt aNumber,TLexMark8& aMark)
   1.190 +/**
   1.191 +Moves the next character position a specified number of characters and copies 
   1.192 +it to the specified extraction mark.
   1.193 +
   1.194 +@param aNumber Number of characters to skip.  
   1.195 +@param aMark   On return, set to the next character position. 
   1.196 +
   1.197 +@panic USER 61, if the skip moves the next character position either to before
   1.198 +       the start or beyond the end of the string.
   1.199 +*/
   1.200 +	{
   1.201 +
   1.202 +	iNext+=aNumber;
   1.203 +	__ASSERT_ALWAYS(iNext>=iBuf && iNext<=iEnd,Panic(ETLex8SkipOutOfRange));
   1.204 +	Mark(aMark);
   1.205 +	}
   1.206 +
   1.207 +
   1.208 +
   1.209 +
   1.210 +EXPORT_C void TLex8::SkipSpaceAndMark(TLexMark8& aMark)
   1.211 +/**
   1.212 +Moves the next character position past any white space and copies it to the 
   1.213 +specified extraction mark.
   1.214 +
   1.215 +Stops if at the end of the string.
   1.216 +
   1.217 +@param aMark On return, contains a reference to the next character position.
   1.218 +*/
   1.219 +	{
   1.220 +
   1.221 +	SkipSpace();
   1.222 +	Mark(aMark);
   1.223 +	}
   1.224 +
   1.225 +
   1.226 +
   1.227 +
   1.228 +EXPORT_C void TLex8::SkipCharacters()
   1.229 +/**
   1.230 +Moves the next character position to the next white space (space or separator). 
   1.231 +
   1.232 +Stops if at the end of the string.
   1.233 +*/
   1.234 +	{
   1.235 +
   1.236 +	while (!Eos() && !Peek().IsSpace())
   1.237 +		iNext++;
   1.238 +	}
   1.239 +
   1.240 +
   1.241 +
   1.242 +
   1.243 +EXPORT_C TInt TLex8::TokenLength(const TLexMark8 aMark) const
   1.244 +/**
   1.245 +Gets the length of the token starting at the specified extraction mark.
   1.246 +
   1.247 +@param aMark Extraction mark indicating the start of the token.
   1.248 +
   1.249 +@return Length of the token.
   1.250 +
   1.251 +@panic USER 63, if the specified mark is before the start or beyond the end
   1.252 +       of the string.
   1.253 +*/
   1.254 +	{
   1.255 +
   1.256 +	ValidateMark(aMark);
   1.257 +	return (iNext-aMark.iPtr);
   1.258 +	}
   1.259 +
   1.260 +
   1.261 +
   1.262 +
   1.263 +EXPORT_C TPtrC8 TLex8::MarkedToken(const TLexMark8 aMark) const
   1.264 +/**
   1.265 +Extracts the token, starting at the specified mark
   1.266 +
   1.267 +@param aMark Extraction mark indicating the start of the token.
   1.268 +
   1.269 +@return Extracted token.
   1.270 +
   1.271 +@panic USER 63, if the specified mark is before the start or beyond the end
   1.272 +       of the string.
   1.273 +*/
   1.274 +	{
   1.275 +
   1.276 +	return(TPtrC8(aMark.iPtr,TokenLength(aMark)));
   1.277 +	}
   1.278 +
   1.279 +
   1.280 +
   1.281 +
   1.282 +EXPORT_C TPtrC8 TLex8::MarkedToken() const
   1.283 +//
   1.284 +// Extract the internally marked token
   1.285 +// there is the assumption here that iMark is always valid
   1.286 +/**
   1.287 +Extracts the marked token.
   1.288 +
   1.289 +Note that the function assumes that the current extraction mark is valid.
   1.290 +
   1.291 +@return Extracted token.
   1.292 +
   1.293 +@panic USER 63, if the specified mark is before the start or beyond the end
   1.294 +       of the string.
   1.295 +*/
   1.296 +	{
   1.297 +
   1.298 +	return(TPtrC8(iMark.iPtr,TokenLength()));
   1.299 +	}
   1.300 +
   1.301 +
   1.302 +
   1.303 +
   1.304 +EXPORT_C TPtrC8 TLex8::NextToken()
   1.305 +/**
   1.306 +Strips any white space and extracts the next token.
   1.307 +
   1.308 +@return Extracted token.
   1.309 +*/
   1.310 +	{
   1.311 +	TLexMark8 mark;
   1.312 +
   1.313 +	SkipSpaceAndMark(mark);
   1.314 +	SkipCharacters();
   1.315 +	return(TPtrC8(mark.iPtr,TokenLength(mark)));
   1.316 +	}
   1.317 +
   1.318 +
   1.319 +
   1.320 +
   1.321 +EXPORT_C TPtrC8 TLex8::Remainder() const
   1.322 +/**
   1.323 +Gets a descriptor containing all the text from the next character position 
   1.324 +to the end of the string.
   1.325 +
   1.326 +@return Text from the next character position onwards.
   1.327 +
   1.328 +@panic USER 29, if the value of (next character position - extraction mark) is
   1.329 +       negative.
   1.330 +*/
   1.331 +	{
   1.332 +
   1.333 +	return(TPtrC8(iNext,iEnd-iNext));
   1.334 +	}
   1.335 +
   1.336 +
   1.337 +
   1.338 +
   1.339 +EXPORT_C TPtrC8 TLex8::RemainderFromMark(const TLexMark8 aMark) const
   1.340 +/**
   1.341 +Gets a descriptor containing all the text from the specified extraction mark 
   1.342 +to the end of the string.
   1.343 +
   1.344 +@param aMark Extraction mark indicating where remaining text starts.
   1.345 +
   1.346 +@return Text from the specified extraction mark onwards.
   1.347 +
   1.348 +@panic USER 29, if the value of (next character position - extraction mark) is
   1.349 +       negative.
   1.350 +@panic USER 63, if the specified mark is before the start or beyond the end
   1.351 +       of the string.
   1.352 +*/
   1.353 +	{
   1.354 +
   1.355 +	ValidateMark(aMark);
   1.356 +	return(TPtrC8(aMark.iPtr,iEnd-aMark.iPtr));
   1.357 +	}
   1.358 +
   1.359 +
   1.360 +
   1.361 +
   1.362 +EXPORT_C TPtrC8 TLex8::RemainderFromMark() const
   1.363 +//
   1.364 +// Return the remainder from iMark
   1.365 +// There is an assumption here that the internal mark will always be valid
   1.366 +//
   1.367 +/**
   1.368 +Gets a descriptor containing all the text from the current extraction mark to the end 
   1.369 +of the string.
   1.370 +
   1.371 +The function assumes that the current extraction mark is valid.
   1.372 +
   1.373 +@return Text from the extraction mark onwards.
   1.374 +*/
   1.375 +	{
   1.376 +	
   1.377 +	return(TPtrC8(iMark.iPtr,iEnd-iMark.iPtr));
   1.378 +	}
   1.379 +
   1.380 +
   1.381 +
   1.382 +
   1.383 +EXPORT_C TInt TLex8::Offset() const
   1.384 +//
   1.385 +// Return the offset from iNext to the lex start.
   1.386 +//
   1.387 +/**
   1.388 +Gets the offset of the next character position from the start of the string.
   1.389 +
   1.390 +@return Offset of next character position.
   1.391 +*/
   1.392 +	{
   1.393 +
   1.394 +	return((TUint)(iNext-iBuf));
   1.395 +	}
   1.396 +
   1.397 +
   1.398 +
   1.399 +
   1.400 +EXPORT_C TInt TLex8::MarkedOffset(const TLexMark8 aMark) const
   1.401 +/**
   1.402 +Gets the offset of the specified extraction mark from the start of the string.
   1.403 +
   1.404 +@param aMark Extraction mark. 
   1.405 + 
   1.406 +@return The offset of the extraction mark.
   1.407 +
   1.408 +@panic USER 63, if the specified mark is before the start or beyond the end
   1.409 +       of the string.
   1.410 +*/
   1.411 +	{
   1.412 +
   1.413 +	ValidateMark(aMark);
   1.414 +	return((TUint)(aMark.iPtr-iBuf));
   1.415 +	}
   1.416 +
   1.417 +
   1.418 +
   1.419 +
   1.420 +EXPORT_C TInt TLex8::BoundedVal(TUint32 &aVal,TRadix aRadix,TUint aLimit)
   1.421 +/**
   1.422 +Parses the string to extract a 32-bit unsigned integer, using the
   1.423 +specified radix, and checks that it is within the specified limit.
   1.424 +
   1.425 +The specified radix is one of binary, octal, decimal, or hexadecimal.
   1.426 +
   1.427 +@param aVal   On return, contains the extracted integer.
   1.428 +@param aRadix The radix to use when converting the number.
   1.429 +@param aLimit The upper limit.
   1.430 +
   1.431 +@return KErrNone if successful.
   1.432 +        KErrGeneral if the next character position is initially at the end of the string
   1.433 +        or no valid characters found initially.
   1.434 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.435 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.436 +        members are left unaltered.
   1.437 +*/
   1.438 +	{
   1.439 +
   1.440 +	TUint l=aLimit/aRadix;
   1.441 +	TUint v=0;
   1.442 +	TUint d=0;
   1.443 +	TLexMark8 mark(iNext);
   1.444 +	while (!Eos())
   1.445 +		{
   1.446 +		TChar c=Peek(); 
   1.447 +		if (!c.IsHexDigit())
   1.448 +			break; 
   1.449 +		c=Get(); 
   1.450 +		if (c.IsAlpha())
   1.451 +			{
   1.452 +			c.UpperCase();
   1.453 +			c-=('A'-10);
   1.454 +			}
   1.455 +		else
   1.456 +			c-='0';
   1.457 +		if (c>=(TUint)aRadix)
   1.458 +			{
   1.459 +			iNext--;
   1.460 +			break;
   1.461 +			}
   1.462 +		if (v>l)
   1.463 +			{
   1.464 +			UnGetToMark(mark);
   1.465 +			return(KErrOverflow);
   1.466 +			}
   1.467 +		TUint o=v;
   1.468 +		v*=aRadix;
   1.469 +		v+=c;
   1.470 +		if (o>v)
   1.471 +			{
   1.472 +			UnGetToMark(mark);
   1.473 +			return(KErrOverflow);
   1.474 +			}
   1.475 +		d++;
   1.476 +		}
   1.477 +	if (d==0)
   1.478 +		{
   1.479 +		UnGetToMark(mark);
   1.480 +		return(KErrGeneral);
   1.481 +		}
   1.482 +	if (v>aLimit)
   1.483 +		{
   1.484 +		UnGetToMark(mark);
   1.485 +		return(KErrOverflow);
   1.486 +		}
   1.487 +	aVal=v;
   1.488 +	return(KErrNone);
   1.489 +	}
   1.490 +
   1.491 +
   1.492 +
   1.493 +
   1.494 +EXPORT_C TInt TLex8::BoundedVal(TInt32 &aVal,TInt aLimit)
   1.495 +/**
   1.496 +Parses the string to extract a 32-bit signed integer, and checks that it is
   1.497 +within the specified limit.
   1.498 +
   1.499 +@param aVal   On return, contains the extracted integer.
   1.500 +@param aLimit The upper limit.
   1.501 +
   1.502 +@return KErrNone if successful.
   1.503 +        KErrGeneral if the next character position is initially at the end of the string
   1.504 +        or no valid characters found initially.
   1.505 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.506 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.507 +        members are left unaltered.
   1.508 +*/
   1.509 +	{
   1.510 +
   1.511 +	if (Eos())
   1.512 +		return(KErrGeneral);
   1.513 +	TUint lim=aLimit;
   1.514 +	TLexMark8 mark(iNext);
   1.515 +	TUint s=FALSE;
   1.516 +	TChar c=Peek();
   1.517 +	if (c=='-')
   1.518 +		{
   1.519 +		lim++;
   1.520 +		s++;
   1.521 +		Inc();
   1.522 +		}
   1.523 +	else if (c=='+')
   1.524 +		Inc();
   1.525 +	TUint32 v;
   1.526 +	TInt r=BoundedVal(v,EDecimal,lim);
   1.527 +	if (r==KErrNone)
   1.528 +		{
   1.529 +		if (v>lim)
   1.530 +			r=KErrOverflow;
   1.531 +		else if (s)
   1.532 +			aVal=(-((TInt32)v));
   1.533 +		else
   1.534 +			aVal=v;
   1.535 +		}
   1.536 +	if (r!=KErrNone)
   1.537 +		UnGetToMark(mark);
   1.538 +	return(r);
   1.539 +	}
   1.540 +
   1.541 +
   1.542 +
   1.543 +
   1.544 +EXPORT_C TInt TLex8::BoundedVal(TInt64& aVal, TRadix aRadix, const TInt64& aLimit)
   1.545 +/**
   1.546 +Parses the string to extract a 64-bit signed integer, using the
   1.547 +specified radix, and checks that it is within the specified limit.
   1.548 +
   1.549 +The specified radix is one of binary, octal, decimal, or hexadecimal.
   1.550 +
   1.551 +@param aVal   On return, contains the extracted integer.
   1.552 +@param aRadix The radix to use when converting the number.
   1.553 +@param aLimit The upper limit.
   1.554 +
   1.555 +@return KErrNone if successful.
   1.556 +        KErrGeneral if the next character position is initially at the end of the string
   1.557 +        or no valid characters found initially.
   1.558 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.559 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.560 +        members are left unaltered.
   1.561 +*/
   1.562 +	{
   1.563 +	TUint64 rad = aRadix;
   1.564 +	TUint64 lim = static_cast<TUint64>(aLimit);
   1.565 +
   1.566 +	lim /= rad;
   1.567 +
   1.568 +	TUint64 v = 0;
   1.569 +	TUint digit=0;
   1.570 +	TLexMark8 mark(iNext);
   1.571 +	while (!Eos())
   1.572 +		{
   1.573 +		TChar c=Peek(); 
   1.574 +		if (!c.IsHexDigit())
   1.575 +			break;	  
   1.576 +		c=Get(); 
   1.577 +		if (c.IsAlpha())
   1.578 +			{
   1.579 +			c.UpperCase();
   1.580 +			c-=('A'-10);
   1.581 +			}
   1.582 +		else
   1.583 +			c-='0';
   1.584 +		if (c >= rad)
   1.585 +			{
   1.586 +			iNext--;
   1.587 +			break;
   1.588 +			}
   1.589 +		if (v > lim)
   1.590 +			{
   1.591 +			UnGetToMark(mark);
   1.592 +			return(KErrOverflow);
   1.593 +			}
   1.594 +		TUint64 old = v;
   1.595 +		v*=rad;
   1.596 +		v+=c;
   1.597 +		if (old > v)
   1.598 +			{
   1.599 +			UnGetToMark(mark);
   1.600 +			return(KErrOverflow);
   1.601 +			}
   1.602 +		digit++;
   1.603 +		}
   1.604 +	if (digit==0)
   1.605 +		{
   1.606 +		UnGetToMark(mark);
   1.607 +		return(KErrGeneral);
   1.608 +		}
   1.609 +	if (v > static_cast<TUint64>(aLimit))
   1.610 +		{
   1.611 +		UnGetToMark(mark);
   1.612 +		return(KErrOverflow);
   1.613 +		}
   1.614 +	aVal = static_cast<TInt64>(v);
   1.615 +	return(KErrNone);
   1.616 +	}
   1.617 +
   1.618 +
   1.619 +
   1.620 +
   1.621 +EXPORT_C TInt TLex8::BoundedVal(TInt64& aVal, const TInt64& aLimit)
   1.622 +/**
   1.623 +Parses the string to extract a 64-bit signed integer, and checks that it
   1.624 +is within the specified limit.
   1.625 +
   1.626 +@param aVal   On return, contains the extracted integer.
   1.627 +@param aLimit The upper limit.
   1.628 +
   1.629 +@return KErrNone if successful.
   1.630 +        KErrGeneral if the next character position is initially at the end of the string
   1.631 +        or no valid characters found initially.
   1.632 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.633 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.634 +        members are left unaltered.
   1.635 +*/
   1.636 +	{
   1.637 +
   1.638 +	if (Eos())
   1.639 +		return(KErrGeneral);
   1.640 +	TInt64 lim = aLimit;
   1.641 +	TLexMark8 mark(iNext);
   1.642 +	TBool s=EFalse;
   1.643 +	TChar c=Peek();
   1.644 +	if (c=='-')
   1.645 +		{
   1.646 +		lim++;
   1.647 +		s++;
   1.648 +		Inc();
   1.649 +		}
   1.650 +	else if (c=='+')
   1.651 +		Inc();
   1.652 +	TInt64 v;
   1.653 +	TInt r=BoundedVal(v,EDecimal,lim);
   1.654 +	if (r==KErrNone)
   1.655 +		{
   1.656 +		if (v>lim)
   1.657 +			r=KErrOverflow;
   1.658 +		else if (s)
   1.659 +			aVal=(-v);
   1.660 +		else
   1.661 +			aVal=v;
   1.662 +		}
   1.663 +	if (r!=KErrNone)
   1.664 +		UnGetToMark(mark);
   1.665 +	return(r);
   1.666 +	}
   1.667 +
   1.668 +
   1.669 +
   1.670 +
   1.671 +EXPORT_C TInt TLex8::Val(TInt8 &aVal)
   1.672 +/**
   1.673 +Parses the string to extract a signed 8-bit integer.
   1.674 +
   1.675 +@param aVal On return, contains the extracted integer.
   1.676 +
   1.677 +@return KErrNone if successful.
   1.678 +        KErrGeneral if the next character position is initially at the end of the string
   1.679 +        or no valid characters found initially.
   1.680 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.681 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.682 +        members are left unaltered.
   1.683 +*/
   1.684 +	{
   1.685 +
   1.686 +	TInt32 v;
   1.687 +	TInt r=BoundedVal(v,0x7fu);
   1.688 +	if (r==KErrNone)
   1.689 +		aVal=(TInt8)v;
   1.690 +	return(r);
   1.691 +	}
   1.692 +
   1.693 +
   1.694 +
   1.695 +
   1.696 +EXPORT_C TInt TLex8::Val(TInt16 &aVal)
   1.697 +/**
   1.698 +Parses the string to extract a signed 16-bit integer.
   1.699 +
   1.700 +@param aVal On return, contains the extracted integer.
   1.701 +
   1.702 +@return KErrNone if successful.
   1.703 +        KErrGeneral if the next character position is initially at the end of the string
   1.704 +        or no valid characters found initially.
   1.705 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.706 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.707 +        members are left unaltered.
   1.708 +*/
   1.709 +	{
   1.710 +
   1.711 +	TInt32 v;
   1.712 +	TInt r=BoundedVal(v,0x7fffu);
   1.713 +	if (r==KErrNone)
   1.714 +		aVal=(TInt16)v;
   1.715 +	return(r);
   1.716 +	}
   1.717 +
   1.718 +
   1.719 +
   1.720 +
   1.721 +EXPORT_C TInt TLex8::Val(TInt32 &aVal)
   1.722 +/**
   1.723 +Parses the string to extract a signed 32-bit integer.
   1.724 +
   1.725 +@param aVal On return, contains the extracted integer.
   1.726 +
   1.727 +@return KErrNone if successful.
   1.728 +        KErrGeneral if the next character position is initially at the end of the string
   1.729 +        or no valid characters found initially.
   1.730 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.731 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.732 +        members are left unaltered.
   1.733 +*/
   1.734 +	{
   1.735 +
   1.736 +	TInt32 v;
   1.737 +	TInt r=BoundedVal(v,0x7fffffffu);
   1.738 +	if (r==KErrNone)
   1.739 +		aVal=v;
   1.740 +	return(r);
   1.741 +	}
   1.742 +
   1.743 +
   1.744 +
   1.745 +EXPORT_C TInt TLex8::Val(TInt64& aVal)
   1.746 +/**
   1.747 +Parses the string to extract a signed 64-bit integer.
   1.748 +
   1.749 +@param aVal On return, contains the extracted integer.
   1.750 +
   1.751 +@return KErrNone if successful.
   1.752 +        KErrGeneral if the next character position is initially at the end of the string
   1.753 +        or no valid characters found initially.
   1.754 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.755 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.756 +        members are left unaltered.
   1.757 +*/
   1.758 +	{
   1.759 +
   1.760 +	TChar c=Peek();
   1.761 +	if (c=='-' || c=='+')
   1.762 +		Inc();
   1.763 +	TInt r;
   1.764 +	if (c=='-')
   1.765 +		{
   1.766 +		r=BoundedVal(aVal, EDecimal, UI64LIT(0x8000000000000000));
   1.767 +		if (r==KErrNone)
   1.768 +			aVal=-aVal;
   1.769 +		}
   1.770 +	else
   1.771 +		r=BoundedVal(aVal, UI64LIT(0x7fffffffffffffff));
   1.772 +	return(r);
   1.773 +	}
   1.774 +
   1.775 +
   1.776 +
   1.777 +
   1.778 +EXPORT_C TInt TLex8::Val(TUint8 &aVal,TRadix aRadix)
   1.779 +/**
   1.780 +Parses the string to extract an 8-bit unsigned integer, using the
   1.781 +specified radix.
   1.782 +
   1.783 +The specified radix is one of binary, octal, decimal, or hexadecimal.
   1.784 +
   1.785 +@param aVal   On return, contains the extracted integer.
   1.786 +@param aRadix The radix to use when converting the number.
   1.787 +
   1.788 +@return KErrNone if successful.
   1.789 +        KErrGeneral if the next character position is initially at the end of the string
   1.790 +        or no valid characters found initially.
   1.791 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.792 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.793 +        members are left unaltered.
   1.794 +*/
   1.795 +	{
   1.796 +
   1.797 +	TUint32 v;
   1.798 +	TInt r=BoundedVal(v,aRadix,0xffu);
   1.799 +	if (r==KErrNone)
   1.800 +		aVal=(TUint8)v;
   1.801 +	return(r);
   1.802 +	}
   1.803 +
   1.804 +EXPORT_C TInt TLex8::Val(TUint16 &aVal,TRadix aRadix)
   1.805 +/**
   1.806 +Parses the string to extract a 16-bit unsigned integer, using the
   1.807 +specified radix.
   1.808 +
   1.809 +The specified radix is one of binary, octal, decimal, or hexadecimal.
   1.810 +
   1.811 +@param aVal   On return, contains the extracted integer.
   1.812 +@param aRadix The radix to use when converting the number.
   1.813 +
   1.814 +@return KErrNone if successful.
   1.815 +        KErrGeneral if the next character position is initially at the end of the string
   1.816 +        or no valid characters found initially.
   1.817 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.818 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.819 +        members are left unaltered.
   1.820 +*/
   1.821 +	{
   1.822 +
   1.823 +	TUint32 v;
   1.824 +	TInt r=BoundedVal(v,aRadix,0xffffu);
   1.825 +	if (r==KErrNone)
   1.826 +		aVal=(TUint16)v;
   1.827 +	return(r);
   1.828 +	}
   1.829 +
   1.830 +EXPORT_C TInt TLex8::Val(TUint32 &aVal,TRadix aRadix)
   1.831 +/**
   1.832 +Parses the string to extract a 32-bit unsigned integer, using the
   1.833 +specified radix.
   1.834 +
   1.835 +The specified radix is one of binary, octal, decimal, or hexadecimal.
   1.836 +
   1.837 +@param aVal   On return, contains the extracted integer.
   1.838 +@param aRadix The radix to use when converting the number.
   1.839 +
   1.840 +@return KErrNone if successful.
   1.841 +        KErrGeneral if the next character position is initially at the end of the string
   1.842 +        or no valid characters found initially.
   1.843 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.844 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.845 +        members are left unaltered.
   1.846 +*/
   1.847 +	{
   1.848 +
   1.849 +	TUint32 v;
   1.850 +	TInt r=BoundedVal(v,aRadix,0xffffffffu);
   1.851 +	if (r==KErrNone)
   1.852 +		aVal=v;
   1.853 +	return(r);
   1.854 +	}
   1.855 +
   1.856 +EXPORT_C TInt TLex8::Val(TInt64& aVal, TRadix aRadix)
   1.857 +/**
   1.858 +Parses the string to extract a 64-bit integer (treated as unsigned), using the
   1.859 +specified radix.
   1.860 +
   1.861 +The specified radix is one of binary, octal, decimal, or hexadecimal.
   1.862 +
   1.863 +@param aVal   On return, contains the extracted integer.
   1.864 +@param aRadix The radix to use when converting the number.
   1.865 +
   1.866 +@return KErrNone if successful.
   1.867 +        KErrGeneral if the next character position is initially at the end of the string
   1.868 +        or no valid characters found initially.
   1.869 +        KErrOverflow if there is sign overflow, i.e. converted value greater than limit.
   1.870 +        If error codes KErrGeneral or KErrOverflow are returned, the object's
   1.871 +        members are left unaltered.
   1.872 +*/
   1.873 +	{
   1.874 +
   1.875 +	return BoundedVal(aVal,aRadix,TInt64(UI64LIT(0xffffffffffffffff)));
   1.876 +	}
   1.877 +
   1.878 +void TLex8::ValidateMark(const TLexMark8 aMark) const
   1.879 +//
   1.880 +// Asserts that the mark is valid for this lex
   1.881 +//
   1.882 +	{
   1.883 +	__ASSERT_ALWAYS(aMark.iPtr>=iBuf && aMark.iPtr<=iEnd,Panic(ETLex8MarkOutOfRange));
   1.884 +	}