当前位置: 首页>>代码示例>>C++>>正文


C++ CCommandLineArguments::Count方法代码示例

本文整理汇总了C++中CCommandLineArguments::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ CCommandLineArguments::Count方法的具体用法?C++ CCommandLineArguments::Count怎么用?C++ CCommandLineArguments::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCommandLineArguments的用法示例。


在下文中一共展示了CCommandLineArguments::Count方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MainL

static void MainL(void)
/**
Takes a User Prompt Service policy resource file and dumps it as human readable text to the 
console. The user may also specify the name of an output file on the command line. If so, text
is also written to this file.
*/
	{
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
		
	CConsoleBase* console = Console::NewL(KAppName, TSize(KDefaultConsWidth, KDefaultConsHeight));
	CleanupStack::PushL(console);
	
	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	
	if (args->Count() > 1)
		{		
		CPolicyReader* reader = CPolicyReader::NewLC(fs, args->Arg(1));		
		CPrinter* printer(0);
		if (args->Count() > 2)
			{
			RFile outFile;
			User::LeaveIfError(outFile.Replace(fs, args->Arg(2), EFileShareExclusive | EFileWrite));
			CleanupClosePushL(outFile);
			printer = CPrinter::NewLC(console, outFile);		
			
			CleanupStack::Pop(printer); 
			CleanupStack::PopAndDestroy(&outFile);
			CleanupStack::PushL(printer);
			}
		else
			{
			printer = CPrinter::NewLC(console);	
			}
		__UHEAP_MARK;
		PrintPoliciesL(printer, reader);
		__UHEAP_MARKEND;
		
		if (args->Count() < 3)
			{
			// If no output file is specified then pause after finishing
			// because the console will vanish when it is closed.
			console->Printf(_L("Press any key to continue\r\n"));
			console->Getch();
			}		
		CleanupStack::PopAndDestroy(2, reader); // printer, reader		
		}
	else 
		{
		console->Printf(_L("Usage: dumppolicy.exe policy.rsc <output.txt>\r\n"));
		console->Printf(_L("Press any key to continue\r\n"));
		console->Getch();
		}
	
	CleanupStack::PopAndDestroy(3, &fs); // args, console, fs
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:57,代码来源:dumppolicy.cpp

示例2: DoStartL

LOCAL_C void DoStartL()
	{
	// Create active scheduler (to run active objects)
	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
	CleanupStack::PushL(scheduler);
	CActiveScheduler::Install(scheduler);

	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
	CFed* fed = CFed::NewL(*console, fs);
	CleanupStack::PushL(fed);
	CDesC16ArrayFlat* argsBuf = new(ELeave) CDesC16ArrayFlat(4);
	CleanupStack::PushL(argsBuf);
	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	for (TInt i = 1; i < args->Count(); i++) // Start from 1 as arg zero is the exe name
		{
		// No attempt to be clever with arguments - this code is only used when building a raw non-fshell version - mainfshell has the nicer equivalent
		TPtrC arg = args->Arg(i);
		argsBuf->AppendL(arg);
		}
	CleanupStack::PopAndDestroy(args);
	CleanupStack::Pop(argsBuf);
	gFed = fed;
	fed->StartL(argsBuf);
	CActiveScheduler::Start();

	// Delete active scheduler
	CleanupStack::PopAndDestroy(3, scheduler); // fed, fs, scheduler
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:30,代码来源:main.cpp

示例3: DoStartL

LOCAL_C void DoStartL() 
	{
	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	TInt i = args->Count();

	if ( args->Count() == 2 )
		{
		TLex tlex(args->Arg(1));
		TInt argVal = 0;
		if ( tlex.Val(argVal) == KErrNone )
			{
			// 
			if(argVal == 1)
				{
				RFeatureControl control;
				TInt err = control.Connect();

				TBitFlags32 flags( 0 );
				flags.Set( EFeatureSupported);
				flags.Set( EFeatureModifiable );

				// Adding features
				TFeatureEntry entry1( KNewUid1, flags, KDefaultData1 );
				err = control.AddFeature(entry1);

				control.Close();
				}
			else if( argVal == 2)
				{
				RFeatureControl control;
				TInt err = control.Connect();

				err = control.SWIEnd();

				control.Close();
				}
			}
		}
	CleanupStack::PopAndDestroy(); //args
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:40,代码来源:helping_exe.cpp

示例4: mainL

LOCAL_C void mainL()
	{
	CCommandLineArguments* cmdLine = CCommandLineArguments::NewLC();
	CConsoleBase* console = Console::NewL(_L("Siftestintegrationlockfile"),TSize(KConsFullScreen,KConsFullScreen));
	CleanupStack::PushL(console);
	TInt argTotal(cmdLine->Count());
	if (argTotal < 2  || argTotal > 3)
		{
		console->Printf(_L("Incorrect arguments specified: expected 1, received %d"), argTotal - 1);
		User::Leave(KErrArgument);
		}
		
	TPtrC filename(cmdLine->Arg(1));
	_LIT(KDoLockFileParam, " lockfile");
	if (argTotal == 2)
		{
		RBuf params;
		params.CreateL(filename.Length() + KDoLockFileParam().Length());
		params.CleanupClosePushL();
		params.Append(cmdLine->Arg(1));
		params.Append(KDoLockFileParam());
		// Since this executable is used by TEF, we wish to lock the file after the launched process has exited, so we spawn this process again with a different set of parameters
		RProcess newInstance;
		User::LeaveIfError(newInstance.Create(_L("Siftestintegrationlockfile"), params));
		CleanupClosePushL(newInstance);
		newInstance.Resume();
		TRequestStatus status;		
		newInstance.Rendezvous(status);
		User::WaitForRequest(status);
		User::LeaveIfError(status.Int());
		CleanupStack::PopAndDestroy(2, &params); // newInstance
		}
	else
		{
		// This is the execution for locking the file, invoked using the branch above
		console->Printf(_L("Locking file %S for read"), &filename);	
		RFs fs;
		User::LeaveIfError(fs.Connect());
		CleanupClosePushL(fs);
	
		RFile file;
		User::LeaveIfError(file.Open(fs, filename, EFileShareReadersOnly|EFileRead));
		CleanupClosePushL(file);
		// Signal the invoker only here, so that the file will definitely get locked before TEF proceeds to the next step
		RProcess::Rendezvous(KErrNone);		
		
		User::After(10*1000*1000); // Wait for 10 seconds
	
		CleanupStack::PopAndDestroy(2 , &fs); // file
		}
	CleanupStack::PopAndDestroy(2, cmdLine); // console,
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:52,代码来源:siftestintegrationlockfile.cpp

示例5: BaseConstructL

// -----------------------------------------------------------------------------
// Cosmo4AppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void COsmo4AppUi::ConstructL()
{
    // Initialise app UI with standard value.
    BaseConstructL(CAknAppUi::EAknEnableSkin);

    /*Create display*/
    iAppView = COsmo4AppView::NewL( ClientRect() );
	AddToStackL(iAppView);

	/*create playlist*/
#ifndef GPAC_GUI_ONLY
	iPlaylist = CPlaylist::NewL( ClientRect(), iAppView->GetUser() );

	iPlaylist->MakeVisible(EFalse);
#endif
	
	iAppView->MakeVisible(ETrue);
	view_mode = 0;

	m_title = NULL;

	//StatusPane ()->SwitchLayoutL ( R_AVKON_STATUS_PANE_LAYOUT_SMALL );

	nb_keys = 0;
	CaptureKeys(1);



	CCommandLineArguments *args = CCommandLineArguments::NewL();
#ifndef GPAC_GUI_ONLY
	if (args->Count() > 1) {
		TPtrC url = args->Arg(1);
#if defined(_UNICODE)
		char szURL[1024];
		u16 szURLUTF16[1024];
		size_t len;
		len = url.Size();
		memcpy(szURLUTF16, url.Ptr(), sizeof(u8)*len);
		szURLUTF16[len/2] = 0;
		const u16 *sptr = szURLUTF16;
		len = gf_utf8_wcstombs(szURL, 512, &sptr);
		if (len != (size_t) -1) {
			szURL[len] = 0;
			iAppView->Connect((const char *)szURL);
		}
#else
		iAppView->Connect((const char *)url.Ptr());
#endif
	}
#endif
	delete args;
}
开发者ID:bigbensk,项目名称:gpac,代码行数:57,代码来源:osmo4_ui.cpp

示例6: ConstructL

void CAppView::ConstructL()
{
	DebugMarkStart();
	LOGD("HELLOTE\n");

#if 0
	CCommandLineArguments* cla = CCommandLineArguments::NewLC();
	LOGD("CLA count: %i\n", cla->Count());
	for(int i=0; i<cla->Count(); i++) {
		HBufC8* buf = CreateHBufC8FromDesC16LC(cla->Arg(i));
		LOGD("%i \"%S\"\n", i, buf);
		CleanupStack::PopAndDestroy(buf);
	}
	CleanupStack::PopAndDestroy(cla);
#endif	//0

	CreateWindowL();  // Create a window for this application view
	// Set the window size
	SetRect(CCoeEnv::Static()->ScreenDevice()->SizeInPixels());
	iEngine = CDirScrAccEng::NewL(iEikonEnv->WsSession(),
		*(CCoeEnv::Static()->ScreenDevice()), Window());
	LOGD("AVC1\n");

	EnableDragEvents();

	iEventBuffer.SetLengthL(EVENT_BUFFER_SIZE);

	ActivateL();  // Activate the window, which makes it ready to be drawn
	LOGD("AVC3\n");

	iWaitTimer = new (ELeave) CWaitTimer(*this);
	iWaitTimer->ConstructL();

	iDelayTimer = new (ELeave) CDelayTimer(*this);
	iDelayTimer->ConstructL();

	iIdle = CIdle::NewL(MyPrioIdle);
	iIdle->Start(TCallBack(StartStuff, this));
}
开发者ID:GregorGullwi,项目名称:MoSync,代码行数:39,代码来源:AppView.cpp

示例7: InternalizeL

void CCellTowerDataSimulation::InternalizeL() {
	RFs aSession;
	RFile aFile;
	TFileName aFileName;
	TInt aFileSize;

	if(aSession.Connect() == KErrNone) {
		CleanupClosePushL(aSession);

#ifndef __SERIES60_3X__
		aFileName = TFileName(_L("CellTowerSimData.txt"));
		CompleteWithAppPath(aFileName);
#else
		if(aSession.PrivatePath(aFileName) == KErrNone) {
#ifndef __WINSCW__
			aFileName.Insert(0, _L(":"));
			CCommandLineArguments* pArguments;
			TFileName drive;
			pArguments = CCommandLineArguments::NewL();
			if (pArguments->Count() > 0) {
				drive.Append(pArguments->Arg(0)[0]);
				aFileName.Insert(0, drive);
				delete pArguments;
			}
#endif

			aFileName.Append(_L("CellTowerSimData.txt"));

#ifdef __WINSCW__
			aFileName.Insert(0, _L("z:"));
#endif
		}
#endif

		if(aFile.Open(aSession, aFileName, EFileStreamText|EFileRead) == KErrNone) {
			CleanupClosePushL(aFile);
			aFile.Size(aFileSize);

			// Creat buffer & read file
			iCellBuffer = HBufC8::NewL(aFileSize);
			TPtr8 pCellBuffer(iCellBuffer->Des());
			aFile.Read(pCellBuffer);
			aFile.Close();
			
			CleanupStack::PopAndDestroy(&aFile);
		}
		
		CleanupStack::PopAndDestroy(&aSession);
	}
}
开发者ID:Persepoliss,项目名称:symbian-client,代码行数:50,代码来源:CellTowerDataSimulation.cpp

示例8: HandleCommandL

//             Called by the UI framework when a command has been issued.
//             In this example, a command can originate through a 
//             hot-key press or by selection of a menu item.
//             The command Ids are defined in the .hrh file
//             and are 'connected' to the hot-key and menu item in the
//             resource file.
//             Note that the EEikCmdExit is defined by the UI
//             framework and is pulled in by including eikon.hrh
//
void CExampleAppUi::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		      // Just issue simple info messages to show that
		      // the menu items have been selected
	case EExampleItem0:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM0);
		break;

	
	case EExampleItem1:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM1);
		break;
	
	case EExampleItem2:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM2);
		break;
               // Exit the application. The call is
		       // implemented by the UI framework.

	case EEikCmdExit: 
		TInt timerDuration(KDefaultTimeout);
	    CCommandLineArguments* cmdLine = CCommandLineArguments::NewL();
		TInt argTotal=cmdLine->Count();
		for (TInt loop=1 ; loop < argTotal ; ++loop)
			{
			TPtrC arg(cmdLine->Arg(loop));
			if (arg==KSetShutDownTimeOption && loop++ < (argTotal-1))
				{
				TLex timeoutLex(cmdLine->Arg(loop));
				timeoutLex.Val(timerDuration);
				}
			}
		delete cmdLine;
		if(timerDuration > 0)
			{
			RTimer timer;
			TRequestStatus timerStatus;
			timer.CreateLocal();
			timer.After(timerStatus, timerDuration);
			User::WaitForRequest(timerStatus);
			timer.Close();
			}
		Exit();
		break;
		}
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:57,代码来源:HelloWorld_AppUi.cpp

