本文整理汇总了C++中NextArg函数的典型用法代码示例。如果您正苦于以下问题:C++ NextArg函数的具体用法?C++ NextArg怎么用?C++ NextArg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NextArg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Initialise
/* Initialise: initialise global data structures */
void Initialise(void)
{
float weight;
char *fn;
CreateWordMap(mapFN,&wmap,1);
SortWordMap(&wmap);
weight = 1.0;
CreateInputSet(&gstack,&wmap,&inSet);
while (NextArg() == STRINGARG || NextArg() == FLOATARG) {
if (NextArg() == FLOATARG)
weight = GetFltArg();
if (weight==0.0 || weight<-10000.0 || weight>10000.0)
HError(-16719,"Unlikely ngram weight[%.4f]",weight);
if (NextArg()!=STRINGARG)
HError(16719,"Gram base file name expected");
fn = GetStrArg();
AddInputGFile(&inSet,fn,weight);
if (trace&T_TOP)
printf("Input file %s added, weight=%.4f\n",fn,weight);
}
if (nSize==0)
nSize = inSet.N;
}
示例2: main
int main(int argc, char *argv[])
{
char *s;
void Initialise(void);
InitShell(argc,argv,lfof_version,lfof_vc_id);
InitMem();
InitMath();
InitWave();
InitLabel();
InitWMap();
InitGBase();
InitPCalc();
if (!InfoPrinted() && NumArgs() == 0)
ReportUsage();
if (NumArgs() == 0) Exit(EXIT_SUCCESS);
SetConfParms();
while (NextArg() == SWITCHARG) {
s = GetSwtArg();
if (strlen(s)!=1)
HError(16719,"Bad switch %s; must be single letter",s);
switch(s[0]){
case 'f':
fofSize = GetChkedInt(1, 1000, s); break;
case 'n':
nSize = GetChkedInt(1, MAXNG, s); break;
case 'T':
trace = GetChkedInt(0,077,s); break;
default:
HError(16719,"LFoF: Unknown switch %s",s);
}
}
if (NextArg() != STRINGARG)
HError(16719,"LFoF: map file name expected");
mapFN = GetStrArg();
if (NextArg() != STRINGARG)
HError(16719,"LFoF: FoF file name expected");
fofFN = GetStrArg();
Initialise();
if (trace&T_TOP) {
printf("Calculating FoF table\n"); fflush(stdout);
}
fofTab = CreateFoFTab(&gstack,fofSize,nSize);
ComputeFoFTab(fofTab,nSize,&inSet);
WriteFoFTab(fofFN,fofTab,NULL);
Exit(EXIT_SUCCESS);
return EXIT_SUCCESS; /* never reached -- make compiler happy */
}
示例3: fontpane_popup
void
fontpane_popup(int *psfont_adr, int *latexfont_adr, int *psflag_adr, void (*showfont_fn) (/* ??? */), Widget show_widget)
{
DeclareArgs(2);
Position xposn, yposn;
Widget widg;
font_ps_sel = psfont_adr;
font_latex_sel = latexfont_adr;
flag_sel = psflag_adr;
font_setimage = showfont_fn;
font_widget = show_widget;
if (first_fontmenu) {
first_fontmenu = False; /* don't reposition it if user has already popped it */
XtTranslateCoords(tool, CANVAS_WD/4, CANVAS_HT/4, &xposn, &yposn);
FirstArg(XtNx, xposn); /* position about 1/4 from upper-left corner of canvas */
NextArg(XtNy, yposn);
SetValues(ps_fontmenu);
SetValues(latex_fontmenu);
}
widg = *flag_sel ? ps_fontmenu : latex_fontmenu;
XtPopup(widg, XtGrabExclusive);
/* if the file message window is up add it to the grab */
file_msg_add_grab();
/* insure that the most recent colormap is installed */
set_cmap(XtWindow(widg));
XSetWMProtocols(tool_d, XtWindow(widg), &wm_delete_window, 1);
}
示例4: main
int main(int argc, char *argv[])
{
char *s;
Initialise(argc,argv);
CreateHeap(&modelHeap, "Model heap", MSTAK, 1, 0.0, 100000, 800000 );
CreateHMMSet(&hset,&modelHeap,TRUE);
while (NextArg() == SWITCHARG) {
s = GetSwtArg();
if (strlen(s)!=1)
HError(3219,"HNetTest: Bad switch %s; must be single letter",s);
switch(s[0]){
case 'H':
if (NextArg() != STRINGARG)
HError(3219,"HNetTest: MMF File name expected");
AddMMF(&hset,GetStrArg());
break;
default:
HError(3219,"HNetTest: Unknown switch %s",s);
}
}
if (NextArg()!=STRINGARG)
HError(999,"HNetTest: Dictionary file name expected");
dictFn = GetStrArg();
if (NextArg()!=STRINGARG)
HError(999,"HNetTest: Word Net file name expected");
wdNetFn = GetStrArg();
if (NextArg()!=STRINGARG)
HError(999,"HNetTest: HMM list file name expected");
hmmListFn = GetStrArg();
if(MakeHMMSet(&hset,hmmListFn)<SUCCESS)
HError(999,"HNetTest: MakeHMMSet failed");
if(LoadHMMSet(&hset,NULL,NULL)<SUCCESS)
HError(999,"HNetTest: LoadHMMSet failed");
InitVocab(&vocab);
if(ReadDict(dictFn,&vocab)<SUCCESS)
HError(3213, "HNetTest: ReadDict failed");
LoadNetwork();
}
示例5: spell_select_word
static void
spell_select_word(Widget widget, XtPointer closure, XtPointer call_data)
{
XawListReturnStruct *ret_struct = (XawListReturnStruct *) call_data;
/* make correct button and correction entry sensitive */
XtSetSensitive(correct_button, True);
XtSetSensitive(correct_word, True);
/* save the selected word */
strcpy(selected_word, ret_struct->string);
/* copy the word to the correct_word ascii widget */
FirstArg(XtNstring, ret_struct->string);
NextArg(XtNeditType, XawtextEdit); /* make editable now */
NextArg(XtNsensitive, True); /* and sensitive */
SetValues(correct_word);
}
示例6: SafeFree
bool CConEmuStart::GetCfgParm(LPCWSTR& cmdLineRest, CESwitch& Val, int nMaxLen, bool bExpandAndDup /*= false*/)
{
if (Val.Type == sw_Str || Val.Type == sw_EnvStr || Val.Type == sw_PathStr)
{
SafeFree(Val.Str);
}
else
{
Val.Type = bExpandAndDup ? sw_EnvStr : sw_Str;
}
Val.Exists = false;
if (!cmdLineRest || !*cmdLineRest)
{
_ASSERTE(cmdLineRest && *cmdLineRest);
return false;
}
// Сохраним, может для сообщения об ошибке понадобится
LPCWSTR pszName = cmdLineRest;
CmdArg szGetCfgParmTemp;
if (!(cmdLineRest = NextArg(cmdLineRest, szGetCfgParmTemp)))
{
return false;
}
LPCWSTR curCommand = szGetCfgParmTemp.ms_Val;
int nLen = _tcslen(curCommand);
if (nLen >= nMaxLen)
{
int nCchSize = nLen+100+_tcslen(pszName);
wchar_t* psz = (wchar_t*)calloc(nCchSize,sizeof(wchar_t));
if (psz)
{
swprintf_c(psz, nCchSize/*#SECURELEN*/, L"Too long %s value (%i chars).\r\n", pszName, nLen);
_wcscat_c(psz, nCchSize, curCommand);
MBoxA(psz);
free(psz);
}
return false;
}
// We need independent absolute file paths, Working dir changes during ConEmu session
if (bExpandAndDup)
Val.Str = GetFullPathNameEx(curCommand); // it allocates memory
else
Val.SetStr(curCommand, Val.Type);
// Ok
Val.Exists = (Val.Str && *Val.Str);
return true;
}
示例7: GetNextSwitch
Switch* GetNextSwitch(LPCWSTR& rpsz, CEStr& szArg)
{
LPCWSTR psz = rpsz;
CEStr szNext;
if ((0 == NextArg(&psz, szNext)) && !szNext.IsPossibleSwitch())
rpsz = psz;
else
szNext.Clear();
Switch* ps = new Switch(szArg.Detach(), szNext.Detach());
return ps;
};
示例8: background_select
static void
background_select(Widget w, XtPointer closure, XtPointer call_data)
{
Pixel bgcolor, fgcolor;
/* get the colors from the color button just pressed */
FirstArg(XtNbackground, &bgcolor);
NextArg(XtNforeground, &fgcolor);
GetValues(w);
/* get the colorname from the color button and put it and the colors
in the menu button */
FirstArg(XtNlabel, XtName(w));
NextArg(XtNbackground, bgcolor);
NextArg(XtNforeground, fgcolor);
SetValues(print_background_panel);
/* update the export panel too if it exists */
if (export_background_panel)
SetValues(export_background_panel);
export_background_color = (int)closure;
XtPopdown(background_menu);
}
示例9: CreateDataFileList
/* CreateDataFileList: */
static void CreateDataFileList()
{
char *datafn;
g_nDataFileNum = 0;
do {
if (NextArg() != STRINGARG)
HError(2319, "HMGenS: data file name expected");
datafn = GetStrArg();
g_pDataFileList[g_nDataFileNum] = (TDataFile *) New(&gstack, sizeof(TDataFile));
strcpy(g_pDataFileList[g_nDataFileNum]->datafn, datafn);
g_pDataFileList[g_nDataFileNum]->bValid = TRUE;
g_nDataFileNum++;
} while (NumArgs() > 0);
}
示例10: main
int main(int argc, char *argv[])
{
int n,a1,a2,a3,a4;
InitThreads(sMon);
if(InitShell(argc,argv,hthreadtest_version)<SUCCESS)
HError(1100,"HThreadTest: InitShell failed");
if (NumArgs() < 1) ReportUsage();
InitMem(); InitLabel();
InitMath(); InitSigP();
InitWave(); InitAudio();
InitVQ();
if(InitParm()<SUCCESS)
HError(3200,"HThreadTest: InitParm failed");
InitGraf(FALSE);
if (sMon==HT_MSGMON) HCreateMonitor(tmon4,(void *)0);
if (NextArg() == INTARG){
n = GetIntArg();
switch(n){
case 1:
a1 = GetIntArg(); a2 = GetIntArg();
ParallelForkAndJoin(a1,a2); break;
case 2:
a1 = GetIntArg(); a2 = GetIntArg();
SimpleMutex(a1,a2); break;
case 3:
SimpleSignal(); break;
case 4:
a1 = GetIntArg(); a2 = GetIntArg();
a3 = GetIntArg(); a4 = GetIntArg();
BufferTest(a1,a2,a3,a4,GetStrArg()); break;
default:
printf("Bad test number %d\n",n); ReportUsage();
}
}
if (sMon>0){
AccessStatus();
PrintThreadStatus("Final");
ReleaseStatusAccess();
if (sMon==HT_MSGMON)HJoinMonitor();
}
}
示例11: GetNextPair
Switch* GetNextPair(LPCWSTR& rpsz)
{
LPCWSTR psz = rpsz;
CEStr szArg;
if (0 != NextArg(&psz, szArg))
{
return NULL;
}
// Invalid switch? or first argument (our executable)
if (!szArg.IsPossibleSwitch())
{
rpsz = psz;
return NULL;
}
rpsz = psz;
return GetNextSwitch(rpsz, szArg);
};
示例12:
bool CConEmuUpdate::Check7zipInstalled()
{
if (mp_Set->UpdateDownloadSetup() == 1)
return true; // Инсталлер, архиватор не требуется!
LPCWSTR pszCmd = mp_Set->UpdateArcCmdLine();
CmdArg sz7zip; sz7zip.GetBuffer(MAX_PATH);
if (NextArg(&pszCmd, sz7zip) != 0)
{
ReportError(L"Invalid update command\nGoto 'Update' page and check 7-zip command", 0);
return false;
}
if (FileExistsSearch(sz7zip.GetBuffer(MAX_PATH), MAX_PATH))
return true;
WARNING("TODO: Suggest to download 7zip");
ReportError(L"7zip or WinRar not found! Not installed?\n%s\nGoto 'Update' page and check 7-zip command", sz7zip, 0);
return false;
}
示例13: IsNeedCmd
bool IsNeedCmd(BOOL bRootCmd, LPCWSTR asCmdLine, CEStr &szExe,
LPCWSTR* rsArguments /*= NULL*/, BOOL* rpbNeedCutStartEndQuot /*= NULL*/,
BOOL* rpbRootIsCmdExe /*= NULL*/, BOOL* rpbAlwaysConfirmExit /*= NULL*/, BOOL* rpbAutoDisableConfirmExit /*= NULL*/)
{
bool rbNeedCutStartEndQuot = false;
bool rbRootIsCmdExe = true;
bool rbAlwaysConfirmExit = false;
bool rbAutoDisableConfirmExit = false;
wchar_t *pwszEndSpace;
if (rsArguments) *rsArguments = NULL;
bool lbRc = false;
int iRc = 0;
BOOL lbFirstWasGot = FALSE;
LPCWSTR pwszCopy;
int nLastChar;
#ifdef _DEBUG
CEStr szDbgFirst;
#endif
if (!asCmdLine || !*asCmdLine)
{
_ASSERTE(asCmdLine && *asCmdLine);
goto wrap;
}
#ifdef _DEBUG
// Это минимальные проверки, собственно к коду - не относятся
bool bIsBatch = false;
{
LPCWSTR psz = asCmdLine;
NextArg(&psz, szDbgFirst);
psz = PointToExt(szDbgFirst);
if (lstrcmpi(psz, L".cmd")==0 || lstrcmpi(psz, L".bat")==0)
bIsBatch = true;
}
#endif
if (!szExe.GetBuffer(MAX_PATH))
{
_ASSERTE(FALSE && "Failed to allocate MAX_PATH");
lbRc = true;
goto wrap;
}
szExe.Empty();
if (!asCmdLine || *asCmdLine == 0)
{
_ASSERTE(asCmdLine && *asCmdLine);
lbRc = true;
goto wrap;
}
pwszCopy = asCmdLine;
// cmd /c ""c:\program files\arc\7z.exe" -?" // да еще и внутри могут быть двойными...
// cmd /c "dir c:\"
nLastChar = lstrlenW(pwszCopy) - 1;
if (pwszCopy[0] == L'"' && pwszCopy[nLastChar] == L'"')
{
//if (pwszCopy[1] == L'"' && pwszCopy[2])
//{
// pwszCopy ++; // Отбросить первую кавычку в командах типа: ""c:\program files\arc\7z.exe" -?"
// if (rbNeedCutStartEndQuot) *rbNeedCutStartEndQuot = TRUE;
//}
//else
// глючила на ""F:\VCProject\FarPlugin\#FAR180\far.exe -new_console""
//if (wcschr(pwszCopy+1, L'"') == (pwszCopy+nLastChar)) {
// LPCWSTR pwszTemp = pwszCopy;
// // Получим первую команду (исполняемый файл?)
// if ((iRc = NextArg(&pwszTemp, szArg)) != 0) {
// //Parsing command line failed
// lbRc = true; goto wrap;
// }
// pwszCopy ++; // Отбросить первую кавычку в командах типа: "c:\arc\7z.exe -?"
// lbFirstWasGot = TRUE;
// if (rbNeedCutStartEndQuot) *rbNeedCutStartEndQuot = TRUE;
//} else
{
// Will be dequoted in 'NextArg' function. Examples
// "C:\GCC\msys\bin\make.EXE -f "makefile" COMMON="../../../plugins/common""
// ""F:\VCProject\FarPlugin\#FAR180\far.exe -new_console""
// ""cmd""
// cmd /c ""c:\program files\arc\7z.exe" -?" // да еще и внутри могут быть двойными...
// cmd /c "dir c:\"
LPCWSTR pwszTemp = pwszCopy;
// Получим первую команду (исполняемый файл?)
if ((iRc = NextArg(&pwszTemp, szExe)) != 0)
{
//Parsing command line failed
#ifdef WARN_NEED_CMD
_ASSERTE(FALSE);
#endif
lbRc = true; goto wrap;
//.........这里部分代码省略.........
示例14: QueryNextArg
// Returns PTR to next arg or NULL on error
LPCWSTR QueryNextArg(const wchar_t* asCmdLine, CEStr &rsArg, const wchar_t** rsArgStart/*=NULL*/)
{
if (0 != NextArg(&asCmdLine, rsArg, rsArgStart))
return NULL;
return asCmdLine;
}
示例15: OurShellExecCmdLine
// Called from OnShellExecCmdLine
HRESULT OurShellExecCmdLine(HWND hwnd, LPCWSTR pwszCommand, LPCWSTR pwszStartDir, bool bRunAsAdmin, bool bForce)
{
HRESULT hr = E_UNEXPECTED;
BOOL bShell = FALSE;
CEStr lsLog = lstrmerge(L"OnShellExecCmdLine", bRunAsAdmin ? L"(RunAs): " : L": ", pwszCommand);
DefTermLogString(lsLog);
// Bad thing, ShellExecuteEx needs File&Parm, but we get both in pwszCommand
CmdArg szExe;
LPCWSTR pszFile = pwszCommand;
LPCWSTR pszParm = pwszCommand;
if (NextArg(&pszParm, szExe) == 0)
{
pszFile = szExe; pszParm = SkipNonPrintable(pszParm);
}
else
{
// Failed
pszFile = pwszCommand; pszParm = NULL;
}
if (!bForce)
{
DWORD nCheckSybsystem1 = 0, nCheckBits1 = 0;
if (!FindImageSubsystem(pszFile, nCheckSybsystem1, nCheckBits1))
{
hr = (HRESULT)-1;
DefTermLogString(L"OnShellExecCmdLine: FindImageSubsystem failed");
goto wrap;
}
if (nCheckSybsystem1 != IMAGE_SUBSYSTEM_WINDOWS_CUI)
{
hr = (HRESULT)-1;
DefTermLogString(L"OnShellExecCmdLine: !=IMAGE_SUBSYSTEM_WINDOWS_CUI");
goto wrap;
}
}
// "Run as admin" was requested?
if (bRunAsAdmin)
{
SHELLEXECUTEINFO sei = {sizeof(sei), 0, hwnd, L"runas", pszFile, pszParm, pwszStartDir, SW_SHOWNORMAL};
bShell = OnShellExecuteExW(&sei);
}
else
{
wchar_t* pwCommand = lstrdup(pwszCommand);
DWORD nCreateFlags = CREATE_NEW_CONSOLE|CREATE_UNICODE_ENVIRONMENT|CREATE_DEFAULT_ERROR_MODE;
STARTUPINFO si = {sizeof(si)};
PROCESS_INFORMATION pi = {};
bShell = OnCreateProcessW(NULL, pwCommand, NULL, NULL, FALSE, nCreateFlags, NULL, pwszStartDir, &si, &pi);
if (bShell)
{
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
}
hr = bShell ? S_OK : HRESULT_FROM_WIN32(GetLastError());
wrap:
return hr;
}