diff -r 7d4490026038 -r 44f437012c90 persistentstorage/dbms/tdbms/t_dbcmdlineutil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/persistentstorage/dbms/tdbms/t_dbcmdlineutil.cpp Tue Oct 19 16:26:13 2010 +0100 @@ -0,0 +1,147 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// +#include +#include "t_dbcmdlineutil.h" + +static void GetCmdLine(RTest& aTest, const TDesC& aTestName, TDes& aCmdLine) + { + User::CommandLine(aCmdLine); + aCmdLine.TrimAll(); + if(aCmdLine.Length() == 0) + { + aTest.Printf(_L("Usage: %S [/drv=:] [/logfile=]\r\n"), &aTestName); + return; + } + aCmdLine.Append(TChar('/')); + } + +static void ExtractCmdLineParams(TDes& aCmdLine, RArray& aPrmNames, RArray& aPrmValues) + { + aPrmNames.Reset(); + aPrmValues.Reset(); + + enum TState{EWaitPrmStart, EReadPrmName, EReadPrmValue}; + TState state = EWaitPrmStart; + TInt startPos = -1; + TPtr prmName(0, 0); + TPtr prmValue(0, 0); + + aCmdLine.Append(TChar('/')); + + for(TInt i=0;i& aPrmNames, const RArray& aPrmValues, TCmdLineParams& aCmdLineParams) + { + __ASSERT_ALWAYS(aPrmNames.Count() == aPrmValues.Count(), User::Invariant()); + + aCmdLineParams.SetDefaults(); + + for(TInt i=0;i= TChar('a') && ch <= TChar('z')) + aCmdLineParams.iDriveName.Copy(aPrmValues[i]); + } + } + else if(aPrmNames[i].CompareF(_L("logfile")) == 0) + { + aCmdLineParams.iLogFileName.Copy(aPrmValues[i]); + } + } + } + +void GetCmdLineParams(RTest& aTest, const TDesC& aTestName, TCmdLineParams& aCmdLineParams) + { + TBuf<200> cmdLine; + GetCmdLine(aTest, aTestName, cmdLine); + RArray prmNames; + RArray prmValues; + ExtractCmdLineParams(cmdLine, prmNames, prmValues); + ExtractParamNamesAndValues(prmNames, prmValues, aCmdLineParams); + prmValues.Close(); + prmNames.Close(); + aTest.Printf(_L("--PRM--Database drive: %S\r\n"), &aCmdLineParams.iDriveName); + if(aCmdLineParams.iLogFileName.Length() > 0) + { + aTest.Printf(_L("--PRM--Log file name: %S\r\n"), &aCmdLineParams.iLogFileName); + } + else + { + aTest.Printf(_L("--PRM--Test output: to screen only\r\n")); + } + } + +void PrepareDbName(const TDesC& aDeafultDbName, const TDriveName& aDriveName, TDes& aDbName) + { + TParse parse; + parse.Set(aDriveName, &aDeafultDbName, 0); + const TDesC& dbFilePath = parse.FullName(); + aDbName.Copy(dbFilePath); + } + +void LogConfig(RFile& aLogFile, const TCmdLineParams& aCmdLineParams) + { + TBuf8<100> buf; + buf.Format(_L8("Database drive:%S\r\n"), &aCmdLineParams.iDriveName); + (void)aLogFile.Write(buf); + buf.Format(_L8("\r\n\r\n")); + (void)aLogFile.Write(buf); + }