示例9: StartTestL

void CSdlAppUi::StartTestL(TInt aCmd)
{

	//TInt flags = CSDL::EDrawModeGdi | CSDL::EEnableFocusStop
	//		| CSDL::EMainThread;// | CSDL::EAutoOrientation;

	TInt flags = 0;

	//flags |= CSDL::EDrawModeDSB | CSDL::EDrawModeDSBDoubleBuffer;
	flags |= CSDL::EDrawModeGdi;
	// Don't draw when in background.
	//flags |= CSDL::EEnableFocusStop;
	flags |= CSDL::EAutoOrientation;
	// This should be on by default anyway
	flags |= CSDL::EMainThread;

	//Create CommandLine Arguments and read it.
	CDesC8ArrayFlat *arr = new (ELeave) CDesC8ArrayFlat(1);
	CleanupStack::PushL(arr);

	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	// The real args we are interested in start at the 2nd arg
	for (TInt i = 1; i < args->Count(); i++)
	{
		TBuf8<256> arg;
		arg.Copy(args->Arg(i));

		arr->AppendL(arg);
		//TPtrC argumentPrt(args->Arg(i));
		//console->Printf(_L("Arg %d == %S\n"), i, &argumentPrt);
	}

	iSdl = CSDL::NewL(flags);

	iSdl->SetContainerWindowL(iSDLWin->GetWindow(), iEikonEnv->WsSession(),
			*iEikonEnv->ScreenDevice());
	iSdl->CallMainL(iWait->iStatus, *arr, flags, 0x14000);
	iWait->Start();

	arr->Reset();
	CleanupStack::PopAndDestroy(2); // command line and arr
}
开发者ID:Anugrahaa,项目名称:anagrammatic,代码行数:42,代码来源:pygame_app.cpp

