本文整理汇总了C++中CString::Mid方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::Mid方法的具体用法?C++ CString::Mid怎么用?C++ CString::Mid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::Mid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExcludeTag
BOOL AFX_GLOBAL_DATA::ExcludeTag(CString& strBuffer, LPCTSTR lpszTag, CString& strTag, BOOL bIsCharsList /* = FALSE*/)
{
const int iBufLen = strBuffer.GetLength();
CString strTagStart = _T("<");
strTagStart += lpszTag;
strTagStart += _T(">");
const int iTagStartLen = strTagStart.GetLength();
int iStart = -1;
int iIndexStart = strBuffer.Find(strTagStart);
if (iIndexStart < 0)
{
return FALSE;
}
iStart = iIndexStart + iTagStartLen;
CString strTagEnd = _T("</");
strTagEnd += lpszTag;
strTagEnd += _T('>');
const int iTagEndLen = strTagEnd.GetLength();
int iIndexEnd = -1;
int nBalanse = 1;
for (int i = iStart; i < iBufLen - iTagEndLen + 1; i ++)
{
if (strBuffer [i] != '<')
{
continue;
}
if (i < iBufLen - iTagStartLen && _tcsncmp(strBuffer.Mid(i), strTagStart, iTagStartLen) == 0)
{
i += iTagStartLen - 1;
nBalanse ++;
continue;
}
if (_tcsncmp(strBuffer.Mid(i), strTagEnd, iTagEndLen) == 0)
{
nBalanse --;
if (nBalanse == 0)
{
iIndexEnd = i;
break;
}
i += iTagEndLen - 1;
}
}
if (iIndexEnd == -1 || iStart > iIndexEnd)
{
return FALSE;
}
strTag = strBuffer.Mid(iStart, iIndexEnd - iStart);
strTag.TrimLeft();
strTag.TrimRight();
strBuffer.Delete(iIndexStart, iIndexEnd + iTagEndLen - iIndexStart);
if (bIsCharsList)
{
if (strTag.GetLength() > 1 && strTag [0] == _T('\"'))
{
strTag = strTag.Mid(1, strTag.GetLength() - 2);
}
strTag.Replace(_T("\\t"), _T("\t"));
strTag.Replace(_T("\\n"), _T("\n"));
strTag.Replace(_T("\\r"), _T("\r"));
strTag.Replace(_T("\\b"), _T("\b"));
strTag.Replace(_T("LT"), _T("<"));
strTag.Replace(_T("GT"), _T(">"));
strTag.Replace(_T("AMP"), _T("&"));
}
return TRUE;
}
示例2: Parse
bool CSubtitleDlDlg::Parse()
{
// Parse raw list
isdb_movie m;
isdb_subtitle sub;
CAtlList<CStringA> sl;
Explode(m_pTA->raw_list, sl, '\n');
CString str;
POSITION pos = sl.GetHeadPosition();
while (pos) {
str = sl.GetNext(pos);
CStringA param = str.Left(max(0, str.Find('=')));
CStringA value = str.Mid(str.Find('=') + 1);
if (param == "ticket") {
m_pTA->ticket = value;
} else if (param == "movie") {
m.reset();
Explode(value, m.titles, '|');
} else if (param == "subtitle") {
sub.reset();
sub.id = atoi(value);
} else if (param == "name") {
sub.name = value;
} else if (param == "discs") {
sub.discs = atoi(value);
} else if (param == "disc_no") {
sub.disc_no = atoi(value);
} else if (param == "format") {
sub.format = value;
} else if (param == "iso639_2") {
sub.iso639_2 = value;
} else if (param == "language") {
sub.language = value;
} else if (param == "nick") {
sub.nick = value;
} else if (param == "email") {
sub.email = value;
} else if (param == "" && value == "endsubtitle") {
m.subs.AddTail(sub);
} else if (param == "" && value == "endmovie") {
m_pTA->raw_movies.AddTail(m);
} else if (param == "" && value == "end") {
break;
}
}
// Parse movies
pos = m_pTA->raw_movies.GetHeadPosition();
while (pos) {
isdb_movie& raw_movie = m_pTA->raw_movies.GetNext(pos);
isdb_movie_parsed p;
CStringA titlesA = Implode(raw_movie.titles, '|');
titlesA.Replace("|", ", ");
p.titles = UTF8To16(titlesA);
p.checked = false;
POSITION pos2 = raw_movie.subs.GetHeadPosition();
while (pos2) {
const isdb_subtitle& s = raw_movie.subs.GetNext(pos2);
p.name = UTF8To16(s.name);
p.language = s.language;
p.format = s.format;
p.disc.Format(_T("%d/%d"), s.disc_no, s.discs);
p.ptr = reinterpret_cast<DWORD_PTR>(&s);
m_parsed_movies.Add(p);
}
}
bool ret = true;
if (m_parsed_movies.GetCount() == 0) {
ret = false;
}
return ret;
}
示例3: ReadFile
bool CHexFileList::ReadFile()
{
CStdioFile ff; // Text file we are reading from
CFileException fe; // Stores file exception info
CString strLine; // One line read in from the file
// Open the file
if (!ff.Open(filename_, CFile::modeRead|CFile::shareDenyWrite|CFile::typeText, &fe))
return false;
// Read all the recent file names (and associated data) from the file
ver_ = -1;
for (int line_no = 0; ff.ReadString(strLine); ++line_no)
{
// Ignore comment lines
if (strLine[0] == ';')
{
// Get file version from 1st comment line
if (line_no == 0 && _strnicmp(strLine, "; version ", 10) == 0)
ver_ = atoi((const char *)strLine + 10);
if (ver_ > 4)
return false; // Can't handle new fileformat in this old program
continue;
}
CString ss;
// Get the file's name
AfxExtractSubString(ss, strLine, 0, '|');
if (ss.IsEmpty()) continue;
name_.push_back(ss);
ss.MakeUpper();
hash_.push_back(str_hash(ss));
// Get the last opened date
AfxExtractSubString(ss, strLine, 1, '|');
time_t tt = strtol(ss, NULL, 10);
opened_.push_back(tt);
if (ver_ > 3)
{
AfxExtractSubString(ss, strLine, 2, '|');
open_count_.push_back(strtol(ss, NULL, 10));
}
else
open_count_.push_back(1); // it must have been opened at least once before
// Get the data string
int curr; // Where in the input string the extra data is stored
ss.Empty(); // Default data
if (ver_ > 3)
{
// Skip 1st three vertical bars (|)
if ((curr = strLine.Find('|')) != -1 && (curr = strLine.Find('|', curr+1)) != -1 && (curr = strLine.Find('|', curr+1)) != -1)
ss = strLine.Mid(curr+1);
}
else
{
// Skip 1st two vertical bars (|)
if ((curr = strLine.Find('|')) != -1 && (curr = strLine.Find('|', curr+1)) != -1)
ss = strLine.Mid(curr+1);
}
data_.push_back(ss);
}
ff.Close();
int max_keep = 20000;
if (name_.size() > max_keep)
{
CString ss;
ss.Format("Truncated recent file list to most recent %d files", max_keep);
name_.erase(name_.begin(), name_.begin() + (name_.size() - max_keep));
hash_.erase(hash_.begin(), hash_.begin() + (hash_.size() - max_keep));
opened_.erase(opened_.begin(), opened_.begin() + (opened_.size() - max_keep));
open_count_.erase(open_count_.begin(), open_count_.begin() + (open_count_.size() - max_keep));
data_.erase(data_.begin(), data_.begin() + (data_.size() - max_keep));
}
ASSERT(hash_.size() == name_.size());
ASSERT(opened_.size() == name_.size());
ASSERT(open_count_.size() == name_.size());
ASSERT(data_.size() == name_.size());
return true;
}
示例4: Init
//.........这里部分代码省略.........
memcpy(cButtonStrings+lLen, GetResString(IDS_EM_SEARCH), lLen2*sizeof(TCHAR));
lLen += lLen2;
++m_buttoncount;
lLen2 = _tcslen(GetResString(IDS_EM_FILES)) + 1;
memcpy(cButtonStrings+lLen, GetResString(IDS_EM_FILES), lLen2*sizeof(TCHAR));
lLen += lLen2;
++m_buttoncount;
lLen2 = _tcslen(GetResString(IDS_EM_MESSAGES)) + 1;
memcpy(cButtonStrings+lLen, GetResString(IDS_EM_MESSAGES), lLen2*sizeof(TCHAR));
lLen += lLen2;
++m_buttoncount;
lLen2 = _tcslen(GetResString(IDS_IRC)) + 1;
memcpy(cButtonStrings+lLen, GetResString(IDS_IRC), lLen2*sizeof(TCHAR));
lLen += lLen2;
++m_buttoncount;
lLen2 = _tcslen(GetResString(IDS_EM_STATISTIC)) + 1;
memcpy(cButtonStrings+lLen, GetResString(IDS_EM_STATISTIC), lLen2*sizeof(TCHAR));
lLen += lLen2;
++m_buttoncount;
lLen2 = _tcslen(GetResString(IDS_EM_PREFS)) + 1;
memcpy(cButtonStrings+lLen, GetResString(IDS_EM_PREFS), lLen2*sizeof(TCHAR));
lLen += lLen2;
++m_buttoncount;
lLen2 = _tcslen(GetResString(IDS_TOOLS)) + 1;
memcpy(cButtonStrings+lLen, GetResString(IDS_TOOLS), lLen2*sizeof(TCHAR));
lLen += lLen2;
++m_buttoncount;
lLen2 = _tcslen(GetResString(IDS_EM_HELP)) + 1;
memcpy(cButtonStrings+lLen, GetResString(IDS_EM_HELP), lLen2*sizeof(TCHAR));
lLen += lLen2;
++m_buttoncount;
// terminate
memcpy(cButtonStrings+lLen, _T("\0"), sizeof(TCHAR));
AddStrings(cButtonStrings);
// initialize buttons:
for(int i = 0; i < m_buttoncount; i++)
{
TBButtons[i].fsState = TBSTATE_ENABLED;
TBButtons[i].fsStyle = TBSTYLE_CHECKGROUP;
TBButtons[i].idCommand = IDC_TOOLBARBUTTON + i;
TBButtons[i].iString = i;
switch (TBButtons[i].idCommand)
{
case TBBTN_CONNECT:
case TBBTN_OPTIONS:
case TBBTN_TOOLS:
case TBBTN_HELP:
TBButtons[i].fsStyle = TBSTYLE_BUTTON;
break;
}
}
// set button image indices
int iBitmap = 0;
for (int i = 0; i < m_buttoncount; i++)
{
TBButtons[i].iBitmap = iBitmap;
if (TBButtons[i].idCommand == TBBTN_CONNECT) // 'Connect' button has 3 states
iBitmap += 3;
else
iBitmap += 1;
}
TBBUTTON sepButton = {0};
sepButton.idCommand = 0;
sepButton.fsStyle = TBSTYLE_SEP;
sepButton.fsState = TBSTATE_ENABLED;
sepButton.iString = -1;
sepButton.iBitmap = -1;
CString config = thePrefs.GetToolbarSettings();
for (int i = 0; i < config.GetLength(); i += 2)
{
int index = _tstoi(config.Mid(i, 2));
if (index == 99)
{
AddButtons(1, &sepButton);
continue;
}
AddButtons(1, &TBButtons[index]);
}
// recalc toolbar-size
SetAllButtonsStrings();
ChangeTextLabelStyle(thePrefs.GetToolbarLabelSettings(), false, true);
SetAllButtonsWidth(); // then calc and set the button width
AutoSize(); // and finally call the original (but maybe obsolete) function
SaveCurHeight();
}
示例5: OnBnClickedOk
void CDlgAutoRegister::OnBnClickedOk()
{
if (!SaveConfig())
return;
FILE *fp;
if ((fp=fopen(CT2A(m_strFilePath), "r"))==NULL) {
CString strErr;
strErr.Format(_T("启动失败, 无法打开文件%s"), m_strFilePath);
AfxMessageBox(strErr);
return;
}
m_btnStart.EnableWindow(FALSE);
// 读取文件,证件信息
while(1) {
char buf[200] = {0};
if (!fgets(buf, 200, fp))
{
break;
}
CString str = CA2T(buf);
str.Trim();
int nSpace = str.Find(_T(' '));
if (nSpace < 0) continue;
int nSpace2 = str.ReverseFind(_T(' '));
if (nSpace2 < 0) continue;
IDInfo info;
ZeroMemory(&info, sizeof(info));
_tcscpy(info.idNumber, str.Mid(0, nSpace));
_tcscpy(info.name, str.Mid(nSpace2 + 1));
if (_tcslen(info.idNumber) != 18)
{
continue;
}
info.sex = (BYTE)(info.idNumber[16] - _T('0')) % 2;
GXX_TRACE(_T("%s %s"), info.idNumber, info.name);
m_arrayIDs.push_back(info);
}
COleDateTime begTime;
COleDateTime curTime = COleDateTime::GetCurrentTime();
if(m_config.m_startTime < curTime)
{
begTime = curTime;
}
else
{
begTime = m_config.m_startTime;
}
COleDateTime timeTodayEnd;
// 结束时间不是今天
if(m_config.m_startTime.GetDay() != m_config.m_endTime.GetDay())
{
timeTodayEnd.SetDateTime(begTime.GetYear(), begTime.GetMonth(), begTime.GetDay(), 23,59,59);
}
else
{
timeTodayEnd = m_config.m_endTime;
}
int dBeginDaySeconds = GetSeconds(timeTodayEnd, begTime);
double dBeginDayInterval = (double)dBeginDaySeconds / (double)m_config.m_array24Amount[0]; // 第一天单位间隔开户时间
if(0 == m_config.m_array24Amount.size())
return ;
m_arrayTasks.clear();
int iIdIndex = 0;
// 获取第一天的开户数组
std::vector<int> vecRegMoneyBeginDay;
GetRegisterMoneyArr(m_config.m_array24Amount[0], vecRegMoneyBeginDay);
for(size_t i = 1; i < vecRegMoneyBeginDay.size(); i++)
{
TaskNode tn;
tn.idInfo = m_arrayIDs[iIdIndex];
tn.nDeltaSeconds = vecRegMoneyBeginDay[i] * dBeginDayInterval;
tn.nAmount = vecRegMoneyBeginDay[i] * 100;
m_arrayTasks.push_back(tn);
iIdIndex++;
if(iIdIndex >= m_arrayIDs.size())
{
iIdIndex = 0;
}
}
if(2 <= m_config.m_array24Amount.size())
{
// 获取最后一天的开户数组
COleDateTime timeEndDayEnd;
timeEndDayEnd.SetDateTime(m_config.m_endTime.GetYear(), m_config.m_endTime.GetMonth(), m_config.m_endTime.GetDay(), 23,59,59);
int dEndDaySeconds = GetSeconds(timeEndDayEnd, m_config.m_endTime);
//.........这里部分代码省略.........
示例6: OnButtonConnect
// 서버접속처리
void CConnectDlg::OnButtonConnect()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString ip;
if(m_nClient == 0){ // 클라이언트
if(m_strServerName == ""){
MessageBox("서버이름을 확인하세요!");
GetDlgItem(IDC_EDIT_SERVERNAME)->SetFocus();
return;
}
m_ipAddressServerIP.GetWindowText(ip);
if(ip == "0.0.0.0"){
MessageBox("서버IP 를 확인하세요!");
GetDlgItem(IDC_IPADDRESS_SERVERIP)->SetFocus();
return;
}
}
// 서버라도 이부분을 체크
if(m_strUserID == ""){
MessageBox("사용자 아이디를 확인하세요!");
GetDlgItem(IDC_EDIT_USERID)->SetFocus();
return;
}
// 소켓연결(접속처리)
((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_strUserID = m_strUserID;
((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_bIsClient = m_nClient; // 클라이언트인지 서버인지
((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_strSevrIP = ip;
((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_bViewFolder = m_bViewFolder;
((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.InitSock();
if(((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_nErrorCode != 0){ // 접속실패시
AfxMessageBox("접속에 실패했습니다\n다시 접속하십시요!");
return;
}
// 접속할때 환경설정값을 넣어준다
CMainFrame *pMain = (CMainFrame *)AfxGetMainWnd();
pMain->m_cPreferencesValue.DirectoryLoadFile(&(pMain->m_cPreferencesValue.m_strFolderTemp), &(pMain->m_cPreferencesValue.m_strFolderInComing),
&(pMain->m_cPreferencesValue.m_strFolderShare));
pMain->m_cPreferencesValue.DirectoryLoadFile(&(pMain->m_cPreferencesValue.m_strFolderTemp), &(pMain->m_cPreferencesValue.m_strFolderInComing),
&(pMain->m_cPreferencesValue.m_strFolderShare));
pMain->m_cPreferencesValue.DisplayLoadFile(&(pMain->m_cPreferencesValue.m_bDeleteComplete), &(pMain->m_cPreferencesValue.m_nPopupTime),
&(pMain->m_cPreferencesValue.m_bPopupConnect), &(pMain->m_cPreferencesValue.m_bPopupDisconnect), &(pMain->m_cPreferencesValue.m_bPopupCompleteDownload));
// 쓰레드에서 이폴더값을 접근을 못해서 여기서 값을넣어준다
pMain->m_myIOCPSocket.m_strFolderInComing = pMain->m_cPreferencesValue.m_strFolderInComing;
pMain->m_myIOCPSocket.m_strFolderTemp = pMain->m_cPreferencesValue.m_strFolderTemp;
pMain->m_myIOCPSocket.m_strFolderShare = pMain->m_cPreferencesValue.m_strFolderShare;
// 하드의 용량을 알아내서 status 바에 넣는다
CString strUNC;
pMain->m_cPreferencesValue.DirectoryLoadFile(&pMain->m_cPreferencesValue.m_strFolderTemp, &pMain->m_cPreferencesValue.m_strFolderInComing, &pMain->m_cPreferencesValue.m_strFolderShare);
strUNC.Format(pMain->m_cPreferencesValue.m_strFolderInComing.Left(1));
strUNC = strUNC + ":\\";
ULARGE_INTEGER ulAvailable, ulTotal, ulFree;
GetDiskFreeSpaceEx((LPCTSTR)strUNC, &ulAvailable, &ulTotal, &ulFree);
double nFree, nTotal;
if(ulAvailable.QuadPart){
nFree = ulAvailable.LowPart+(double)ulAvailable.HighPart*(double)4294967296;
nTotal = ulTotal.LowPart+(double)ulTotal.HighPart*(double)4294967296;
}
CString strFree;
strFree.Format("%f", nFree);
int cnt = strFree.Find(".", 0);
strFree = strFree.Mid(0, cnt - 7); // 8은 기가바이트로 나타낼경우 소수점이상의 수치에서 9자리가 기가바이트(12.34 GB)
strFree.Format("(%s:)%s.%s GB Free", strUNC.Left(1), strFree.Left(strFree.GetLength() - 2), strFree.Right(2));
pMain->m_wndStatusBar.SetPaneText(1, strFree);
// status 바, upload, download
CString strStatus;
pMain->m_cPreferencesValue.ConnectLoadFile(&pMain->m_cPreferencesValue.m_nDownloadSpeed, &pMain->m_cPreferencesValue.m_nUploadSpeed);
strStatus.Format("%d개 - %d kB/s", 0, pMain->m_cPreferencesValue.m_nUploadSpeed);
pMain->m_wndStatusBar.SetPaneText(2, strStatus);
strStatus.Format("%d개 - %d kB/s", 0, pMain->m_cPreferencesValue.m_nDownloadSpeed);
pMain->m_wndStatusBar.SetPaneText(3, strStatus);
EndDialog(IDYES);
}
示例7: LoadDownloadHosts
CGnuDownloadShell* CGnuTransfers::LoadDownloadHosts(CString FilePath)
{
// Check if file already loaded
for(int i = 0; i < m_DownloadList.size(); i++)
if( m_DownloadList[i]->m_BackupPath.CompareNoCase(FilePath) == 0 )
return NULL;
CStdioFile BackupFile;
CString NextLine;
CString Backup;
if (BackupFile.Open(FilePath, CFile::modeRead))
{
while (BackupFile.ReadString(NextLine))
Backup += NextLine + "\n";
BackupFile.Abort();
}
if(Backup.IsEmpty() || Backup.Find("[Download]") == -1)
return NULL;
int CurrentPos = Backup.Find("[Download]");
CGnuDownloadShell* Download = new CGnuDownloadShell(this);
Download->m_ShellStatus = (CGnuDownloadShell::Status) atoi(GetBackupString("Status", CurrentPos, Backup));
Download->m_Name = GetBackupString("Name", CurrentPos, Backup);
Download->m_FileLength = _atoi64(GetBackupString("FileLength", CurrentPos, Backup));
Download->m_PartSize = atoi(GetBackupString("PartSize", CurrentPos, Backup));
Download->m_OverrideName = GetBackupString("OverrideName", CurrentPos, Backup);
Download->m_OverridePath = GetBackupString("OverridePath", CurrentPos, Backup);
Download->m_PartialPath = GetBackupString("PartialPath", CurrentPos, Backup);
Download->m_BackupPath = FilePath;
Download->m_Sha1Hash = GetBackupString("Sha1Hash", CurrentPos, Backup);
Download->m_Search = GetBackupString("Search", CurrentPos, Backup);
Download->m_AvgSpeed = atoi(GetBackupString("AvgSpeed", CurrentPos, Backup));
Download->m_HashComputed = atoi(GetBackupString("HashComputed", CurrentPos, Backup));
Download->m_HashVerified = atoi(GetBackupString("HashVerified", CurrentPos, Backup));
Download->m_FileMoved = atoi(GetBackupString("FileMoved", CurrentPos, Backup));
Download->m_ReasonDead = GetBackupString("ReasonDead", CurrentPos, Backup);
Download->m_MetaXml = GetBackupString("Meta", CurrentPos, Backup);
Download->m_UseProxy = atoi(GetBackupString("UseProxy", CurrentPos, Backup));
Download->m_DefaultProxy = GetBackupString("DefaultProxy", CurrentPos, Backup);
Download->m_TigerHash = GetBackupString("TigerHash", CurrentPos, Backup);
Download->m_TreeSize = atoi(GetBackupString("TreeSize", CurrentPos, Backup));
Download->m_TreeRes = atoi(GetBackupString("TreeRes", CurrentPos, Backup));
if(Download->m_TreeSize)
{
Download->m_TigerTree = new byte[Download->m_TreeSize];
memset(Download->m_TigerTree, 0, Download->m_TreeSize);
}
if(Download->m_TigerTree)
{
CString Value = GetBackupString("TigerTree", CurrentPos, Backup);
int buffPos = 0;
int dotPos = Value.Find(".");
while(dotPos != -1 && buffPos < Download->m_TreeSize)
{
DecodeBase32( Value.Mid(dotPos - 39, 39), 39, Download->m_TigerTree + buffPos, Download->m_TreeSize - buffPos );
buffPos += 24;
dotPos = Value.Find(".", dotPos + 1);
}
}
Download->Init(Download->m_Name, Download->m_FileLength, HASH_SHA1, Download->m_Sha1Hash);
// Load Host info
if( !Download->m_FileMoved )
for(int i = 0; ; i++)
{
CurrentPos = Backup.Find("[Host " + NumtoStr(i) + "]");
if(CurrentPos == -1)
break;
CurrentPos += 5; // Host in header and value conflict
FileSource nResult;
nResult.Name = GetBackupString("Name", CurrentPos, Backup);
nResult.NameLower = nResult.Name;
nResult.NameLower.MakeLower();
nResult.Sha1Hash = GetBackupString("Sha1Hash", CurrentPos, Backup);
//nResult.BitprintHash = GetBackupString("BitprintHash", CurrentPos, Backup);
nResult.FileIndex = atoi(GetBackupString("FileIndex", CurrentPos, Backup));
nResult.Size = _atoi64(GetBackupString("Size", CurrentPos, Backup));
//.........这里部分代码省略.........
示例8: Refresh
void CBrowseRefsDlg::Refresh(CString selectRef)
{
// m_RefMap.clear();
// g_Git.GetMapHashToFriendName(m_RefMap);
if(!selectRef.IsEmpty())
{
if(selectRef == "HEAD")
{
selectRef = g_Git.GetSymbolicRef(selectRef, false);
}
}
else
{
selectRef = GetSelectedRef(false, true);
}
m_RefTreeCtrl.DeleteAllItems();
m_ListRefLeafs.DeleteAllItems();
m_TreeRoot.m_ShadowTree.clear();
m_TreeRoot.m_csRefName = "refs";
m_TreeRoot.m_hTree=m_RefTreeCtrl.InsertItem(L"Refs",NULL,NULL);
m_RefTreeCtrl.SetItemData(m_TreeRoot.m_hTree,(DWORD_PTR)&m_TreeRoot);
CString allRefs, error;
if (g_Git.Run(L"git for-each-ref --format="
L"%(refname)%04"
L"%(objectname)%04"
L"%(authordate:relative)%04"
L"%(subject)%04"
L"%(authorname)%04"
L"%(authordate:iso8601)%03",
&allRefs, &error, CP_UTF8))
{
CMessageBox::Show(NULL, CString(_T("Get refs failed\n")) + error, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
}
int linePos=0;
CString singleRef;
MAP_STRING_STRING refMap;
//First sort on ref name
while(!(singleRef=allRefs.Tokenize(L"\03",linePos)).IsEmpty())
{
singleRef.TrimLeft(L"\r\n");
int valuePos=0;
CString refName=singleRef.Tokenize(L"\04",valuePos);
if(refName.IsEmpty())
continue;
CString refRest=singleRef.Mid(valuePos);
//Use ref based on m_pickRef_Kind
if(wcsncmp(refName,L"refs/heads",10)==0 && !(m_pickRef_Kind & gPickRef_Head) )
continue; //Skip
if(wcsncmp(refName,L"refs/tags",9)==0 && !(m_pickRef_Kind & gPickRef_Tag) )
continue; //Skip
if(wcsncmp(refName,L"refs/remotes",12)==0 && !(m_pickRef_Kind & gPickRef_Remote) )
continue; //Skip
refMap[refName] = refRest; //Use
}
MAP_STRING_STRING descriptions = GetBranchDescriptions();
//Populate ref tree
for(MAP_STRING_STRING::iterator iterRefMap=refMap.begin();iterRefMap!=refMap.end();++iterRefMap)
{
CShadowTree& treeLeaf=GetTreeNode(iterRefMap->first,NULL,true);
CString values=iterRefMap->second;
values.Replace(L"\04" L"\04",L"\04 \04");//Workaround Tokenize problem (treating 2 tokens as one)
int valuePos=0;
treeLeaf.m_csRefHash= values.Tokenize(L"\04",valuePos); if(valuePos < 0) continue;
treeLeaf.m_csDate= values.Tokenize(L"\04",valuePos); if(valuePos < 0) continue;
treeLeaf.m_csSubject= values.Tokenize(L"\04",valuePos); if(valuePos < 0) continue;
treeLeaf.m_csAuthor= values.Tokenize(L"\04",valuePos); if(valuePos < 0) continue;
treeLeaf.m_csDate_Iso8601= values.Tokenize(L"\04",valuePos);
if (wcsncmp(iterRefMap->first, L"refs/heads", 10) == 0)
treeLeaf.m_csDescription = descriptions[treeLeaf.m_csRefName];
}
// try exact match first
if(selectRef.IsEmpty() || !(SelectRef(selectRef, true) || SelectRef(selectRef, false)))
//Probably not on a branch. Select root node.
m_RefTreeCtrl.Expand(m_TreeRoot.m_hTree,TVE_EXPAND);
}
示例9: DoDeleteRef
bool CBrowseRefsDlg::DoDeleteRef(CString completeRefName, bool bForce)
{
bool bIsRemoteBranch = false;
bool bIsBranch = false;
if (wcsncmp(completeRefName, L"refs/remotes",12)==0) {bIsBranch = true; bIsRemoteBranch = true;}
else if (wcsncmp(completeRefName, L"refs/heads",10)==0) {bIsBranch = true;}
if(bIsBranch)
{
CString branchToDelete = completeRefName.Mid(bIsRemoteBranch ? 13 : 11);
CString cmd;
if(bIsRemoteBranch)
{
CString remoteName, remoteBranchToDelete;
if (SplitRemoteBranchName(branchToDelete, remoteName, remoteBranchToDelete))
return false;
if(CAppUtils::IsSSHPutty())
{
CAppUtils::LaunchPAgent(NULL, &remoteName);
}
cmd.Format(L"git.exe push \"%s\" :refs/heads/%s", remoteName, remoteBranchToDelete);
}
else
cmd.Format(L"git.exe branch -%c -- %s",bForce?L'D':L'd',branchToDelete);
CSysProgressDlg sysProgressDlg;
if (bIsRemoteBranch)
{
sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME)));
sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_DELETING_REMOTE_REFS)));
sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));
sysProgressDlg.SetShowProgressBar(false);
sysProgressDlg.ShowModal(this, true);
}
CString errorMsg;
if(g_Git.Run(cmd,&errorMsg,CP_UTF8)!=0)
{
CMessageBox::Show(m_hWnd, errorMsg, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
if (bIsRemoteBranch)
sysProgressDlg.Stop();
BringWindowToTop();
return false;
}
if (bIsRemoteBranch)
sysProgressDlg.Stop();
BringWindowToTop();
}
else if(wcsncmp(completeRefName,L"refs/tags",9)==0)
{
CString tagToDelete = completeRefName.Mid(10);
CString cmd;
cmd.Format(L"git.exe tag -d -- %s",tagToDelete);
CString errorMsg;
if(g_Git.Run(cmd,&errorMsg,CP_UTF8)!=0)
{
CMessageBox::Show(m_hWnd, errorMsg, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
return false;
}
}
return true;
}
示例10: Execute
bool DropMoveCommand::Execute()
{
CString droppath = parser.GetVal(_T("droptarget"));
CString ProjectTop;
if (!CTGitPath(droppath).HasAdminDir(&ProjectTop))
return FALSE;
if (ProjectTop != g_Git.m_CurrentDir )
{
CMessageBox::Show(NULL,_T("Target and source must be the same git repository"),_T("TortoiseGit"),MB_OK);
return FALSE;
}
if (ProjectTop.GetLength() == 3 && ProjectTop.Mid(1, 2) == _T(":\\")) // working tree root is directly on a drive
droppath = droppath.Right(droppath.GetLength() - ProjectTop.GetLength());
else
droppath = droppath.Right(droppath.GetLength() - ProjectTop.GetLength() - 1);
if (!droppath.IsEmpty())
droppath += L"\\";
unsigned long count = 0;
pathList.RemoveAdminPaths();
CString sNewName;
if ((parser.HasKey(_T("rename")))&&(pathList.GetCount()==1))
{
// ask for a new name of the source item
do
{
CRenameDlg renDlg;
renDlg.m_windowtitle.LoadString(IDS_PROC_MOVERENAME);
renDlg.m_name = pathList[0].GetFileOrDirectoryName();
if (renDlg.DoModal() != IDOK)
{
return FALSE;
}
sNewName = renDlg.m_name;
} while(sNewName.IsEmpty() || PathFileExists(droppath + sNewName));
}
CSysProgressDlg progress;
if (progress.IsValid())
{
progress.SetTitle(IDS_PROC_MOVING);
progress.SetAnimation(IDR_MOVEANI);
progress.SetTime(true);
progress.ShowModeless(CWnd::FromHandle(hwndExplorer));
}
for (int nPath = 0; nPath < pathList.GetCount(); ++nPath)
{
CTGitPath destPath;
if (sNewName.IsEmpty())
destPath = CTGitPath(droppath + pathList[nPath].GetFileOrDirectoryName());
else
destPath = CTGitPath(droppath + sNewName);
if (destPath.Exists())
{
CString name = pathList[nPath].GetFileOrDirectoryName();
if (!sNewName.IsEmpty())
name = sNewName;
progress.Stop();
CRenameDlg dlg;
dlg.m_name = name;
dlg.m_windowtitle.Format(IDS_PROC_NEWNAMEMOVE, (LPCTSTR)name);
if (dlg.DoModal() != IDOK)
{
return FALSE;
}
destPath.SetFromWin(droppath + dlg.m_name);
}
CString cmd,out;
cmd.Format(_T("git.exe mv -- \"%s\" \"%s\""),pathList[nPath].GetGitPathString(),destPath.GetGitPathString());
if (g_Git.Run(cmd, &out, CP_UTF8))
{
if (CMessageBox::Show(hwndExplorer, out, _T("TortoiseGit"), 2, IDI_EXCLAMATION, CString(MAKEINTRESOURCE(IDS_IGNOREBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 1)
{
#if 0
if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath, TRUE))
{
CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
return FALSE; //get out of here
}
CShellUpdater::Instance().AddPathForUpdate(destPath);
#endif
}
else
{
CMessageBox::Show(hwndExplorer, IDS_git_USERCANCELLED, IDS_APPNAME, MB_ICONERROR);
return FALSE; //get out of here
}
}
else
CShellUpdater::Instance().AddPathForUpdate(destPath);
++count;
if (progress.IsValid())
{
progress.FormatPathLine(1, IDS_PROC_MOVINGPROG, pathList[nPath].GetWinPath());
progress.FormatPathLine(2, IDS_PROC_CPYMVPROG2, destPath.GetWinPath());
progress.SetProgress(count, pathList.GetCount());
}
//.........这里部分代码省略.........
示例11: AddButton
/////////////////////////////////////////////////////////////////////////////
// CDocSelector message handlers
BOOL CDocSelector::AddButton( CWnd* wnd, WORD wIcon, LPCTSTR lpszImage )
{
CRect rect;
GetClientRect(&rect);
// Yogesh Jagota
CDocument* pDoc = ((CView *) wnd)->GetDocument();
CString sPath = pDoc->GetPathName();
CString sFileName;
if ( sPath.IsEmpty() )
sPath = pDoc->GetTitle();
// Can be only the filename, like Noname01
if ( sPath.Find( _T('\\') ) != -1 )
sFileName = sPath.Mid( sPath.ReverseFind( _T('\\') ) + 1 );
else
sFileName = sPath;
// If there is no space left to display extra buttons...
int nNewSize = ( ( rect.Width() - DS_MENU_BUTTON_WIDTH )
/ ( m_Buttons.GetSize() + 1 ) ) - DS_SEPERATER_MARGIN;
bool bShowButton = true;
if ( nNewSize <= MINWIDTH )
{
// Check if the menu button is displayed, if not, display it...
m_btnMenuButton.ShowWindow( SW_SHOW );
// Don't show the button...
bShowButton = false;
}
else
m_nDisplayedButtons++;
// End Yogesh Jagota
CSwitcherButton* newbutton = new CSwitcherButton();
// Yogesh Jagota
newbutton->m_AttachedView = wnd;
// I am saving the frame to make life easier in case
// of activation in selection process...
CMDIFrameWnd *pFrame = (CMDIFrameWnd *)AfxGetMainWnd();
CWnd * pWnd = pFrame->GetWindow( GW_CHILD );
ASSERT (pWnd);
pWnd = pWnd->GetWindow( GW_CHILD );
while (pWnd)
{
if ( ((CFrameWnd *)pWnd)->GetActiveView() == (CView*)wnd )
newbutton->m_FrameWnd = (CFrameWnd *)pWnd;
pWnd = pWnd->GetWindow( GW_HWNDNEXT );
}
// Load the icon....
if ( wIcon != 0 ){
newbutton->m_iIcon = ::LoadIcon( AfxGetInstanceHandle(),
MAKEINTRESOURCE( wIcon ) );
}
else if(lpszImage != 0){
HBITMAP hTmp = (HBITMAP)::LoadImage(NULL, lpszImage, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_DEFAULTCOLOR);
if(hTmp){
newbutton->m_hBmp = CEmoticonManager::ReplaceColor(hTmp, RGB(255, 0, 255), ::GetSysColor(COLOR_3DFACE), 0);
DeleteObject(hTmp);
}
else{
newbutton->m_hBmp = NULL;
}
}
// End Yogesh Jagota
newbutton->m_iID = m_Buttons.GetSize();
if (!newbutton->DoCreate(this, m_iNextButtonStart,
rect.top + 3, m_iButtonWidth, DS_HEIGHT - 2,
sFileName, sPath )) // Yogesh Jagota
{
return FALSE;
}
if ( !bShowButton )
newbutton->ShowWindow( SW_HIDE );
m_Buttons.Add((void*)newbutton);
m_iNextButtonStart += m_iButtonWidth + DS_SEPERATER_MARGIN;
if (m_iNextButtonStart - DS_SEPERATER_MARGIN > rect.Width())
{
// this loop makes a neat little animation
int newsize = ((rect.Width() - DS_MENU_BUTTON_WIDTH )
/ (m_Buttons.GetSize())) - DS_SEPERATER_MARGIN;
//.........这里部分代码省略.........
示例12: GetSelectedFunction
CString GetSelectedFunction (CString & strWindowContents, int & nStartChar, int & nEndChar)
{
CString strWord;
if (!strWindowContents.IsEmpty ())
{
// if no selection try to get word under cursor
if (nStartChar == nEndChar)
{
nStartChar--; // go back one so we are not at end of string
// scan backwards from cursor
while (nStartChar >= 0 &&
strWord.GetLength () < 30 &&
(isalnum (strWindowContents [nStartChar]) ||
strWindowContents [nStartChar] == '.' ||
strWindowContents [nStartChar] == '-' ||
strWindowContents [nStartChar] == '_')
)
{
strWord = strWindowContents.Mid (nStartChar, 1) + strWord;
nStartChar--;
}
nStartChar++;
// scan forwards from cursor
while (nEndChar < strWindowContents.GetLength () &&
strWord.GetLength () < 30 &&
(isalnum (strWindowContents [nEndChar]) ||
strWindowContents [nEndChar] == '.' ||
strWindowContents [nEndChar] == '-' ||
strWindowContents [nEndChar] == '_')
)
{
strWord = strWord + strWindowContents.Mid (nEndChar, 1);
nEndChar++;
}
strWord.MakeLower ();
strWord.Replace ("world.", ""); // if they said world.note, just take note
} // end of no selection
else
{
if (nEndChar > nStartChar &&
(nEndChar - nStartChar) < 30)
{
// skip spaces, changing the selection while we do it (for replacement purposes)
while (isspace (strWindowContents [nStartChar]) &&
nEndChar > nStartChar)
nStartChar++;
// ditto for trailing spaces
while (isspace (strWindowContents [nEndChar - 1]) &&
(nEndChar - 1) > nStartChar)
nEndChar--;
strWindowContents = strWindowContents.Mid (nStartChar, nEndChar - nStartChar);
strWindowContents.MakeLower ();
strWindowContents.Replace ("@world.", ""); // ditto for @world.Note (Ruby)
strWindowContents.Replace ("world.", ""); // if they said world.note, just take note
strWindowContents.Replace ("$world->", ""); // ditto for $world->note (Perl)
bool bFunction = true;
for (int i = 0; i < strWindowContents.GetLength (); i++)
if (!isalnum (strWindowContents [i]))
bFunction = false;
if (bFunction)
strWord = strWindowContents;
}
} // we have a selection
} // end of some selection supplied
return strWord;
} // end of GetSelectedFunction
示例13: DoDataExchange
//.........这里部分代码省略.........
::UMessageBox(strMsg);
DDX_Text(pDX, IDC_TIMER_LABEL, m_strLabel);
pDX->Fail();
}
} // end of checking each Timer
if (!m_strLabel.IsEmpty ()) // we can have blank labels
{
// check label is valid
if (CheckLabel (m_strLabel))
{
::TMessageBox ("The label must start with a letter and consist of letters"
", numbers or the underscore character.");
DDX_Text(pDX, IDC_TIMER_LABEL, m_strLabel);
pDX->Fail();
}
} // end of having non-blank label
if (m_strVariable.IsEmpty ()) // we can have blank variables
{
if (m_iSendTo == eSendToVariable)
{
::TMessageBox("When sending to a variable you must specify a variable name. ",
MB_ICONSTOP);
DDX_Text(pDX, IDC_VARIABLE, m_strVariable);
pDX->Fail();
}
}
else
{
// check variable name is valid
if (CheckLabel (m_strVariable))
{
::TMessageBox("The variable name must start with a letter and consist of letters"
", numbers or the underscore character.");
DDX_Text(pDX, IDC_VARIABLE, m_strVariable);
pDX->Fail();
}
} // end of having non-blank variable
// check for speed walking OK, unless they are substituting
if (m_iSendTo == eSendToSpeedwalk)
{
CString strResult = m_pDoc->DoEvaluateSpeedwalk (m_strContents);
if (!strResult.IsEmpty ())
{
if (strResult [0] == '*') // error in speedwalk string?
{
::UMessageBox (strResult.Mid (1)); // already translated, I think
DDX_Text(pDX, IDC_TIMER_CONTENTS, m_strContents);
pDX->Fail();
} // end of error message
} // end of non-empty speedwalk
} // end of speed walking wanted
if(m_strContents.IsEmpty () && m_strProcedure.IsEmpty ())
{
::TMessageBox("The timer contents cannot be blank unless you specify a script subroutine.");
DDX_Text(pDX, IDC_TIMER_CONTENTS, m_strContents);
pDX->Fail();
} // end of contents being blank
if (!m_strProcedure.IsEmpty ()) // blank procedure is OK
{
// check procedure is valid
if (CheckLabel (m_strProcedure, true))
{
::TMessageBox("The script subroutine name must start with a letter and consist of letters"
", numbers or the underscore character.");
DDX_Text(pDX, IDC_SCRIPT_NAME, m_strProcedure);
pDX->Fail();
}
} // end of having non-blank procedure
} // end of saving and validating
else
{
if (App.m_bFixedFontForEditing)
{
FixFont(m_font, m_ctlContents, App.m_strFixedPitchFont, App.m_iFixedPitchFontSize, FW_NORMAL, DEFAULT_CHARSET);
}
}
}
示例14: OnCbnEditchangeUrlcombo
void CCloneDlg::OnCbnEditchangeUrlcombo()
{
// do not update member variables from UI while saving
if (m_bSaving || m_bExactPath)
return;
this->UpdateData();
CString url;
m_URLCombo.GetWindowText(url);
url.Trim();
if(m_OldURL == url )
return;
m_OldURL=url;
//if(url.IsEmpty())
// return;
CString old;
old=m_ModuleName;
url.Replace(L'\\', L'/');
// add compatibility for Google Code git urls
url.TrimRight(L"/");
int start = url.ReverseFind(L'/');
if(start<0)
{
start = url.ReverseFind(L':');
if(start <0)
start = url.ReverseFind(L'@');
if(start<0)
start = 0;
}
CString temp;
temp=url.Mid(start+1);
temp=temp.MakeLower();
// we've to check whether the URL ends with .git (instead of using the first .git)
int end = CStringUtils::EndsWith(temp, L".git") ? (temp.GetLength() - 4) : temp.GetLength();
//CString modulename;
m_ModuleName=url.Mid(start+1,end);
start = m_Directory.ReverseFind(L'\\');
if(start <0 )
start = m_Directory.ReverseFind(L'/');
if(start <0 )
start =0;
int dirstart=m_Directory.Find(old,start);
if(dirstart>=0 && (dirstart+old.GetLength() == m_Directory.GetLength()) )
m_Directory=m_Directory.Left(dirstart);
m_Directory.TrimRight(L"\\/");
m_Directory += L'\\';
m_Directory += m_ModuleName;
// check if URL starts with http://, https:// or git:// in those cases loading putty keys is only
// asking for passwords for keys that are never used
if (url.Find(L"http://", 0) >= 0 || url.Find(L"https://", 0) >= 0 || url.Find(L"git://", 0) >= 0)
m_bAutoloadPuttyKeyFile = false;
else
m_bAutoloadPuttyKeyFile = m_regUseSSHKey && CAppUtils::IsSSHPutty();
this->UpdateData(FALSE);
}
示例15: put_XDataXMLConfigFile
//////////////////////////////////////////////////////////////////////////
//简要描述 : 设置扩展属性配置文件
//输入参数 :
//返 回 值 :
//
//
//修改日志 :
//////////////////////////////////////////////////////////////////////////
STDMETHODIMP CDwgWriter::put_XDataXMLConfigFile(BSTR sXMLFile)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if (sXMLFile == NULL) return S_OK;
CString sXml = sXMLFile;
if (sXml.IsEmpty()) return S_OK;
m_XDataCfgs.RemoveAll();
try
{
CXMLFile xmlfile;
xmlfile.load(sXml);
MSXML2::IXMLDOMNodePtr pNode;
MSXML2::IXMLDOMNodePtr pExtAttrNode = NULL;
xmlfile.GetNode("LAYERS", pNode);
if (pNode == NULL)
{
//AfxMessageBox("XML配置文件不正确,请检查。");
m_dwgWriter.WriteLog("XML配置文件不正确,请检查。");
return S_FALSE;
}
pNode = pNode->GetfirstChild();
if (pNode == NULL)
{
//AfxMessageBox("XML配置文件不正确,请检查。");
m_dwgWriter.WriteLog("XML配置文件不正确,请检查。");
return S_FALSE;
}
CComBSTR bsNodeName;
CComBSTR bsExtAttrs;
CString sLayerName;
CString sRegAppName;
CString sExtAttrs;
while (pNode != NULL)
{
//得到图层名
pNode->get_nodeName(&bsNodeName);
sLayerName = bsNodeName;
//去掉前面的_前缀,解决数字开头的节点问题
CString sSign = "";
sSign = sLayerName.Mid(0, 1);
if (sSign.CompareNoCase("_") == 0)
{
sLayerName = sLayerName.Mid(1);
}
XDataAttrLists* pExtAttrs = new XDataAttrLists();
//得到图层下的注册应用名
if (pNode->hasChildNodes())
{
pExtAttrNode = pNode->GetfirstChild();
while (pExtAttrNode != NULL)
{
pExtAttrNode->get_nodeName(&bsNodeName);
sRegAppName = bsNodeName;
//去掉前面的_前缀,解决数字开头的节点问题
sSign = sRegAppName.Mid(0, 1);
if (sSign.CompareNoCase("_") == 0)
{
sRegAppName = sRegAppName.Mid(1);
}
pExtAttrNode->get_text(&bsExtAttrs);
sExtAttrs = bsExtAttrs;
CStringList* pAttrLst = new CStringList();
//解析注册应用名下的属性字段名称
CString sAttr;
int iPos = sExtAttrs.Find(',');
while (iPos > 0)
{
sAttr = sExtAttrs.Mid(0, iPos);
sExtAttrs = sExtAttrs.Mid(iPos + 1);
if (!sAttr.IsEmpty())
{
pAttrLst->AddTail(sAttr);
}
iPos = sExtAttrs.Find(',');
}
if (iPos == -1)
{
if (!sExtAttrs.IsEmpty())
{
pAttrLst->AddTail(sExtAttrs);
}
}
pExtAttrs->SetAt(sRegAppName, pAttrLst);
//得到下一个注册应用名的配置
//.........这里部分代码省略.........