本文整理汇总了C++中CString::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::Find方法的具体用法?C++ CString::Find怎么用?C++ CString::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::Find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InsertComment
void CSynBCGPEditCtrl::InsertComment(BOOL bForward)
{
int iStartSel = min (m_iStartSel, m_iEndSel);
int iEndSel = max (m_iStartSel, m_iEndSel);
int nFirstSelRow, nLastSelRow;
if (iStartSel == -1 || iEndSel == -1)
{
nFirstSelRow = GetCurrRowStart(FALSE);
nLastSelRow = GetCurrRowEnd(FALSE);
}
else
{
int nEndRowOffset = GetRowStartByOffset (iEndSel, TRUE);
if (nEndRowOffset == iEndSel)
{
iEndSel--;
}
nFirstSelRow = GetRowStartByOffset (iStartSel, TRUE);
nLastSelRow = max (iEndSel, GetRowEndByOffset (iEndSel, TRUE));
}
SetSel2(nFirstSelRow, nLastSelRow + 1, TRUE, FALSE);
CString strSelText(GetSelText());
if (strSelText.IsEmpty())
{
return;
}
CString strComment;
BOOL bCaseSensitive;
m_SynLanguage.GetLineComment(strComment, bCaseSensitive);
int nPosPrior = 0;
int nPos = strComment.Find(_T(","), nPosPrior);
if(nPos != -1)
{
strComment = strComment.Mid(nPosPrior, nPos - nPosPrior);
}
if (strComment.IsEmpty())
{
return;
}
if (bForward)
{
int nCommentLen = strComment.GetLength();
nPos = nCommentLen;
strSelText.Insert(0, strComment);
nPos = strSelText.Find(g_chEOL, nPos);
while (nPos != -1)
{
if (nPos == strSelText.GetLength() - 1)
{
break;
}
strSelText.Insert(nPos + 1, strComment);
nPos = strSelText.Find(g_chEOL, nPos + nCommentLen + 1);
}
SetLastUndoReason(g_dwUATComment);
ReplaceSel(strSelText, TRUE);
}
else
{
int nCommentLen = strComment.GetLength();
BOOL bModify = FALSE;
CString strMid, strLeft;
int nPosComment;
nPos = 0, nPosPrior = 0;
nPos = strSelText.Find(g_chEOL, nPosPrior);
// 当是最后一行时,也要处理
if (-1 == nPos)
{
nPos = strSelText.GetLength();
}
while (nPos != -1)
{
strMid = strSelText.Mid(nPosPrior, nPos - nPosPrior);
strLeft = strMid.TrimLeft();
strLeft = strLeft.Left(nCommentLen);
if (strLeft.Compare(strComment) == 0)
{
nPosComment = strSelText.Find(strComment, nPosPrior);
if (nPosComment != -1)
{
strSelText.Delete(nPosComment, nCommentLen);
nPos -= nCommentLen;
bModify = TRUE;
}
}
nPosPrior = nPos + 1;
nPos = strSelText.Find(g_chEOL, nPosPrior);
if (-1 == nPos)
{
if (nPosPrior < strSelText.GetLength())
{
nPos = strSelText.GetLength();
}
//.........这里部分代码省略.........
示例2: ParserGitPatch
BOOL CPatch::ParserGitPatch(CFileTextLines &PatchLines,int nIndex)
{
CString sLine;
EOL ending = EOL_NOENDING;
int state = 0;
Chunks * chunks = NULL;
Chunk * chunk = NULL;
int nAddLineCount = 0;
int nRemoveLineCount = 0;
int nContextLineCount = 0;
for ( ;nIndex<PatchLines.GetCount(); nIndex++)
{
sLine = PatchLines.GetAt(nIndex);
ending = PatchLines.GetLineEnding(nIndex);
if (ending != EOL_NOENDING)
ending = EOL_AUTOLINE;
switch (state)
{
case 0:
{
// diff --git
if( sLine.Find(_T("diff --git"))==0)
{
if (chunks)
{
//this is a new file diff, so add the last one to
//our array.
m_arFileDiffs.Add(chunks);
}
chunks = new Chunks();
}
//index
if( sLine.Find(_T("index"))==0 )
{
int dotstart=sLine.Find(_T(".."));
if(dotstart>=0)
{
chunks->sRevision = sLine.Mid(dotstart-7,7);
chunks->sRevision2 = sLine.Mid(dotstart+2,7);
}
}
//---
if( sLine.Find(_T("--- "))==0 )
{
if (sLine.Left(3).Compare(_T("---"))!=0)
{
//no starting "---" found
//seems to be either garbage or just
//a binary file. So start over...
state = 0;
nIndex--;
if (chunks)
{
delete chunks;
chunks = NULL;
}
break;
}
sLine = sLine.Mid(3); //remove the "---"
sLine =sLine.Trim();
//at the end of the filepath there's a revision number...
int bracket = sLine.ReverseFind('(');
if (bracket < 0)
// some patch files can have another '(' char, especially ones created in Chinese OS
bracket = sLine.ReverseFind(0xff08);
if (bracket < 0)
{
if (chunks->sFilePath.IsEmpty())
chunks->sFilePath = sLine.Trim();
}
else
chunks->sFilePath = sLine.Left(bracket-1).Trim();
if (chunks->sFilePath.Find('\t')>=0)
{
chunks->sFilePath = chunks->sFilePath.Left(chunks->sFilePath.Find('\t'));
}
if (chunks->sFilePath.Find(_T('"')) == 0 && chunks->sFilePath.ReverseFind(_T('"')) == chunks->sFilePath.GetLength() - 1)
chunks->sFilePath=chunks->sFilePath.Mid(1, chunks->sFilePath.GetLength() - 2);
if( chunks->sFilePath.Find(_T("a/")) == 0 )
chunks->sFilePath=chunks->sFilePath.Mid(2);
if( chunks->sFilePath.Find(_T("b/")) == 0 )
chunks->sFilePath=chunks->sFilePath.Mid(2);
chunks->sFilePath.Replace(_T('/'),_T('\\'));
if (chunks->sFilePath == _T("\\dev\\null") || chunks->sFilePath == _T("/dev/null"))
chunks->sFilePath = _T("NUL");
}
// +++
//.........这里部分代码省略.........
示例3: LoadSettings
void CSettingsGeneralDlg::LoadSettings() {
CPBXClientApp* pApp = (CPBXClientApp*)AfxGetApp();
CString value;
int iValue;
value = pApp->GetProfileString("Settings", "DelayTime", "3");
this->SetDlgItemText(IDC_EDIT_DELAY_TIME, value);
iValue = pApp->GetProfileInt("Settings", "AutomaticStart", 1);
this->CheckDlgButton(IDC_CHECK_AUTOMATIC_START, (iValue==1)?1:0);
iValue = pApp->GetProfileInt("Settings", "AutomaticSignIn", 1);
this->CheckDlgButton(IDC_CHECK_AUTOMATIC_CONNECT, (iValue==1)?1:0);
iValue = pApp->GetProfileInt("Settings", "ShowSettingsOnStartup", 0);
this->CheckDlgButton(IDC_CHECK_SHOW_AT_STARTUP, (iValue==1)?0:1);
iValue = pApp->GetProfileInt("Settings", "IgnoreCalls", 0);
m_chkIgnore.SetCheck((iValue==0)?FALSE:1);
TCHAR chDigits[50];
for (int i=2; i<26; i++) {
_itot(i, chDigits, 10);
m_cboDigits.AddString(chDigits);
}
_itot(iValue, chDigits, 10);
if (iValue==0) {
m_cboDigits.EnableWindow(0);
m_cboDigits.SetCurSel(0);
} else {
m_cboDigits.EnableWindow(1);
m_cboDigits.SelectString(-1, chDigits);
}
FILE *file = _tfopen(::theApp.GetInstallDir()+"\\languages.txt", _T("r"));
if (file) {
CString str;
int pos;
char ch[100];
while (!feof(file)) {
str = fgets(ch, 100, file);
if (str.GetLength()<4) {
continue;
}
pos = str.Find(_T(" "));
languages[str.Left(pos)] = str.Mid(pos+1, str.GetLength()-pos-3);
}
fclose(file);
}
WIN32_FIND_DATA FileData;
HANDLE hFind;
map<CString, CString>::iterator iter;
CString CurrLanguage = pApp->GetProfileString("Settings", "Language", "");
m_cboLanguage.AddString(CString("(") + _("Default language") + CString(")"));
hFind = FindFirstFile(::theApp.GetInstallDir() + "\\lang\\*.*", &FileData);
if (hFind != INVALID_HANDLE_VALUE)
{
while (true) {
if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if (_tcscmp(FileData.cFileName, _T(".")) && _tcscmp(FileData.cFileName, _T(".."))) {
iter = languages.find(FileData.cFileName);
if (iter!=languages.end())
m_cboLanguage.AddString(iter->second);
else
m_cboLanguage.AddString(FileData.cFileName);
}
}
if (!FindNextFile(hFind, &FileData))
break;
}
FindClose(hFind);
}
if (CurrLanguage=="") {
m_cboLanguage.SetCurSel(0);
} else {
iter = languages.find(CurrLanguage);
if (iter!=languages.end()) {
m_cboLanguage.SelectString(-1, iter->second);
} else {
if (m_cboLanguage.SelectString(-1, CurrLanguage)==CB_ERR) {
m_cboLanguage.SetCurSel(0);
}
}
}
}
示例4: ParserFromRefLog
int ParserFromRefLog(CString ref, std::vector<GitRev> &refloglist)
{
refloglist.clear();
if (g_Git.m_IsUseLibGit2)
{
CAutoRepository repo(g_Git.GetGitRepository());
if (!repo)
{
MessageBox(nullptr, CGit::GetLibGit2LastErr(_T("Could not open repository.")), _T("TortoiseGit"), MB_ICONERROR);
return -1;
}
CAutoReflog reflog;
if (git_reflog_read(reflog.GetPointer(), repo, CUnicodeUtils::GetUTF8(ref)) < 0)
{
MessageBox(nullptr, CGit::GetLibGit2LastErr(_T("Could not read reflog.")), _T("TortoiseGit"), MB_ICONERROR);
return -1;
}
for (size_t i = 0; i < git_reflog_entrycount(reflog); ++i)
{
const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, i);
if (!entry)
continue;
GitRev rev;
rev.m_CommitHash = (char *)git_reflog_entry_id_new(entry)->id;
rev.m_Ref.Format(_T("%[email protected]{%d}"), ref, i);
rev.GetCommitterDate() = CTime(git_reflog_entry_committer(entry)->when.time);
if (git_reflog_entry_message(entry) != nullptr)
{
CString one;
g_Git.StringAppend(&one, (BYTE *)git_reflog_entry_message(entry));
int message = one.Find(_T(":"), 0);
if (message > 0)
{
rev.m_RefAction = one.Left(message);
rev.GetSubject() = one.Mid(message + 1);
}
}
refloglist.push_back(rev);
}
}
else if (g_Git.m_IsUseGitDLL)
{
git_for_each_reflog_ent(CUnicodeUtils::GetUTF8(ref), AddToRefLoglist, &refloglist);
for (size_t i = 0; i < refloglist.size(); ++i)
refloglist[i].m_Ref.Format(_T("%[email protected]{%d}"), ref, i);
}
else
{
CString cmd, out;
GitRev rev;
cmd.Format(_T("git.exe reflog show --pretty=\"%%H %%gD: %%gs\" --date=raw %s"), ref);
if (g_Git.Run(cmd, &out, NULL, CP_UTF8))
return -1;
int i = 0;
CString prefix = ref + _T("@{");
int pos = 0;
while (pos >= 0)
{
CString one = out.Tokenize(_T("\n"), pos);
int refPos = one.Find(_T(' '), 0);
if (refPos < 0)
continue;
rev.Clear();
CString hashStr = one.Left(refPos);
rev.m_CommitHash = hashStr;
rev.m_Ref.Format(_T("%[email protected]{%d}"), ref, i++);
int prefixPos = one.Find(prefix, refPos + 1);
if (prefixPos != refPos + 1)
continue;
int spacePos = one.Find(_T(' '), prefixPos + prefix.GetLength() + 1);
if (spacePos < 0)
continue;
CString timeStr = one.Mid(prefixPos + prefix.GetLength(), spacePos - prefixPos - prefix.GetLength());
rev.GetCommitterDate() = CTime(_ttoi(timeStr));
int action = one.Find(_T("}: "), spacePos + 1);
if (action > 0)
{
action += 2;
int message = one.Find(_T(":"), action);
if (message > 0)
{
rev.m_RefAction = one.Mid(action + 1, message - action - 1);
rev.GetSubject() = one.Right(one.GetLength() - message - 1);
}
}
refloglist.push_back(rev);
}
}
return 0;
}
示例5: Deserialize
TLSecurity TLSecurity::Deserialize(CString msg)
{
std::vector<CString> rec;
CString del(" ");
bool hasdel = msg.FindOneOf(del) != -1;
if (hasdel)
gsplit(msg,del,rec);
else
rec.push_back(msg);
TLSecurity sec;
// symbol is a requirement for every type
sec.sym = rec[SecSym];
// check for option
//bool isopt = (msg.Find(CString("PUT"))!=-1) || (msg.Find(CString("CALL"))!=-1);
if (rec.size()>1 && _tstoi(rec[1])!=0)
{
// sym, date, details, price, ex
sec.date = _tstoi(rec[1]);
bool isput = msg.Find(CString("PUT"))!=-1;
sec.details = isput ? CString("PUT") : CString("CALL");
sec.strike = _tstof(rec[3]);
if (rec.size()>5)
{
sec.dest = rec[4];
sec.type = SecurityID(rec[5]);
}
else
sec.type = SecurityID(rec[4]);
}// see if both type and destination were specified
else if (rec.size()>2)
{
// try to get type from both parameters
int f2id = SecurityID(rec[2]);
int f1id = SecurityID(rec[1]);
// whichever one works, use type for that one and assume destination
// is other parameter
if (f1id!=-1)
{
sec.type = f1id;
sec.dest = rec[2];
}
else if (f2id!=-1)
{
sec.type = f2id;
sec.dest = rec[1];
}
}
// otherwise if we only ahve one extra parameters
else if (rec.size()>1)
{
// try to get it's type
int id = SecurityID(rec[1]);
// if it works assume it's type
if (id!=-1)
sec.type = id;
else // otherwise it's exchange
sec.dest = rec[1];
}
return sec;
}
示例6: vSetFunctionToEdit
void CFunctionView::vSetFunctionToEdit(const CString& omStrFunction)
{
m_omStrFnName = omStrFunction;
CString omStrFnBody("");
BOOL bGlobalVar = FALSE;
m_bIsValidFunction = FALSE;
m_sStartPos = NULL;
CFunctionEditorDoc* pDoc = NULL;
pDoc = (CFunctionEditorDoc*)CView::GetDocument();
if ( pDoc != NULL )
{
SBUS_SPECIFIC_INFO sBusSpecInfo;
pDoc->bGetBusSpecificInfo(sBusSpecInfo);
CString omStrFnHeader, omStrFnFooter;
// If it is a global variable block then set the block
// with global variable boundary
if( omStrFunction == GLOBAL_VARIABLES )
{
omStrFnHeader = BUS_VAR_HDR;
omStrFnHeader.Replace("PLACE_HODLER_FOR_BUSNAME", sBusSpecInfo.m_omBusName);
omStrFnFooter = BUS_VAR_FOOTER;
omStrFnFooter.Replace("PLACE_HODLER_FOR_BUSNAME", sBusSpecInfo.m_omBusName);
bGlobalVar = TRUE;
}
else
{
//Construct the Function Header
omStrFnHeader = BUS_FN_HDR;
omStrFnHeader.Replace("PLACE_HODLER_FOR_BUSNAME", sBusSpecInfo.m_omBusName);
omStrFnHeader.Replace( "PLACE_HODLER_FOR_FUNCTIONNAME",
omStrFunction );
//Construct the Function Footer
omStrFnFooter = EDITOR_BUS_FN_FOOTER;
omStrFnFooter.Replace(_T("PLACE_HODLER_FOR_BUSNAME"), sBusSpecInfo.m_omBusName);
omStrFnFooter.Replace( _T("PLACE_HODLER_FOR_FUNCTIONNAME"),
omStrFunction );
}
POSITION sPos = pDoc->m_omSourceCodeTextList.GetHeadPosition();
int nLineNumber = 0;
while ( sPos != NULL )
{
//Iterate through the Source Code String-List
CString omStrLine = pDoc->m_omSourceCodeTextList.GetNext(sPos);
// Increment the line count
nLineNumber++;
//If the current line matches the Function Header...
//(means the starting of the function we are looking for)
if ( omStrLine == omStrFnHeader )
{
if( bGlobalVar == FALSE)
{
m_nStartingLine = nLineNumber;
//Skip Function name and parameters line
omStrLine = pDoc->m_omSourceCodeTextList.GetNext(sPos);
if (sPos != NULL)
{
//Get Next line
omStrLine = pDoc->m_omSourceCodeTextList.GetNext(sPos);
if (sPos != NULL)
{
//Opening brace indicates start of function body
if ( omStrLine.Find('{') != -1 )
{
//Store the start for later use
m_sStartPos = sPos;
//Loop through the function body till we encounter
//the function footer
while ( (sPos != NULL) && ( m_bIsValidFunction != TRUE) )
{
omStrLine = pDoc->m_omSourceCodeTextList.GetNext(sPos);
if ( omStrLine.Find(omStrFnFooter) >= 0 )
{
m_bIsValidFunction = TRUE;
}
else
{
omStrFnBody += omStrLine;
omStrFnBody += '\n';
}
}
}
}
}
}
else
{
//Store the start for later use
m_sStartPos = sPos;
m_nStartingLine = nLineNumber;
//.........这里部分代码省略.........
示例7: InitInstance
BOOL CGpsxConsoleApp::InitInstance()
{
AfxEnableControlContainer();
openCommandWindow();
TCHAR result[MAX_PATH];
GetModuleFileName(NULL,result,MAX_PATH);//daemon
CString strProcess;
strProcess.Format(_T("%s"),result);
strProcess.MakeLower();
int nRet = strProcess.Find("daemon.exe");
if(__argc==1 && nRet>0 )//带参数
{
printf("守护进程\r\nPress 'E' to exit\r\n");
nRet = strProcess.Find("daemon");
strProcess.Delete(nRet,6);
HANDLE hProcess=NULL;
DWORD dwProcessID=0;
while(1){
if((dwProcessID=_IsProcessExist(strProcess))==0){
int nRet = DeleteFile(strProcess);
if(nRet || GetLastError()==2){
if(CopyFile(result,strProcess,FALSE)){
PROCESS_INFORMATION pi;
_CreateProcess(strProcess,pi,FALSE,"");
hProcess = pi.hProcess;
dwProcessID = pi.dwProcessId;
}else{
}
}else{
// printf("deletefile %d,%d\r\n",nRet,GetLastError());
}
//printf("pi-->%d-->%d\r\n",hProcess,pi.dwProcessId);
}else{
//printf("IS-->%d\r\n",hProcess);
}
//Sleep(30*1000);
if(getch2(3*1000) == 101){
_KillProcess(dwProcessID);
int i=0;
do{
Sleep(i*100);
BOOL bRet = DeleteFile(strProcess);
printf("%s---%d\r\n",strProcess,bRet);
}while(i++<4);
return 1;
}
}
}
CString strLogServer("sonaps.logger.service.exe");
//*
HANDLE hProcess=NULL;
DWORD dwProcessID = 0;
if(!_IsProcessExist(strLogServer,FALSE)){
PROCESS_INFORMATION pi;
_CreateProcess(strLogServer,pi,FALSE,"");
}/**/
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
int nListenPort=GetPrivateProfileInt(_T("GPSSet"),_T("listenPort"),110,GetMgConfigFileName());
CString strTmp;
strTmp.Format(_T("GPSXCONSOLE_H__BA472566_78AA_%d"),nListenPort);
if(OpenMutex(MUTEX_ALL_ACCESS,FALSE,strTmp))
{
return FALSE;
}
else
{
CreateMutex(NULL,FALSE,strTmp);
}
// IDumper *pDumper = CreateDumper();
// if(pDumper)
// pDumper->SetExceptionFilter();
//自动抓取错误dump
CMiniDumper::SetExceptionFilter(MiniDumpWithFullMemory);
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CGpsxConsoleDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
//.........这里部分代码省略.........
示例8: Create
bool CHooks::Create()
{
if (m_pInstance == NULL)
m_pInstance = new CHooks();
CRegString reghooks = CRegString(L"Software\\TortoiseSVN\\hooks");
CString strhooks = reghooks;
// now fill the map with all the hooks defined in the string
// the string consists of multiple lines, where one hook script is defined
// as six lines:
// line 1: the hook type
// line 2: path to working copy where to apply the hook script
// line 3: command line to execute
// line 4: 'true' or 'false' for waiting for the script to finish
// line 5: 'show' or 'hide' on how to start the hook script
// line 6: 'enforce' on whether to ask the user for permission (optional)
hookkey key;
int pos = 0;
hookcmd cmd;
while ((pos = strhooks.Find('\n')) >= 0)
{
// line 1
key.htype = GetHookType(strhooks.Mid(0, pos));
if (pos+1 < strhooks.GetLength())
strhooks = strhooks.Mid(pos+1);
else
strhooks.Empty();
bool bComplete = false;
if ((pos = strhooks.Find('\n')) >= 0)
{
// line 2
key.path = CTSVNPath(strhooks.Mid(0, pos));
if (pos+1 < strhooks.GetLength())
strhooks = strhooks.Mid(pos+1);
else
strhooks.Empty();
if ((pos = strhooks.Find('\n')) >= 0)
{
// line 3
cmd.commandline = strhooks.Mid(0, pos);
if (pos+1 < strhooks.GetLength())
strhooks = strhooks.Mid(pos+1);
else
strhooks.Empty();
if ((pos = strhooks.Find('\n')) >= 0)
{
// line 4
cmd.bWait = (strhooks.Mid(0, pos).CompareNoCase(L"true")==0);
if (pos+1 < strhooks.GetLength())
strhooks = strhooks.Mid(pos+1);
else
strhooks.Empty();
if ((pos = strhooks.Find('\n')) >= 0)
{
// line 5
cmd.bShow = (strhooks.Mid(0, pos).CompareNoCase(L"show")==0);
if (pos+1 < strhooks.GetLength())
strhooks = strhooks.Mid(pos+1);
else
strhooks.Empty();
cmd.bEnforce = false;
if ((pos = strhooks.Find('\n')) >= 0)
{
// line 6 (optional)
if (GetHookType(strhooks.Mid(0, pos)) == unknown_hook)
{
cmd.bEnforce = (strhooks.Mid(0, pos).CompareNoCase(L"enforce")==0);
if (pos+1 < strhooks.GetLength())
strhooks = strhooks.Mid(pos+1);
else
strhooks.Empty();
}
}
cmd.bApproved = true; // user configured scripts are pre-approved
bComplete = true;
}
}
}
}
if (bComplete)
{
m_pInstance->insert(std::pair<hookkey, hookcmd>(key, cmd));
}
}
return true;
}
示例9: ParseAndInsertProjectProperty
bool CHooks::ParseAndInsertProjectProperty( hooktype t, const CString& strhook, const CTSVNPath& wcRootPath, const CString& rootPath, const CString& rootUrl, const CString& repoRootUrl )
{
if (strhook.IsEmpty())
return false;
// the string consists of multiple lines, where one hook script is defined
// as four lines:
// line 1: command line to execute
// line 2: 'true' or 'false' for waiting for the script to finish
// line 3: 'show' or 'hide' on how to start the hook script
// line 4: 'force' on whether to ask the user for permission
hookkey key;
hookcmd cmd;
key.htype = t;
key.path = wcRootPath;
int pos = 0;
CString temp;
temp = strhook.Tokenize(L"\n", pos);
if (!temp.IsEmpty())
{
ASSERT(t == GetHookType(temp));
temp = strhook.Tokenize(L"\n", pos);
if (!temp.IsEmpty())
{
int urlstart = temp.Find(L"%REPOROOT%");
if (urlstart >= 0)
{
temp.Replace(L"%REPOROOT%", repoRootUrl);
CString fullUrl = temp.Mid(urlstart);
int urlend = -1;
if ((urlstart > 0)&&(temp[urlstart-1]=='\"'))
urlend = temp.Find('\"', urlstart);
else
urlend = temp.Find(' ', urlstart);
if (urlend < 0)
urlend = temp.GetLength();
fullUrl = temp.Mid(urlstart, urlend-urlstart);
fullUrl.Replace('\\', '/');
// now we have the full url of the script, e.g.
// https://svn.osdn.net/svnroot/tortoisesvn/trunk/contrib/hook-scripts/client-side/checkyear.js
CString sLocalPathUrl = rootUrl;
CString sLocalPath = rootPath;
// find the lowest common ancestor of the local path url and the script url
while (fullUrl.Left(sLocalPathUrl.GetLength()).Compare(sLocalPathUrl))
{
int sp = sLocalPathUrl.ReverseFind('/');
if (sp < 0)
return false;
sLocalPathUrl = sLocalPathUrl.Left(sp);
sp = sLocalPath.ReverseFind('\\');
if (sp < 0)
return false;
sLocalPath = sLocalPath.Left(sp);
}
// now both sLocalPathUrl and sLocalPath can be used to construct
// the path to the script
CString partUrl = fullUrl.Mid(sLocalPathUrl.GetLength());
if (partUrl.Find('/') == 0)
partUrl = partUrl.Mid(1);
if (sLocalPath.ReverseFind('\\') == sLocalPath.GetLength() - 1 || sLocalPath.ReverseFind('/') == sLocalPath.GetLength() - 1)
sLocalPath = sLocalPath.Left(sLocalPath.GetLength() - 1);
sLocalPath = sLocalPath + L"\\" + partUrl;
sLocalPath.Replace('/', '\\');
// now replace the full url in the command line with the local path
temp.Replace(fullUrl, sLocalPath);
}
urlstart = temp.Find(L"%REPOROOT+%");
if (urlstart >= 0)
{
CString temp2 = temp;
CString sExt = rootUrl.Mid(repoRootUrl.GetLength());
CString sLocalPath;
do
{
temp = temp2;
CString repoRootUrlExt = repoRootUrl + sExt;
int slp = sExt.ReverseFind('/');
if (slp >= 0)
sExt = sExt.Left(sExt.ReverseFind('/'));
else if (sExt.IsEmpty())
return false;
else
sExt.Empty();
temp.Replace(L"%REPOROOT+%", repoRootUrlExt);
CString fullUrl = temp.Mid(urlstart);
int urlend = -1;
if ((urlstart > 0)&&(temp[urlstart-1]=='\"'))
urlend = temp.Find('\"', urlstart);
else
urlend = temp.Find(' ', urlstart);
if (urlend < 0)
urlend = temp.GetLength();
fullUrl = temp.Mid(urlstart, urlend-urlstart);
fullUrl.Replace('\\', '/');
// now we have the full url of the script, e.g.
// https://svn.osdn.net/svnroot/tortoisesvn/trunk/contrib/hook-scripts/client-side/checkyear.js
//.........这里部分代码省略.........
示例10: dlgUnknown
/* this is the main converter for external viewers.
* it returns the stream object as well
* as a data object that it can reference
* internally to save the state of the document
*/
NET_StreamClass *external_viewer_disk_stream(int iFormatOut, void *pDataObj, URL_Struct *pUrl, MWContext *pContext)
{
ASSERT(pUrl);
ASSERT(pUrl->address);
// Lookup the helper app, if one exists.
// If not found, create one on the fly.
CNetscapeApp *pNetscape = (CNetscapeApp *)AfxGetApp();
CHelperApp *pHelper;
XP_Bool isNewHelper = FALSE;
if(0 == pNetscape->m_HelperListByType.Lookup(pUrl->content_type, (CObject *&)pHelper)) {
// couldn't find one.
// create the new mime type.
CString csText = pUrl->content_type;
// If there's no slash, just send the type as the file type
// (this usually only happens on server error, but we
// should still behave ourselves).
int iSlash = csText.Find('/');
if(iSlash != -1) {
// this mess splits the string into the stuff before the slash and
// the stuff after the slash
pHelper = fe_AddNewFileFormatType(csText.Left(iSlash),
csText.Right(csText.GetLength() - iSlash - 1));
isNewHelper = TRUE;
}
else {
pHelper = fe_AddNewFileFormatType(csText, "");
isNewHelper = TRUE;
}
}
// The helper app is now defined for the mime type in any case.
// See how it is to be handled.
BOOL bExternal = FALSE;
BOOL bSave = FALSE;
BOOL bMoreInfo = FALSE;
switch(pHelper->how_handle) {
case HANDLE_UNKNOWN: {
// See what this is supposed to do via user input.
CUnknownTypeDlg dlgUnknown(GetFrame(pContext)->GetFrameWnd(), pUrl->content_type, pHelper);
int iDlg = dlgUnknown.DoModal();
if(iDlg == IDCANCEL) {
// User hit cancel. Abort the load.
if (pHelper && pHelper->cd_item && isNewHelper) {
if (XP_ListRemoveObject(cinfo_MasterListPointer(), pHelper->cd_item)) {
if (pHelper->cd_item) {
if (pHelper->cd_item->ci.type) {
theApp.m_HelperListByType.RemoveKey(pHelper->cd_item->ci.type);
XP_FREE( pHelper->cd_item->ci.type );
}
XP_FREE (pHelper->cd_item);
}
delete pHelper;
}
}
return(NULL);
}
else if(iDlg == HANDLE_EXTERNAL) {
char buf[256];
bExternal = TRUE;
// We need to indicate that this is a user-defined MIME type. If we
// don't, then we won't remember it the next time the Navigator is run
sprintf(buf,"TYPE%d",theApp.m_iNumTypesInINIFile);
theApp.m_iNumTypesInINIFile++;
theApp.WriteProfileString("Viewers", buf, pUrl->content_type);
pHelper->bNewType = FALSE;
}
else if(iDlg == HANDLE_SAVE) {
bSave = TRUE;
}
else if(iDlg == HANDLE_MOREINFO) {
bMoreInfo = TRUE;
}
break;
}
case HANDLE_EXTERNAL:
case HANDLE_BY_OLE: {
bExternal = TRUE;
break;
}
case HANDLE_SHELLEXECUTE: {
bExternal = TRUE;
break;
}
case HANDLE_SAVE: {
bSave = TRUE;
break;
}
default: {
//.........这里部分代码省略.........
示例11: WordWrap
CString CStringUtils::WordWrap(const CString& longstring, int limit, bool bCompactPaths, bool bForceWrap, int tabSize)
{
int nLength = longstring.GetLength();
CString retString;
if (limit < 0)
limit = 0;
int nLineStart = 0;
int nLineEnd = 0;
int tabOffset = 0;
for (int i = 0; i < nLength; ++i)
{
if (i-nLineStart+tabOffset >= limit)
{
if (nLineEnd == nLineStart)
{
if (bForceWrap)
nLineEnd = i;
else
{
while ((i < nLength) && (longstring[i] != ' ') && (longstring[i] != '\t'))
++i;
nLineEnd = i;
}
}
if (bCompactPaths)
{
CString longline = longstring.Mid(nLineStart, nLineEnd-nLineStart).Left(MAX_PATH-1);
if ((bCompactPaths)&&(longline.GetLength() < MAX_PATH))
{
if (((!PathIsFileSpec(longline))&&longline.Find(':')<3)||(PathIsURL(longline)))
{
TCHAR buf[MAX_PATH] = { 0 };
PathCompactPathEx(buf, longline, limit+1, 0);
longline = buf;
}
}
retString += longline;
}
else
retString += longstring.Mid(nLineStart, nLineEnd-nLineStart);
retString += L"\n";
tabOffset = 0;
nLineStart = nLineEnd;
}
if (longstring[i] == ' ')
nLineEnd = i;
if (longstring[i] == '\t')
{
tabOffset += (tabSize - i % tabSize);
nLineEnd = i;
}
}
if (bCompactPaths)
{
CString longline = longstring.Mid(nLineStart).Left(MAX_PATH-1);
if ((bCompactPaths)&&(longline.GetLength() < MAX_PATH))
{
if (((!PathIsFileSpec(longline))&&longline.Find(':')<3)||(PathIsURL(longline)))
{
TCHAR buf[MAX_PATH] = { 0 };
PathCompactPathEx(buf, longline, limit+1, 0);
longline = buf;
}
}
retString += longline;
}
else
retString += longstring.Mid(nLineStart);
return retString;
}
示例12: OnOK
LRESULT CAddMemberVarGl::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
DoDataExchange(TRUE);
//получаем тип
int StartType = 0;
CString Delim = _T(" \t\r\n");
int n1 ,n2;
BOOL bConst = FALSE;
while(StartType >= 0)
{
n1 = m_Edit.Mid(StartType).FindOneOf(Delim) + StartType;
if (n1 == -1)
{
MessageBox(_T("Wrong definition"));
return 0;
}
n2 = n1;
while((Delim.Find(m_Edit[n2]) != -1) && (n2 < m_Edit.GetLength()))
{
n2++;
}
//не совсем правильно, но в больштнстве случаев работает
m_Type = m_Edit.Left(n1);
m_Type.TrimLeft();
if (m_Type == _T("static"))
{
m_bStatic = TRUE;
StartType = n2;
continue;
}
if (m_Type == _T("virtual"))
{
m_bVirtual = TRUE;
StartType = n2;
continue;
}
if (m_Type == _T("const"))
{
bConst = TRUE;
StartType = n2;
continue;
}
StartType = -1;
}
if (bConst && m_AddType == ADD_TYPE_FUNCTION)
{
m_Type = _T("const ") + m_Type;
}
else
{
m_bConst |= bConst;
}
m_Body = m_Edit.Mid(n2);
m_Body.TrimRight();
int k1 = m_ClassBox.GetCurSel();
if (k1 != -1)
{
m_pCurClass = (VSClass*)m_ClassBox.GetItemDataPtr(k1);
}
else
{
m_pCurClass = NULL;
}
EndDialog(IDOK);
return 0;
}
示例13: AnalyseGpsData
/*
*函数介绍:解析GPS数据
*入口参数:aRecvStr :指待解析的GPS缓冲数据
*出口参数:(无)
*返回值:指CGPSData结构体的指针,如果无效即为:NULL;
*/
PGPSData CGPS::AnalyseGpsData(CString &aRecvStr)
{
CString tmpTime;
CString tmpState;
CString tmpDate;
CString tmpLONG;
CString tmpLONGType;
CString tmpLAT;
CString tmpLATType;
CString tmpSpeed;
LPSTR pStrDate = NULL;
LPSTR pStrTime = NULL;
LPSTR pStrLong = NULL;
LPSTR pStrLongType = NULL;
LPSTR pStrLat = NULL;
LPSTR pStrLatType = NULL;
LPSTR pStrSpeed = NULL;
PGPSData pGpsData = NULL;
int tmpPos,tmpPos1;
int len;
tmpPos = aRecvStr.Find(',',0); //第1个值
tmpPos1 = aRecvStr.Find(',',tmpPos+1);
//得到时间
tmpTime = aRecvStr.Mid(tmpPos+1,tmpPos1-tmpPos-1);
tmpTime = tmpTime.Mid(0,2)+L":"+tmpTime.Mid(2,2)+L":"+tmpTime.Mid(4,2);
len = tmpTime.GetLength();
pStrTime = LPSTR(LocalAlloc(LMEM_ZEROINIT,len));
WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK,tmpTime.GetBuffer(len),len
,pStrTime,len ,NULL,NULL);
//数据状态,是否有效
tmpPos = aRecvStr.Find(',',tmpPos+1); //第2个值
tmpPos1 = aRecvStr.Find(',',tmpPos+1);
tmpState = aRecvStr.Mid(tmpPos+1,tmpPos1-tmpPos-1);
if (tmpState != 'A')//代表数据无效,返回
{
if (m_gpsDev_State != GPS_INVALID_DATA)
{
//设置GPS状态
m_gpsDev_State = GPS_INVALID_DATA;
//发送GPS状态变化消息
::PostMessage(m_pWnd->m_hWnd,WM_GPS_STATE_CHANGE_MESSAGE,WPARAM(GPS_INVALID_DATA),1);
}
LocalFree(pStrTime);
return NULL;
}
else //代表数据有效
{
if (m_gpsDev_State != GPS_VALID_DATA)
{
//设置GPS状态
m_gpsDev_State = GPS_VALID_DATA;
//发送GPS状态变化消息
::PostMessage(m_pWnd->m_hWnd,WM_GPS_STATE_CHANGE_MESSAGE,WPARAM(GPS_VALID_DATA),1);
}
}
//得到纬度值
tmpPos = aRecvStr.Find(',',tmpPos+1);//第3个值
tmpPos1 = aRecvStr.Find(',',tmpPos+1);
tmpLAT = aRecvStr.Mid(tmpPos+1,tmpPos1-tmpPos-1);
len = tmpLAT.GetLength();
pStrLat = LPSTR(LocalAlloc(LMEM_ZEROINIT,len));
WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK,tmpLAT.GetBuffer(len),len
,pStrLat,len ,NULL,NULL);
tmpPos = aRecvStr.Find(',',tmpPos+1);//第4个值
tmpPos1 = aRecvStr.Find(',',tmpPos+1);
tmpLATType = aRecvStr.Mid(tmpPos+1,tmpPos1-tmpPos-1);
len = tmpLATType.GetLength();
pStrLatType = LPSTR(LocalAlloc(LMEM_ZEROINIT,len));
WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK,tmpLATType.GetBuffer(len),len
,pStrLatType,len ,NULL,NULL);
//得到经度值
tmpPos = aRecvStr.Find(',',tmpPos+1);//第5个值
tmpPos1 = aRecvStr.Find(',',tmpPos+1);
tmpLONG = aRecvStr.Mid(tmpPos+1,tmpPos1-tmpPos-1);
len = tmpLONG.GetLength();
pStrLong = LPSTR(LocalAlloc(LMEM_ZEROINIT,len));
WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK,tmpLONG.GetBuffer(len),len
,pStrLong,len ,NULL,NULL);
tmpPos = aRecvStr.Find(',',tmpPos+1);//第6个值
tmpPos1 = aRecvStr.Find(',',tmpPos+1);
//.........这里部分代码省略.........
示例14: bIsModeMismatch
BOOL bIsModeMismatch( ifstream& omInReplayFile,
BOOL bReplayHexON,
WORD wLogReplayTimeMode)
{
BOOL bFlag = FALSE;
BOOL bLine = TRUE;
CHAR Line[500] = { NULL };
CString omStrLine;
BOOL bLogModeChecked = FALSE;
BOOL bReplayMsgTypeChecked = FALSE;
if(omInReplayFile != NULL)
{
while( bLine && ! omInReplayFile.eof())
{
omInReplayFile.getline( Line, sizeof(Line));
omStrLine = Line;
if( omStrLine.Find(HEX_MODE) == 0)
{
bLogModeChecked = TRUE;
if(bReplayHexON != TRUE)
{
bFlag = TRUE;
}
}
else if (omStrLine.Find(DEC_MODE) == 0)
{
bLogModeChecked = TRUE;
if(bReplayHexON != FALSE)
{
bFlag = TRUE;
}
}
if( omStrLine.Find(SYSTEM_MODE) == 0)
{
bReplayMsgTypeChecked = TRUE;
if( wLogReplayTimeMode != eSYSTEM_MODE)
{
bFlag = TRUE;
bLine = FALSE;
}
}
else if( omStrLine.Find(ABSOLUTE_MODE) == 0)
{
bReplayMsgTypeChecked = TRUE;
if( wLogReplayTimeMode != eABSOLUTE_MODE)
{
bFlag = TRUE;
bLine = FALSE;
}
}
else if( omStrLine.Find(RELATIVE_MODE) == 0)
{
bReplayMsgTypeChecked = TRUE;
if( wLogReplayTimeMode != eRELATIVE_MODE)
{
bFlag = TRUE;
bLine = FALSE;
}
}
if(bLogModeChecked == TRUE && bReplayMsgTypeChecked == TRUE)
{
bLine = FALSE;
}
}
}
return bFlag;
}
示例15: SaveData
void CPage_Node_Movement::SaveData()
{
bool bTurnVolumeModified = false;
UpdateData(1);
std::map<int, int> IncomingLinkMap;
DTANode* pNode = m_pDoc->m_NodeNoMap [m_CurrentNodeID];
if( pNode->m_CycleLengthInSecond != m_CycleLengthInSec || pNode->m_SignalOffsetInSecond != m_Offset)
{
m_pDoc->Modify (true);
pNode->m_SignalOffsetInSecond = m_Offset;
}
for (unsigned int i=0;i< pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector .size();i++)
{
int turning_prohibition_flag= pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].turning_prohibition_flag;
int PrevQEM_lanes = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_Lanes;
int QEM_Phase1 = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_Phase1;
CString LaneString = m_ListCtrl.GetItemText (i,GetColumnIndex("# of Lanes"));
int QEM_lanes= atoi(LaneString);
// update # of lanes on link
if(PrevQEM_lanes != QEM_lanes)
{
DTALink* pLink0 = m_pDoc->m_LinkNoMap[pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].IncomingLinkNo ];
switch (pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].movement_turn)
{
case DTA_Through: pLink0->m_NumberOfLanes = QEM_lanes; break;
case DTA_LeftTurn:
case DTA_LeftTurn2:
pLink0->m_NumberOfLeftTurnLanes = QEM_lanes ; break;
case DTA_RightTurn:
case DTA_RightTurn2:
pLink0->m_NumberOfRightTurnLanes = QEM_lanes ; break;
}
}
int obs_turn_hourly_count = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].obs_turn_hourly_count ;
int obs_turn_delay = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].obs_turn_delay ;
DTA_SIG_MOVEMENT movement_approach_turn = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].movement_approach_turn ;
int effective_green= (int)(pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_EffectiveGreen);
int saturation_flow_rate= (int)(pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_SatFlow);
DTANodeMovement movement = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i];
int colume_index = 3;
CString str;
str = m_ListCtrl.GetItemText (i,GetColumnIndex("Direction"));
pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].movement_approach_turn = m_pDoc->GetTurnDirectionFromString(str);
str = m_ListCtrl.GetItemText (i,GetColumnIndex("Prohibition"));
if(str.Find("Prohibited") == -1) // not found
pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].turning_prohibition_flag = 0;
else
pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].turning_prohibition_flag = 1;
str = m_ListCtrl.GetItemText (i,GetColumnIndex("# of Lanes"));
pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_Lanes = atoi(str);
if(m_bSigalizedNode == true)
{
str = m_ListCtrl.GetItemText (i,GetColumnIndex("Green Start Time"));
pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_StartTime = atoi(str);
str = m_ListCtrl.GetItemText (i,GetColumnIndex("Green End Time"));
pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_EndTime = atoi(str);
str = m_ListCtrl.GetItemText (i,GetColumnIndex("Sat Flow Rate Per Lane Group"));
pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_SatFlow = atoi(str);
}
if(movement_approach_turn != pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].movement_approach_turn ||
obs_turn_hourly_count != pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].obs_turn_hourly_count ||
obs_turn_delay != pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].obs_turn_delay ||
turning_prohibition_flag != pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].turning_prohibition_flag ||
QEM_lanes != pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_Lanes
)
{
m_bModifiedFlag = true;
m_pDoc->Modify (true);
//.........这里部分代码省略.........