本文整理汇总了C++中STRING_VECTOR::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ STRING_VECTOR::push_back方法的具体用法?C++ STRING_VECTOR::push_back怎么用?C++ STRING_VECTOR::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STRING_VECTOR
的用法示例。
在下文中一共展示了STRING_VECTOR::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRemoteList
int CGit::GetRemoteList(STRING_VECTOR &list)
{
if (this->m_IsUseLibGit2)
{
git_repository *repo = NULL;
CStringA gitdir = CUnicodeUtils::GetMulti(CTGitPath(m_CurrentDir).GetGitPathString(), CP_UTF8);
if (git_repository_open(&repo, gitdir.GetBuffer()))
{
gitdir.ReleaseBuffer();
return -1;
}
gitdir.ReleaseBuffer();
git_strarray remotes;
if (git_remote_list(&remotes, repo))
{
git_repository_free(repo);
return -1;
}
for (size_t i = 0; i < remotes.count; i++)
{
CStringA remote(remotes.strings[i]);
list.push_back(CUnicodeUtils::GetUnicode(remote));
}
git_strarray_free(&remotes);
git_repository_free(repo);
std::sort(list.begin(), list.end());
return 0;
}
else
{
int ret;
CString cmd, output;
cmd=_T("git.exe remote");
ret = Run(cmd, &output, NULL, CP_UTF8);
if(!ret)
{
int pos=0;
CString one;
while( pos>=0 )
{
one=output.Tokenize(_T("\n"),pos);
if (!one.IsEmpty())
list.push_back(one);
}
}
return ret;
}
}
示例2: GetBranchList
int CGit::GetBranchList(STRING_VECTOR &list,int *current,BRANCH_TYPE type)
{
int ret;
CString cmd, output, cur;
cmd = _T("git.exe branch --no-color");
if((type&BRANCH_ALL) == BRANCH_ALL)
cmd += _T(" -a");
else if(type&BRANCH_REMOTE)
cmd += _T(" -r");
ret = Run(cmd, &output, NULL, CP_UTF8);
if(!ret)
{
int pos=0;
CString one;
while( pos>=0 )
{
one=output.Tokenize(_T("\n"),pos);
one.Trim(L" \r\n\t");
if(one.Find(L" -> ") >= 0 || one.IsEmpty())
continue; // skip something like: refs/origin/HEAD -> refs/origin/master
if(one[0] == _T('*'))
{
one = one.Mid(2);
cur = one;
}
if (one != _T("(no branch)"))
list.push_back(one);
}
}
if(type & BRANCH_FETCH_HEAD && !DerefFetchHead().IsEmpty())
list.push_back(L"FETCH_HEAD");
std::sort(list.begin(), list.end(), LogicalComparePredicate);
if (current && cur != _T("(no branch)"))
{
for (unsigned int i = 0; i < list.size(); i++)
{
if (list[i] == cur)
{
*current = i;
break;
}
}
}
return ret;
}
示例3: GetRefList
int CGit::GetRefList(STRING_VECTOR &list)
{
int ret;
if(this->m_IsUseGitDLL)
{
CAutoLocker lock(g_Git.m_critGitDllSec);
ret = git_for_each_ref_in("",addto_list_each_ref_fn, &list);
std::sort(list.begin(), list.end(), LogicalComparePredicate);
}
else
{
CString cmd, output;
cmd=_T("git.exe show-ref -d");
ret = Run(cmd, &output, NULL, CP_UTF8);
if(!ret)
{
int pos=0;
CString one;
while( pos>=0 )
{
one=output.Tokenize(_T("\n"),pos);
int start=one.Find(_T(" "),0);
if(start>0)
{
CString name;
name=one.Right(one.GetLength()-start-1);
list.push_back(name);
}
}
std::sort(list.begin(), list.end(), LogicalComparePredicate);
}
}
return ret;
}
示例4: Refresh
void CRefLogDlg::Refresh()
{
STRING_VECTOR list;
list.push_back(_T("HEAD"));
if (g_Git.GetRefList(list))
MessageBox(g_Git.GetGitLastErr(_T("Could not get all refs.")), _T("TortoiseGit"), MB_ICONERROR);
m_ChooseRef.SetList(list);
if (m_CurrentBranch.IsEmpty())
{
m_CurrentBranch.Format(_T("refs/heads/%s"), (LPCTSTR)g_Git.GetCurrentBranch());
m_ChooseRef.SetCurSel(0); /* Choose HEAD */
}
else
{
bool found = false;
for (int i = 0; i < (int)list.size(); ++i)
{
if(list[i] == m_CurrentBranch)
{
m_ChooseRef.SetCurSel(i);
found = true;
break;
}
}
if (!found)
m_ChooseRef.SetCurSel(0);
}
m_RefList.m_RevCache.clear();
OnCbnSelchangeRef();
}
示例5: AddHelper
static void AddHelper(CComboBox& combobox, STRING_VECTOR& availableHelpers, const CString& helper, const CString& selected = L"")
{
availableHelpers.push_back(helper);
int idx = combobox.AddString(helper);
if (selected == helper)
combobox.SetCurSel(idx);
}
示例6: OnBnClickedOk
void CDeleteRemoteTagDlg::OnBnClickedOk()
{
if (m_ctrlTags.GetSelectedCount() > 1)
{
CString msg;
msg.Format(IDS_PROC_DELETENREFS, m_ctrlTags.GetSelectedCount());
if (CMessageBox::Show(m_hWnd, msg, _T("TortoiseGit"), 2, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_DELETEBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 2)
return;
}
else // GetSelectedCount() is 1, otherwise the button is disabled
{
POSITION pos = m_ctrlTags.GetFirstSelectedItemPosition();
CString msg;
msg.Format(IDS_PROC_DELETEBRANCHTAG, (LPCTSTR)m_taglist[(m_ctrlTags.GetNextSelectedItem(pos))]);
if (CMessageBox::Show(m_hWnd, msg, _T("TortoiseGit"), 2, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_DELETEBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 2)
return;
}
STRING_VECTOR list;
POSITION pos = m_ctrlTags.GetFirstSelectedItemPosition();
int index;
while ((index = m_ctrlTags.GetNextSelectedItem(pos)) >= 0)
list.push_back(_T("refs/tags/") + m_taglist[index]);
CSysProgressDlg sysProgressDlg;
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);
if (g_Git.DeleteRemoteRefs(m_sRemote, list))
CMessageBox::Show(m_hWnd, g_Git.GetGitLastErr(_T("Could not delete remote ref."), CGit::GIT_CMD_PUSH), _T("TortoiseGit"), MB_OK | MB_ICONERROR);
sysProgressDlg.Stop();
BringWindowToTop();
Refresh();
}
示例7: GetRemoteList
int CGit::GetRemoteList(STRING_VECTOR &list)
{
int ret;
CString cmd,output;
cmd=_T("git.exe config --get-regexp remote.*.url");
ret=g_Git.Run(cmd,&output,CP_UTF8);
if(!ret)
{
int pos=0;
CString one;
while( pos>=0 )
{
one=output.Tokenize(_T("\n"),pos);
int start=one.Find(_T("."),0);
if(start>0)
{
CString url;
url=one.Right(one.GetLength()-start-1);
one=url;
one=one.Left(one.Find(_T("."),0));
list.push_back(one);
}
}
}
return ret;
}
示例8: GetBranchList
int CGit::GetBranchList(STRING_VECTOR &list,int *current,BRANCH_TYPE type)
{
int ret;
CString cmd,output;
cmd=_T("git.exe branch");
if(type==(BRANCH_LOCAL|BRANCH_REMOTE))
cmd+=_T(" -a");
else if(type==BRANCH_REMOTE)
cmd+=_T(" -r");
int i=0;
ret=g_Git.Run(cmd,&output,CP_UTF8);
if(!ret)
{
int pos=0;
CString one;
while( pos>=0 )
{
one=output.Tokenize(_T("\n"),pos);
list.push_back(one.Right(one.GetLength()-2));
if(one[0] == _T('*'))
if(current)
*current=i;
i++;
}
}
return ret;
}
示例9: Refresh
void CSubmoduleUpdateDlg::Refresh()
{
while (m_PathListBox.GetCount() > 0)
m_PathListBox.DeleteString(m_PathListBox.GetCount() - 1);
CString WorkingDir = g_Git.m_CurrentDir;
WorkingDir.Replace(_T(':'), _T('_'));
m_regPath = CRegString(CString(_T("Software\\TortoiseGit\\History\\SubmoduleUpdatePath\\") + WorkingDir));
CString path = m_regPath;
STRING_VECTOR emptylist;
STRING_VECTOR list;
GetSubmodulePathList(list, m_bWholeProject ? emptylist : m_PathFilterList);
STRING_VECTOR selected;
if (m_PathList.empty())
{
int pos = 0;
while (pos >= 0)
{
CString part = path.Tokenize(_T("|"), pos);
if (!part.IsEmpty())
selected.push_back(part);
}
}
else
{
for (size_t i = 0; i < m_PathList.size(); ++i)
selected.push_back(m_PathList[i]);
}
for (size_t i = 0; i < list.size(); ++i)
{
m_PathListBox.AddString(list[i]);
if (selected.size() == 0)
m_PathListBox.SetSel((int)i);
else
{
for (size_t j = 0; j < selected.size(); ++j)
{
if (selected[j] == list[i])
m_PathListBox.SetSel((int)i);
}
}
}
OnLbnSelchangeListPath();
}
示例10: addto_list_each_ref_fn
int addto_list_each_ref_fn(const char *refname, const unsigned char * /*sha1*/, int /*flags*/, void *cb_data)
{
STRING_VECTOR *list = (STRING_VECTOR*)cb_data;
CString str;
g_Git.StringAppend(&str, (BYTE*)refname, CP_UTF8);
list->push_back(str);
return 0;
}
示例11: Refresh
void CPushDlg::Refresh()
{
CString WorkingDir=g_Git.m_CurrentDir;
WorkingDir.Replace(_T(':'),_T('_'));
CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PushRemote\\")+WorkingDir));
m_RemoteReg = remote;
int sel = -1;
STRING_VECTOR list;
m_Remote.Reset();
list.push_back(CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES)));
if(!g_Git.GetRemoteList(list))
{
if (list.size() <= 2)
list.erase(list.begin());
for (unsigned int i = 0; i < list.size(); ++i)
{
m_Remote.AddString(list[i]);
if(list[i] == remote)
sel = i;
}
}
// if the last selected remote was "- All -" and "- All -" is still in the list -> select it
if (list.size() > 1 && remote == CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES)))
sel = 0;
m_Remote.SetCurSel(sel);
int current=0;
list.clear();
m_BranchSource.Reset();
m_BranchSource.AddString(_T(" ")); // empty string does not work, for removal of remote branches/tags
m_BranchSource.SetMaxHistoryItems(0x7FFFFFFF);
if(!g_Git.GetBranchList(list,¤t))
{
for (unsigned int i = 0; i < list.size(); ++i)
m_BranchSource.AddString(list[i]);
++current; // shift for " "
}
if (wcsncmp(m_BranchSourceName, _T("refs/"), 5) == 0)
m_BranchSourceName = m_BranchSourceName.Mid(5);
if (wcsncmp(m_BranchSourceName, _T("heads/"), 6) == 0)
{
m_BranchSourceName = m_BranchSourceName.Mid(6);
m_BranchSource.SetCurSel(m_BranchSource.FindStringExact(-1, m_BranchSourceName));
}
else if (wcsncmp(m_BranchSourceName, _T("remotes/"), 8) == 0)
m_BranchSource.SetCurSel(m_BranchSource.FindStringExact(-1, m_BranchSourceName));
else
m_BranchSource.SetCurSel(current);
GetRemoteBranch(m_BranchSource.GetString());
this->GetDlgItem(IDOK)->EnableWindow(m_BranchSource.GetCount() != 0);
}
示例12: SubmoduleCallback
static int SubmoduleCallback(git_submodule *sm, const char * /*name*/, void *payload)
{
STRING_VECTOR *list = *(STRING_VECTOR **)payload;
STRING_VECTOR *prefixList = *((STRING_VECTOR **)payload + 1);
CString path = CUnicodeUtils::GetUnicode(git_submodule_path(sm));
if (prefixList->empty())
list->push_back(path);
else
{
for (size_t i = 0; i < prefixList->size(); ++i)
{
CString prefix = prefixList->at(i) + L'/';
if (CStringUtils::StartsWith(path, prefix))
list->push_back(path);
}
}
return 0;
}
示例13: DoDeleteRef
bool CBrowseRefsDlg::DoDeleteRef(CString completeRefName)
{
bool bIsRemoteBranch = false;
bool bIsBranch = false;
if (wcsncmp(completeRefName, L"refs/remotes/",13) == 0) {bIsBranch = true; bIsRemoteBranch = true;}
else if (wcsncmp(completeRefName, L"refs/heads/",11) == 0) {bIsBranch = true;}
if (bIsRemoteBranch)
{
CString branchToDelete = completeRefName.Mid(13);
CString remoteName, remoteBranchToDelete;
if (SplitRemoteBranchName(branchToDelete, remoteName, remoteBranchToDelete))
return false;
if (CAppUtils::IsSSHPutty())
CAppUtils::LaunchPAgent(NULL, &remoteName);
CSysProgressDlg sysProgressDlg;
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);
STRING_VECTOR list;
list.push_back(_T("refs/heads/") + remoteBranchToDelete);
if (g_Git.DeleteRemoteRefs(remoteName, list))
{
CMessageBox::Show(m_hWnd, g_Git.GetGitLastErr(_T("Could not delete remote ref."), CGit::GIT_CMD_PUSH), _T("TortoiseGit"), MB_OK | MB_ICONERROR);
sysProgressDlg.Stop();
BringWindowToTop();
return false;
}
sysProgressDlg.Stop();
BringWindowToTop();
}
else if (bIsBranch)
{
if (g_Git.DeleteRef(completeRefName))
{
CMessageBox::Show(m_hWnd, g_Git.GetGitLastErr(L"Could not delete reference.", CGit::GIT_CMD_DELETETAGBRANCH), _T("TortoiseGit"), MB_OK | MB_ICONERROR);
return false;
}
}
else if (wcsncmp(completeRefName, L"refs/tags/", 10) == 0)
{
if (g_Git.DeleteRef(completeRefName))
{
CMessageBox::Show(m_hWnd, g_Git.GetGitLastErr(L"Could not delete reference.", CGit::GIT_CMD_DELETETAGBRANCH), _T("TortoiseGit"), MB_OK | MB_ICONERROR);
return false;
}
}
return true;
}
示例14: SubmoduleCallback
static int SubmoduleCallback(git_submodule *sm, const char * /*name*/, void *payload)
{
STRING_VECTOR *list = *(STRING_VECTOR **)payload;
STRING_VECTOR *prefixList = *((STRING_VECTOR **)payload + 1);
CString path = CUnicodeUtils::GetUnicode(git_submodule_path(sm));
if (prefixList->empty())
{
list->push_back(path);
}
else
{
for (size_t i = 0; i < prefixList->size(); ++i)
{
CString prefix = prefixList->at(i) + _T("/");
if (path.Left(prefix.GetLength()) == prefix)
list->push_back(path);
}
}
return 0;
}
示例15: uniqueMergeLists
static void uniqueMergeLists(STRING_VECTOR& list, const STRING_VECTOR& listToMerge)
{
std::map<CString, int> map;
for (CString entry : list)
map[entry] = 1;
for (CString entry : listToMerge)
{
if (map.find(entry) == map.end())
list.push_back(entry);
}
}