TBool CExampleResolver::Match(const TDesC8& aImplementationType, 
	const TDesC8& aMatchType, 
	TBool aUseWildcards) const
	{
	TInt matchPos = KErrNotFound;

	_LIT8(dataSeparator, "||");
	const TInt separatorLength = dataSeparator().Length();

	// Look for the section separator marker '||'
	TInt separatorPos = aImplementationType.Find(dataSeparator);
	if(separatorPos == KErrNotFound)
		{
		// Match against the whole string
		if(aUseWildcards)
			matchPos = aImplementationType.Match(aMatchType);
		else
			matchPos = aImplementationType.Compare(aMatchType);
		}
	else
		{
		// Find the first section, up to the separator
		TPtrC8 dataSection = aImplementationType.Left(separatorPos);
		TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength);
		// Match against each section in turn
		while(separatorPos != KErrNotFound)
			{
			// Search this section
			if(aUseWildcards)
				matchPos = dataSection.Match(aMatchType);
			else
				matchPos = dataSection.Compare(aMatchType);

			// If we found it then no need to continue, so return
			if(matchPos != KErrNotFound)
				return ETrue;

			// Move on to the next section
			separatorPos = remainingData.Find(dataSeparator);
			if(separatorPos != KErrNotFound)
				{
				dataSection.Set(remainingData.Left(separatorPos));
				remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
				}
			else
				dataSection.Set(remainingData);
			}

		// Check the final part
		if(aUseWildcards)
			matchPos = dataSection.Match(aMatchType);
		else
			matchPos = dataSection.Compare(aMatchType);

		}
	return matchPos != KErrNotFound;
	}
/**
ConstructL()
Parses a .txt file and creates Arrays of fields and there values

@param aFileName
Name of the file to be parsed.
*/
EXPORT_C void CT_MsgUtilsConfigFileParserUtility::ConstructL(const TDesC& aFileName)
	{
	RFs fileServerSession;

	fileServerSession.Connect();

	RFile file;
	User::LeaveIfError(file.Open(fileServerSession, aFileName, EFileRead));

	TInt eof = EFalse;
	TInt fileOffset = 0;
	TBuf8<KFileBufferSize> fileBuffer;

	while (!eof)
		{
		fileBuffer.SetLength(0);
		User::LeaveIfError(file.Read(fileOffset, fileBuffer, KFileBufferSize));
		TInt read = fileBuffer.Length();

		if (read < KFileBufferSize)
			{
			fileBuffer.Append('\n');
			eof = ETrue;
			}

		TInt lineOverflow = fileBuffer.Locate('\n');
		
		if ((lineOverflow == KErrNotFound) && (read == KFileBufferSize))
			{
			User::Leave(KErrOverflow);
			}

		TInt eol = EFalse;
		
		while (!eol)
			{
			TInt lineFeedLocation = fileBuffer.Locate('\n');
			
			if (lineFeedLocation == KErrNotFound)
				{
				eol = ETrue;
				}
			
			else
				{
				fileOffset += lineFeedLocation + 1;
				TInt lineLength;
				if ((lineFeedLocation != 0) && (fileBuffer[lineFeedLocation - 1] == '\r'))
					{
					lineLength = lineFeedLocation - 1;
					}
					
				else
					{
					lineLength = lineFeedLocation;
					}
					
				TPtrC8 line  = fileBuffer.Left(lineLength);
				TInt commentLocation = line.Match(KComment);
				
				if (commentLocation != KErrNotFound)
					{
					TPtrC8 skipComment = line.Left(commentLocation);
					line.Set(skipComment);
					}
					
				TInt seperatorLocation = line.Locate('=');
				
				if (seperatorLocation != KErrNotFound)
					{
					if ((seperatorLocation == 0) || (seperatorLocation == line.Length() - 1))
						{
						seperatorLocation = KErrNotFound;
						}
					}
					
				if (seperatorLocation != KErrNotFound)
					{
					TPtrC8 namePtr = line.Left(seperatorLocation);
					HBufC8* nameBuf8 = HBufC8::NewL(namePtr.Length());
					CleanupStack::PushL(nameBuf8);
					
					TPtr8 name8 = nameBuf8->Des();
					name8.Copy(namePtr);
					name8.Trim();
					HBufC* nameBuf16 = HBufC::NewL(namePtr.Length());
					TPtr name16 = nameBuf16->Des();
					name16.Copy(name8);
					iName.Append(nameBuf16);
					CleanupStack::PopAndDestroy(nameBuf8);

					TPtrC8 contentPtr = line.Mid(seperatorLocation + 1);
					HBufC8* contentBuf8 = HBufC8::NewL(contentPtr.Length());
					CleanupStack::PushL(contentBuf8);
					TPtr8 content8 = contentBuf8->Des();
					content8.Copy(contentPtr);
					content8.Trim();
					
					HBufC* contentBuf16 = HBufC::NewL(contentPtr.Length());
					TPtr content16 = contentBuf16->Des();
					content16.Copy(content8);
					iContent.Append(contentBuf16);
					iContent8.Append(contentBuf8);
					CleanupStack::Pop(contentBuf8);
					}
				TPtrC8 theRest = fileBuffer.Mid(lineFeedLocation + 1);
				fileBuffer.Copy(theRest);
				}
			}
		}
	file.Close();
	fileServerSession.Close();
	}