示例10: StartPSYCRTesterL

void StartPSYCRTesterL() 
	{

	// Read the Process Arguments
	TInt psyIDValue;

    // PSY Tester sends the UID of the PSY as an argument
	CCommandLineArguments *args = CCommandLineArguments::NewL();
	CleanupStack::PushL(args);
	if(args->Count() <= 1)
	{
			User::Leave(KErrArgument);
	}
	TPtrC ptr = args->Arg(1);
	
	TLex lex(ptr.Ptr());
	TInt err = lex.Val(psyIDValue);

	if(KErrNone == err)
	{
		
		CPosPSYCRTestHandler* psyCRTestHandler = CPosPSYCRTestHandler::NewL();
		CleanupStack::PushL(psyCRTestHandler);

		TUid psyID;
		psyID.iUid = psyIDValue;
	
	    // Start the test	
		psyCRTestHandler->StartPSYCRTesterL(psyID);
		
		CleanupStack::PopAndDestroy(psyCRTestHandler);
	}
	
	CleanupStack::PopAndDestroy(args);
		
	RProcess::Rendezvous(KErrNone);

	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:38,代码来源:epos_psycrtester_main.cpp

示例11: MainL

/**
* Main function. Process command line arguments and import bookmark data.
*/
LOCAL_D void MainL()
    {
    TBuf<KFormatBufLen> buf;
    TInt num;
    CCommandLineArguments* args = CCommandLineArguments::NewLC();
    if( args->Count() != 2 )
        {
        // Expecting command line 'Appname outfile'.
        User::Leave( KErrArgument );
        }
    RFs fs;
    User::LeaveIfError( fs.Connect() );
    CleanupClosePushL<RFs>( fs );
    RUnicodeFile file;
    User::LeaveIfError( file.ReplaceL
        ( fs, args->Arg( 1 ), EFileWrite | EFileShareExclusive ) );
    CleanupClosePushL<RUnicodeFile>( file );
    RFavouritesSession sess;
    User::LeaveIfError( sess.Connect() );
    CleanupClosePushL<RFavouritesSession>( sess );
    RFavouritesDb db;
    User::LeaveIfError( db.Open( sess, KBrowserBookmarks ) );
    CleanupClosePushL<RFavouritesDb>( db );
    User::LeaveIfError( db.Begin( /*aWrite=*/EFalse ) );
    db.CleanupRollbackPushL();

    CFavouritesItemList* items = new (ELeave) CFavouritesItemList();
    CleanupStack::PushL( items );
    const CFavouritesItem* item;
    User::LeaveIfError( db.GetAll( *items ) );
    buf.Format( _L("%d entries\r\n"), items->Count() );
    User::LeaveIfError( file.Write( buf ) );
    for ( TInt i = 0; i < items->Count(); i++ )
        {
        User::LeaveIfError( file.Write( _L("\r\n") ) );
        item = items->At( i );
        // Uid.
        num = item->Uid();
        buf.Format( _L("Uid=(%d)"), num );
        User::LeaveIfError( file.Write( buf ) );
        // Fixed Uid info.
        if ( num == KFavouritesRootUid )
            {
            User::LeaveIfError( file.Write( _L(" (root folder)\r\n") ) );
            }
        else if ( num == KFavouritesHomepageUid )
            {
            User::LeaveIfError( file.Write( _L(" (homepage)\r\n") ) );
            }
        else if ( num == KFavouritesLastVisitedUid )
            {
            User::LeaveIfError( file.Write( _L(" (last visited)\r\n") ) );
            }
        else
            {
            User::LeaveIfError( file.Write( _L("\r\n") ) );
            }
        // Type.
        if ( item->Type() == CFavouritesItem::EFolder )
            {
            User::LeaveIfError( file.Write( _L("Type=Folder\r\n") ) );
            }
        else if ( item->Type() == CFavouritesItem::EItem )
            {
            User::LeaveIfError( file.Write( _L("Type=Item\r\n") ) );
            }
        else
            {
            User::LeaveIfError( file.Write( _L("Type=HUH???\r\n") ) );
            }
        TPtrC ptr;
        // Name
        ptr.Set( item->Name() );
        buf.Format( _L("Name=<%S>\r\n"), &ptr );
        User::LeaveIfError( file.Write( buf ) );
        // Parent.
        buf.Format( _L("ParentFolder=(%d)\r\n"), item->ParentFolder() );
        User::LeaveIfError( file.Write( buf ) );
        // Url.
        ptr.Set( item->Url() );
        buf.Format( _L("Url=<%S>\r\n"), &ptr );
        User::LeaveIfError( file.Write( buf ) );
        // Access Point.
        if ( item->WapAp().IsNull() )
            {
            User::LeaveIfError( file.Write( _L("WapAp=Null\r\n") ) );
            }
        else if ( item->WapAp().IsDefault() )
            {
            User::LeaveIfError( file.Write( _L("WapAp=Default\r\n") ) );
            }
        else
            {
            buf.Format( _L("WapAp=(%d)\r\n"), item->WapAp().ApId() );
            User::LeaveIfError( file.Write( buf ) );
            }
        // UserName.
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:101,代码来源:BookmarkDumpMain.cpp

示例12: mainL

LOCAL_C void mainL()
	{
	CCommandLineArguments* cmdLine = CCommandLineArguments::NewLC();
	TInt argTotal=cmdLine->Count();
	if (argTotal < 2 || argTotal > 3)
		{
		User::Leave(KErrArgument);
		}
	TUint sidRequested;
	TLex processLex(cmdLine->Arg(1));
	User::LeaveIfError(processLex.Val(sidRequested, EHex));
	if (sidRequested == 0)
		{
		User::Leave(KErrArgument);
		}
	
	if (argTotal == 3)
		{
		TUint timeout;
		TLex timeoutLex(cmdLine->Arg(2));
		User::LeaveIfError(timeoutLex.Val(timeout));
		if (timeout > 0)
			{
			User::After(timeout);
			}
		}

	TUid sid = {sidRequested};
	TBool needToScanFullList;
	TFullName fullName;

	do
		{
		needToScanFullList = EFalse;
		TFindProcess findProcess;

		while(findProcess.Next(fullName) == KErrNone)
			{
			RProcess process;
			TInt ret=KErrNone;
			TInt count=0;
			do
			{
			count++;
 			ret=process.Open(findProcess);
			if (ret!=KErrNone)
				{
				User::After(200000);
				}
			}while (ret!=KErrNone && count<=10);
			if (ret!=KErrNone)
				{
				User::Leave(ret);
				}

			TUid processSid(process.SecureId());
			if (processSid == sid && process.ExitType() == EExitPending)
				{
				process.Kill(KErrNone);
				needToScanFullList = ETrue;
				}
			process.Close();
			}
		} while (needToScanFullList);

	CleanupStack::PopAndDestroy(cmdLine);
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:67,代码来源:killrunningprocess.cpp


注:本文中的CCommandLineArguments::Count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。