Update contrib.
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test/usb/t_usbdev/src/config.cpp
15 // USB Test Program T_USB_DEVICE.
16 // Reading and converting the XML configuration file.
24 _LIT(KCfgLDD1,"ENDPOINTS");
25 _LIT(KCfgLDD2,"SOFTCONNECT");
26 _LIT(KCfgLDD3,"SELFPOWER");
27 _LIT(KCfgLDD4,"REMOTEWAKEUP");
28 _LIT(KCfgLDD5,"HIGHSPEED");
29 _LIT(KCfgLDD6,"FEATURES");
30 _LIT(KCfgLDD7,"MAXPOWER");
31 _LIT(KCfgLDD8,"EPSTALL");
32 _LIT(KCfgLDD9,"SPEC");
33 _LIT(KCfgLDD10,"VID");
34 _LIT(KCfgLDD11,"PID");
35 _LIT(KCfgLDD12,"RELEASE");
36 _LIT(KCfgLDD13,"MANUFACTURER");
37 _LIT(KCfgLDD14,"PRODUCT");
38 _LIT(KCfgLDD15,"SERIALNUMBER");
39 _LIT(KCfgLDD16,"OTG");
40 _LIT(KCfgIF,"INTERFACE");
41 _LIT(KCfgIFS,"ALT_SETTING");
42 _LIT(KCfgIF1,"CLASS");
43 _LIT(KCfgIF2,"SUBCLASS");
44 _LIT(KCfgIF3,"PROTOCOL");
45 _LIT(KCfgIF4,"DESCRIPTOR");
46 _LIT(KCfgIF5,"BANDWIDTH_IN");
47 _LIT(KCfgIF6,"BANDWIDTH_OUT");
48 _LIT(KCfgEP,"ENDPOINT");
50 _LIT(KCfgEP2,"INTERVAL");
51 _LIT(KCfgEP3,"HSINTERVAL");
52 _LIT(KCfgEP4,"HSTRANSACTIONS");
54 _LIT(KCfgEP6,"DOUBLEBUFF");
55 _LIT(KCfgEP7,"EXTRA");
56 _LIT(KCfgEP8,"BUFFERSIZE");
57 _LIT(KCfgEP9,"READSIZE");
60 _LIT(KAttributeName,"name=");
61 _LIT(KAttributeNumber,"number=");
62 _LIT(KAttributeType,"type=");
63 _LIT(KAttributeDirection,"direction=");
65 _LIT(KEpBulk,"\"BULK\"");
66 _LIT(KEpInterrupt,"\"INTERRUPT\"");
67 _LIT(KEpIsochronous,"\"ISOCHRONOUS\"");
69 _LIT(KEpOut,"\"OUT\"");
71 static const TInt8 KMaxXMLNesting = 3; // max 3 levels of xml nesting
73 static const TPtrC xmlKeys[] =
75 (TDesC&)KCfgLDD, (TDesC&)KCfgLDD1, (TDesC&)KCfgLDD2, (TDesC&)KCfgLDD3, (TDesC&)KCfgLDD4, (TDesC&)KCfgLDD5, (TDesC&)KCfgLDD6,
76 (TDesC&)KCfgLDD7, (TDesC&)KCfgLDD8, (TDesC&)KCfgLDD9, (TDesC&)KCfgLDD10, (TDesC&)KCfgLDD11, (TDesC&)KCfgLDD12, (TDesC&)KCfgLDD13,
77 (TDesC&)KCfgLDD14, (TDesC&)KCfgLDD15, (TDesC&)KCfgLDD16,
78 (TDesC&)KCfgIF, (TDesC&)KCfgIFS, (TDesC&)KCfgIF1, (TDesC&)KCfgIF2, (TDesC&)KCfgIF3, (TDesC&)KCfgIF4, (TDesC&)KCfgIF5, (TDesC&)KCfgIF6,
79 (TDesC&)KCfgEP, (TDesC&)KCfgEP1, (TDesC&)KCfgEP2, (TDesC&)KCfgEP3, (TDesC&)KCfgEP4, (TDesC&)KCfgEP5, (TDesC&)KCfgEP6, (TDesC&)KCfgEP7, (TDesC&)KCfgEP8, (TDesC&)KCfgEP9
84 ExiLdd = 0, // xmlKeys index for LDD
101 ExiInterface, // xmlKeys index for Interface
109 ExiEndpoint, // xmlKeys index for Endpoint
122 // This array provides the index into xmlKeys for each level of xml key
123 // the first index for level n being defined by xmlLevels[n]
124 // and the last index for level n being defined by xmlLevels[n+1] - 1
125 // this means this must have two more entries than the number of nesting levels
126 // and the last entry must be the size of xmlKeys
127 static const TUint8 xmlLevels[] =
129 ExiLdd,ExiLdd+1,ExiSetting+1,ExiEndpoint+1,ExiLAST
132 LDDConfig::LDDConfig (TPtrC aName)
137 iSoftConnect = ETrue;
139 iRemoteWakeup = ETrue;
150 iManufacturer = NULL;
152 iSerialNumber = NULL;
158 IFConfig::IFConfig(TUint8 aNumber)
162 iAlternateSetting = EFalse;
164 iInfoPtr = new TUsbcScInterfaceInfo(0xFF,0xFF,0xFF);
166 iInfoPtr = new TUsbcInterfaceInfo(0xFF,0xFF,0xFF);
167 iBandwidthIn = EUsbcBandwidthINDefault;
168 iBandwidthOut = EUsbcBandwidthOUTDefault;
172 ConfigPtrs::ConfigPtrs (LDDConfigPtr * aLDDPtrPtr)
174 iNextLDDPtrPtr = aLDDPtrPtr;
175 iThisLDDPtr = * aLDDPtrPtr;
177 iNextIFPtrPtr = &iThisIFPtr; // initialised to prevent warning
181 extern TBool gVerbose;
183 extern TBool gStopOnFail;
184 extern TInt gSoakCount;
186 bool ProcessConfigFile (RFile aConfigFile,CConsoleBase* iConsole, LDDConfigPtr * LDDPtrPtr)
188 TUSB_PRINT ("Processing Configuration File");
190 TBuf8<100> configBuf;
195 XMLState state = EEmpty;
199 TBuf<50> endkeyString;
200 TBuf<50> attributeString;
201 TBuf<50> valueString;
203 TInt levelKeys[KMaxXMLNesting+1];
206 ConfigPtrsPtr cpPtr = new ConfigPtrs (LDDPtrPtr);
208 while (!done && !error)
210 rStatus = aConfigFile.Read((TDes8&)configBuf);
211 if (rStatus != KErrNone)
214 TUSB_PRINT1("Config file error %d", rStatus);
218 if (configBuf.Length() == 0)
224 stringBuf.Copy(configBuf);
225 for (TInt i = 0; i < stringBuf.Length() && !error; i++)
228 nextChar = stringBuf[i];
229 if (((nextChar == '<') && !((state == EEmpty) || (state == EValue))) ||
230 ((nextChar == '>') && ((state == EEmpty) || (state == EValue))) ||
231 ((nextChar == '/') && (lastChar != '<')))
234 TUSB_PRINT2 ("Config File Syntax Error at index %d of %s",i,stringBuf.PtrZ());
244 if (!nextChar.IsSpace())
247 TUSB_PRINT2 ("Config File Syntax Error at index %d of %s",i,stringBuf.PtrZ());
255 endkeyString.SetLength(0);
262 if (level > KMaxXMLNesting)
265 TUSB_PRINT1 ("Config File Too Many levels %s",stringBuf.PtrZ());
269 levelKeys[level] = CheckXmlKey (keyString,level);
270 if (levelKeys[level] < 0)
273 TUSB_PRINT1 ("Invalid XML key %s",keyString.PtrZ());
277 if (CheckAttribute(iConsole,cpPtr,levelKeys[level],attributeString))
280 TUSB_VERBOSE_PRINT2 ("Start key: %s level %d",keyString.PtrZ(),level);
285 TUSB_PRINT1 ("No attribute for XML key %s",keyString.PtrZ());
294 keyString.SetLength(0);
295 valueString.SetLength(0);
296 attributeString.SetLength(0);
297 if (nextChar.IsSpace())
300 TUSB_PRINT2 ("Config File Syntax Error at index %d of %s",i,stringBuf.PtrZ());
303 if (nextChar.IsSpace())
309 keyString.Append(nextChar);
318 if (levelKeys[level] != CheckXmlKey (endkeyString,level))
321 TUSB_PRINT1 ("Invalid XML end key %s",endkeyString.PtrZ());
325 if (CheckValue(iConsole,cpPtr,levelKeys[level],valueString))
328 TUSB_VERBOSE_PRINT2 ("End Key: %s value %s",endkeyString.PtrZ(),valueString.PtrZ());
330 valueString.SetLength(0);
335 TUSB_PRINT2 ("Incorrect value string %s for XML key %s",valueString.PtrZ(),endkeyString.PtrZ());
339 if (nextChar.IsSpace())
342 TUSB_PRINT2 ("Config File Syntax Error at index %d of %s",i,stringBuf.PtrZ());
346 endkeyString.Append(nextChar);
354 if (level > KMaxXMLNesting)
357 TUSB_PRINT1 ("Config File Too Many levels %s",stringBuf.PtrZ());
361 levelKeys[level] = CheckXmlKey (keyString,level);
362 if (levelKeys[level] < 0)
365 TUSB_PRINT1 ("Invalid XML key %s",keyString.PtrZ());
369 if (CheckAttribute(iConsole,cpPtr,levelKeys[level],attributeString))
372 TUSB_VERBOSE_PRINT3 ("Start key: %s level %d attribute %s",keyString.PtrZ(),level,attributeString.PtrZ());
377 TUSB_PRINT2 ("Incorrect attribute %s for XML key %s",attributeString.PtrZ(),keyString.PtrZ());
384 attributeString.Append(nextChar);
395 // Don't add any leading spaces
396 if (!nextChar.IsSpace() || valueString.Length() != 0)
398 valueString.Append(nextChar);
415 TBool CheckAttribute (CConsoleBase* iConsole, ConfigPtrsPtr cpPtr,TInt aKeyIndex, TPtrC aDes)
417 TBool retValue = ETrue;
418 TBuf<50> attrib = aDes;
433 if (attrib.Find(KAttributeName) == 0)
435 attrib.Delete(0,((TDesC&)KAttributeName).Length());
436 if (attrib[0] == ((TDesC&)KQuote)[0] && attrib[attrib.Length()-1] == ((TDesC&)KQuote)[0])
438 TUSB_VERBOSE_PRINT1 ("LDD with attribute name %s",attrib.PtrZ());
439 cpPtr->iThisLDDPtr = new LDDConfig (attrib.MidTPtr(1,attrib.Length()-2));
440 *cpPtr->iNextLDDPtrPtr = cpPtr->iThisLDDPtr;
441 cpPtr->iNextLDDPtrPtr = &(cpPtr->iThisLDDPtr->iPtrNext);
442 cpPtr->iNextIFPtrPtr = &(cpPtr->iThisLDDPtr->iIFPtr);
453 // level 1 index INTERFACE
455 if (attrib.Find(KAttributeNumber) == 0)
457 attrib.Delete(0,((TDesC&)KAttributeNumber).Length());
458 if (attrib[0] == ((TDesC&)KQuote)[0] && attrib[attrib.Length()-1] == ((TDesC&)KQuote)[0])
460 if (TDesToTUint(attrib.MidTPtr(1,attrib.Length()-2), &ifNumber))
462 if (cpPtr->iThisLDDPtr == NULL)
464 TUSB_PRINT ("No LDD container for interface");
470 TUSB_PRINT2 ("Number conversion error %s %d",attrib.PtrZ(),ifNumber);
476 TUSB_PRINT1 ("Attribute number not in \"\" %s",attrib.PtrZ());
482 TUSB_VERBOSE_PRINT1 ("Interface number %d",ifNumber);
483 cpPtr->iThisIFPtr = new IFConfig ((TUint8)ifNumber);
484 * cpPtr->iNextIFPtrPtr = cpPtr->iThisIFPtr;
485 cpPtr->iNextIFPtrPtr = &cpPtr->iThisIFPtr->iPtrNext;
486 cpPtr->iThisLDDPtr->iNumChannels++;
491 // level 1 index Setting
493 if (aDes.Length() != 0)
499 if (cpPtr->iThisLDDPtr == NULL)
501 TUSB_PRINT ("No LDD container for interface");
506 TUSB_VERBOSE_PRINT ("Alternate Interface Setting");
507 cpPtr->iThisIFPtr = new IFConfig (0);
508 * cpPtr->iNextIFPtrPtr = cpPtr->iThisIFPtr;
509 cpPtr->iNextIFPtrPtr = &cpPtr->iThisIFPtr->iPtrNext;
510 cpPtr->iThisIFPtr->iAlternateSetting = ETrue;
515 // level 2 index ENDPOINT
517 typePos = attrib.Find(KAttributeType);
518 dirPos = attrib.Find(KAttributeDirection);
520 if (typePos == KErrNotFound || dirPos == KErrNotFound)
526 if (typePos < dirPos)
528 typePos += ((TDesC&)KAttributeType).Length();
529 typeLen = dirPos - typePos;
530 dirPos += ((TDesC&)KAttributeDirection).Length();
531 dirLen = attrib.Length() - dirPos;
535 dirPos += ((TDesC&)KAttributeDirection).Length();
536 dirLen = typePos - dirPos;
537 typePos += ((TDesC&)KAttributeType).Length();
538 typeLen = attrib.Length() - typePos;
540 TPtr attribPtr = attrib.MidTPtr(typePos,typeLen);
541 attribPtr.UpperCase();
543 if (attribPtr == KEpBulk)
545 epType = KUsbEpTypeBulk;
549 if (attribPtr == KEpInterrupt)
551 epType = KUsbEpTypeInterrupt;
555 if (attribPtr == KEpIsochronous)
557 epType = KUsbEpTypeIsochronous;
565 attribPtr = attrib.MidTPtr(dirPos,dirLen);
566 attribPtr.UpperCase();
568 if (attribPtr == KEpIn)
574 if (attribPtr == KEpOut)
576 epDir = KUsbEpDirOut;
585 if (cpPtr->iThisIFPtr == NULL)
587 TUSB_PRINT ("No Interface container for Endpoint");
592 TUint epIndex = cpPtr->iThisIFPtr->iInfoPtr->iTotalEndpointsUsed;
593 TUSB_VERBOSE_PRINT2 ("Endpoint with type %d %d",epType,epDir);
594 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iType = epType;
595 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iDir = epDir;
597 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iBufferSize = 65536;
598 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iReadSize = 4096;
600 cpPtr->iThisIFPtr->iEpDMA[epIndex] = EFalse;
601 cpPtr->iThisIFPtr->iEpDoubleBuff[epIndex] = EFalse;
602 cpPtr->iThisIFPtr->iInfoPtr->iTotalEndpointsUsed++;
609 if (aDes.Length() != 0)
618 TBool CheckValue (CConsoleBase* iConsole, ConfigPtrsPtr cpPtr, TInt aKeyIndex, TPtrC16 aDes)
620 TBool retValue = ETrue;
625 if (cpPtr->iThisIFPtr != NULL)
627 epIndex = cpPtr->iThisIFPtr->iInfoPtr->iTotalEndpointsUsed -1;
630 TUSB_VERBOSE_PRINT2 ("CheckValue keyIndex %d %s",aKeyIndex,aDes.Ptr());
633 case ExiLdd: // xmlKeys index for LDD
634 case ExiInterface: // xmlKeys index for Interface
635 case ExiEndpoint: // xmlKeys index for Endpoint
636 if (aDes.Length() != 0)
643 retValue = TDesToTUint (aDes, &uintValue);
644 if (uintValue == 0 || uintValue > 128)
650 cpPtr->iThisLDDPtr->iNumEndpoints = uintValue;
655 retValue = TDesToBool (aDes, &boolValue);
656 if (cpPtr->iThisLDDPtr == NULL)
660 cpPtr->iThisLDDPtr->iSoftConnect = boolValue;
665 retValue = TDesToBool (aDes, &boolValue);
666 if (cpPtr->iThisLDDPtr == NULL)
670 cpPtr->iThisLDDPtr->iSelfPower = boolValue;
674 case ExiRemoteWakeup:
675 retValue = TDesToBool (aDes, &boolValue);
676 if (cpPtr->iThisLDDPtr == NULL)
680 cpPtr->iThisLDDPtr->iRemoteWakeup = boolValue;
685 retValue = TDesToBool (aDes, &boolValue);
686 if (cpPtr->iThisLDDPtr == NULL)
690 cpPtr->iThisLDDPtr->iHighSpeed = boolValue;
695 retValue = TDesToTUint (aDes, &uintValue);
696 if (cpPtr->iThisLDDPtr == NULL)
700 cpPtr->iThisLDDPtr->iFeatures = uintValue;
705 retValue = TDesToTUint (aDes, &uintValue);
706 if (cpPtr->iThisLDDPtr == NULL || uintValue > 50)
710 cpPtr->iThisLDDPtr->iMaxPower = uintValue;
715 retValue = TDesToBool (aDes, &boolValue);
716 if (cpPtr->iThisLDDPtr == NULL)
720 cpPtr->iThisLDDPtr->iEPStall = boolValue;
725 retValue = TDesToTUint (aDes, &uintValue);
726 if (cpPtr->iThisLDDPtr == NULL)
730 cpPtr->iThisLDDPtr->iSpec = uintValue;
735 retValue = TDesToTUint (aDes, &uintValue);
736 if (cpPtr->iThisLDDPtr == NULL)
740 cpPtr->iThisLDDPtr->iVid = uintValue;
745 retValue = TDesToTUint (aDes, &uintValue);
746 if (cpPtr->iThisLDDPtr == NULL)
750 cpPtr->iThisLDDPtr->iPid = uintValue;
755 retValue = TDesToTUint (aDes, &uintValue);
756 if (cpPtr->iThisLDDPtr == NULL)
760 cpPtr->iThisLDDPtr->iRelease = uintValue;
764 case ExiManufacturer:
765 cpPtr->iThisLDDPtr->iManufacturer = aDes.Alloc();
769 cpPtr->iThisLDDPtr->iProduct = aDes.Alloc();
772 case ExiSerialNumber:
773 cpPtr->iThisLDDPtr->iSerialNumber = aDes.Alloc();
780 retValue = TDesToTUint (aDes, &uintValue);
781 if (cpPtr->iThisIFPtr == NULL || uintValue > 0xFF)
785 cpPtr->iThisIFPtr->iInfoPtr->iClass.iClassNum = uintValue;
790 retValue = TDesToTUint (aDes, &uintValue);
791 if (cpPtr->iThisIFPtr == NULL || uintValue > 0xFF)
795 cpPtr->iThisIFPtr->iInfoPtr->iClass.iSubClassNum = uintValue;
800 retValue = TDesToTUint (aDes, &uintValue);
801 if (cpPtr->iThisIFPtr == NULL || uintValue > 0xFF)
805 cpPtr->iThisIFPtr->iInfoPtr->iClass.iProtocolNum = uintValue;
810 cpPtr->iThisIFPtr->iInfoPtr->iString = aDes.Alloc();
817 retValue = TDesToTUint (aDes, &uintValue);
818 if (cpPtr->iThisIFPtr == NULL || uintValue > 3)
825 cpPtr->iThisIFPtr->iBandwidthIn = EUsbcBandwidthINDefault;
828 cpPtr->iThisIFPtr->iBandwidthIn = EUsbcBandwidthINPlus1;
831 cpPtr->iThisIFPtr->iBandwidthIn = EUsbcBandwidthINPlus2;
834 cpPtr->iThisIFPtr->iBandwidthIn = EUsbcBandwidthINMaximum;
841 case ExiBandwidthOut:
845 retValue = TDesToTUint (aDes, &uintValue);
846 if (cpPtr->iThisIFPtr == NULL || uintValue > 3)
853 cpPtr->iThisIFPtr->iBandwidthOut = EUsbcBandwidthOUTDefault;
856 cpPtr->iThisIFPtr->iBandwidthOut = EUsbcBandwidthOUTPlus1;
859 cpPtr->iThisIFPtr->iBandwidthOut = EUsbcBandwidthOUTPlus2;
862 cpPtr->iThisIFPtr->iBandwidthOut = EUsbcBandwidthOUTMaximum;
870 retValue = TDesToTUint (aDes, &uintValue);
875 TBool defaultIF = cpPtr->iThisLDDPtr->iIFPtr == cpPtr->iThisIFPtr;
876 switch (cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iType)
878 case KUsbEpTypeBulk :
879 if (cpPtr->iThisLDDPtr->iHighSpeed)
881 if (uintValue != 512)
886 if (!(uintValue == 8 || uintValue == 16 || uintValue == 32 || uintValue == 64))
891 case KUsbEpTypeInterrupt :
892 if ((defaultIF && uintValue > 64) ||
893 (!cpPtr->iThisLDDPtr->iHighSpeed && uintValue > 64) ||
894 (!defaultIF && cpPtr->iThisLDDPtr->iHighSpeed && uintValue > 1024))
898 case KUsbEpTypeIsochronous :
899 if ((defaultIF && uintValue > 0) ||
900 (!defaultIF && !cpPtr->iThisLDDPtr->iHighSpeed && uintValue > 1023) ||
901 (!defaultIF && cpPtr->iThisLDDPtr->iHighSpeed && uintValue > 1024))
907 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iSize = uintValue;
914 retValue = TDesToTUint (aDes, &uintValue);
919 switch (cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iType)
921 case KUsbEpTypeBulk :
925 case KUsbEpTypeInterrupt :
926 if (uintValue < 1 || uintValue > 255)
930 case KUsbEpTypeIsochronous :
931 if (uintValue < 1 || uintValue > 16)
937 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iInterval = uintValue;
943 retValue = TDesToTUint (aDes, &uintValue);
944 if (epIndex < 0 || !cpPtr->iThisLDDPtr->iHighSpeed)
948 switch (cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iType)
950 case KUsbEpTypeBulk :
955 case KUsbEpTypeInterrupt :
956 if (uintValue < 1 || uintValue > 16)
960 case KUsbEpTypeIsochronous :
961 if (uintValue < 1 || uintValue > 16)
967 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iInterval_Hs = uintValue;
972 case ExiHSTransactions:
973 retValue = TDesToTUint (aDes, &uintValue);
974 if (epIndex < 0 || !cpPtr->iThisLDDPtr->iHighSpeed)
982 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iTransactions = uintValue;
988 retValue = TDesToBool (aDes, &boolValue);
993 cpPtr->iThisIFPtr->iEpDMA[epIndex] = boolValue;
1001 retValue = TDesToBool (aDes, &boolValue);
1006 cpPtr->iThisIFPtr->iEpDoubleBuff[epIndex] = boolValue;
1012 retValue = TDesToTUint (aDes, &uintValue);
1017 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iExtra = uintValue;
1023 retValue = TDesToTUint (aDes, &uintValue);
1024 if (epIndex < 0 || uintValue < 4096)
1028 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iBufferSize = uintValue;
1037 retValue = TDesToTUint (aDes, &uintValue);
1038 if (epIndex < 0 || uintValue < 1024)
1042 cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iReadSize = uintValue;
1053 TInt CheckXmlKey (TPtrC aKey,TInt aLevel)
1057 for (TInt i = xmlLevels[aLevel]; i < xmlLevels[aLevel+1]; i++)
1059 if (aKey == xmlKeys[i])
1070 TBool TDesToTUint (TPtrC aDes, TUint * aValue)
1072 _LIT (KHexPrefix,"0x");
1073 TBuf<50> numDes = aDes;
1074 TBool hexBase = EFalse;
1075 TBool conversionOK = ETrue;
1076 TUint8 desIndex = 0;
1079 if (numDes.LeftTPtr(((TDesC&)KHexPrefix).Length()) == KHexPrefix)
1082 desIndex = ((TDesC&)KHexPrefix).Length();
1085 while (desIndex < numDes.Length() && conversionOK)
1089 TUint maxValue = 0xFFFFFFFF >> 4;
1090 if (((TChar)numDes[desIndex]).IsHexDigit() && * aValue <= maxValue)
1093 * aValue += ((TChar)numDes[desIndex]).IsDigit() ? numDes[desIndex] - '0' : ((TChar)numDes[desIndex]).GetUpperCase() - 'A' + 10;
1097 conversionOK = EFalse;
1103 TUint maxValue = 0xFFFFFFFF / 10;
1104 if (((TChar)numDes[desIndex]).IsDigit())
1106 TUint digit = numDes[desIndex] - '0';
1107 if ((* aValue < maxValue) || (* aValue == maxValue && digit <= 5))
1114 conversionOK = EFalse;
1120 conversionOK = EFalse;
1128 return conversionOK;
1131 TBool TDesToBool (TPtrC aDes, TBool * aValue)
1135 TBool conversionOK = ETrue;
1136 TBuf<50> boolDes = aDes;
1139 boolDes.UpperCase();
1140 if (boolDes == KBoolY)
1146 if (boolDes == KBoolN)
1152 conversionOK = EFalse;
1156 return conversionOK;