本文整理汇总了C++中CStringArray::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ CStringArray::Add方法的具体用法?C++ CStringArray::Add怎么用?C++ CStringArray::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStringArray
的用法示例。
在下文中一共展示了CStringArray::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAllUserSpeech
CStringArray* DataBase::GetAllUserSpeech(CString UserId)
{
//连接数据库
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
//设置SELECT语句
_bstr_t vSQL;
vSQL = _T("SELECT * FROM SpeechLib WHERE UserId ='" + UserId + "'");
//执行SELETE语句
_RecordsetPtr m_pRecordset;
m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
CStringArray* wavArray = new CStringArray;
CString wavname;
//返回各列的值
while (!m_pRecordset->adoEOF)
{
wavname = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("WavName");// wait to check the correctness!
wavArray->Add(wavname);
m_pRecordset->MoveNext();
}
//断开与数据库的连接
m_AdoConn.ExitConnect();
return wavArray;
}
示例2: Export
void CDiagramEntityContainer::Export( CStringArray& stra, UINT format ) const
/* ============================================================
Function : CDiagramEntityContainer::Export
Description : Exports all objects to format format.
Return : void
Parameters : CStringArray& stra - CStingArray that
will be filled with
data on return.
UINT format - Format to save to.
Usage : Call to export the contents of the container
to a CStringArray. Export will - of course -
have to be defined for the derived objects.
============================================================*/
{
int max = GetSize();
for( int t = 0 ; t < max ; t++ )
{
CDiagramEntity* obj = GetAt( t );
stra.Add( obj->Export( format ) );
}
}
示例3: ReadCircuitSum
bool ReadTxt::ReadCircuitSum(CStdioFile *s_file,CString cmdstr,CStringArray &rstr)
{
CString str,strs;
bool rtrn = false;
int i=0;
s_file->SeekToBegin();
while(s_file->ReadString(str))
if(str.Find(cmdstr) > -1)
{
rtrn = true;
break;
}
if(rtrn)
{
for(i = 0;i < 3;i++)
{
s_file->ReadString(str);
strs += str;
}
int token = 0;
for( i = 0; i < 14; i++)
{
strs.Tokenize(" ",token);
str = strs.Tokenize(" ",token);
str.Replace(",",""); //去掉逗号
rstr.Add(str);
}
}
return rtrn;
}
示例4: SendAsCombinedMail
int CSendMailPatch::SendAsCombinedMail(const CTGitPathList &list, CGitProgressList* instance)
{
ASSERT(instance);
CStringArray attachments;
CString body;
for (int i = 0; i < list.GetCount(); ++i)
{
CPatch patch;
if (patch.Parse((CString&)list[i].GetWinPathString(), !m_bAttachment))
{
instance->ReportError(_T("Could not open/parse ") + list[i].GetWinPathString());
return -2;
}
if (m_bAttachment)
{
attachments.Add(list[i].GetWinPathString());
body += patch.m_Subject;
body += _T("\r\n");
}
else
{
try
{
CGit::StringAppend(&body, (BYTE*)(LPCSTR)patch.m_Body, CP_UTF8, patch.m_Body.GetLength());
}
catch (CMemoryException *)
{
instance->ReportError(_T("Out of memory. Could not parse ") + list[i].GetWinPathString());
return -2;
}
}
}
return SendMail(CTGitPath(), instance, m_sSenderName, m_sSenderMail, m_sTo, m_sCC, m_sSubject, body, attachments);
}
示例5: SendAsCombinedMail
int CSendMailCombineable::SendAsCombinedMail(CTGitPathList &list, CGitProgressList * instance)
{
ASSERT(instance);
CStringArray attachments;
CString body;
for (int i = 0; i < list.GetCount(); ++i)
{
if (m_bAttachment)
{
attachments.Add(list[i].GetWinPathString());
}
else
{
CString filename(list[i].GetWinPathString());
body += filename + _T(":\n");
if (GetFileContents(filename, body))
{
instance->ReportError(_T("Could not open ") + filename);
return -2;
}
body += _T("\n");
}
}
return SendMail(CTGitPath(), instance, m_sSenderName, m_sSenderMail, m_sTo, m_sCC, m_sSubject, body, attachments);
}
示例6: parseMacs
/* Parse MAC concatened into String Array */
UINT CDeviceid::parseMacs( CString &csMac, CStringArray &csMacArray)
{
UINT uNumber = 0,
uIndex = 0;
CString csOneMac;
try
{
csMacArray.RemoveAll();
while (csMac.Mid( uIndex, MAC_STRING_LENGTH).GetLength() > 0)
{
csOneMac = csMac.Mid( uIndex, MAC_STRING_LENGTH);
if (csOneMac.GetLength() == MAC_STRING_LENGTH)
{
// This a MAC address
csMacArray.Add( csOneMac);
uNumber ++;
}
uIndex += MAC_STRING_LENGTH;
}
return uNumber;
}
catch (CException *pEx)
{
pEx->Delete();
return 0;
}
}
示例7: GetSkinList
void CSkinManager::GetSkinList(CStringArray &skins)
{
CFileFind finder;
CString dir = CMyUtility::GetCurDir();
CString strSkins;
strSkins.Format(_T("%s\\skins\\*.*"), dir);
BOOL bFind = finder.FindFile(strSkins);
if(!bFind)
return;
while(bFind)
{
bFind = finder.FindNextFile();
if(finder.IsDots())
continue;
if(finder.IsDirectory())
{
skins.Add(finder.GetFileName());
continue;
}
}
finder.Close();
}
示例8:
int CRegKey2::GetNames(CStringArray& aNames, BOOL bSubKey) const
{
ASSERT(m_hKey);
aNames.RemoveAll();
DWORD nKey = 0;
TCHAR szName[1024];
LONG lResult = ERROR_SUCCESS;
while (lResult == ERROR_SUCCESS)
{
// Inside the loop because RegEnumValue will change it
DWORD nNameLen = 1024;
if (bSubKey)
lResult = ::RegEnumKey(m_hKey, nKey, szName, nNameLen);
else
lResult = ::RegEnumValue(m_hKey, nKey, szName, &nNameLen, NULL, NULL, NULL, NULL);
// we have a valid key name
if (lResult == ERROR_SUCCESS)
aNames.Add(szName);
nKey++; // next
}
return aNames.GetSize();
}
示例9: GetIPs
int CIpAddressesDlg::GetIPs( CStringArray &arrIPS )
{
BOOL bRet = TRUE;
char name[255];
int i=0;
PHOSTENT hostinfo;
//first, clear the list
arrIPS.RemoveAll();
//get the host name
if( gethostname ( name, sizeof(name)) == 0)
{
// get the host info
if((hostinfo = gethostbyname(name)) != NULL)
{
// now, loop until the address list = null
while( hostinfo->h_addr_list[i] != NULL )
{
//get the IP address
char *ip_addr = inet_ntoa (*(struct in_addr *)
hostinfo->h_addr_list[i]);
//add it to the array
arrIPS.Add(CString(ip_addr));
//increment the counter
i++;
}
}
}
//return the array count
return int(arrIPS.GetSize());
}
示例10: GetAllUserInfo
CStringArray* DataBase::GetAllUserInfo(CString Attribute)
{
//连接数据库
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
//设置SELECT语句
_bstr_t vSQL;
vSQL = _T("SELECT * FROM UserInfo");
//执行SELETE语句
_RecordsetPtr m_pRecordset;
m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
CStringArray* itemArray = new CStringArray;
CString item;
//返回各列的值
while (!m_pRecordset->adoEOF)
{
item = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect((const _variant_t)Attribute);// wait to check the correctness!
itemArray->Add(item);
m_pRecordset->MoveNext();
}
//断开与数据库的连接
m_AdoConn.ExitConnect();
return itemArray;
}
示例11: AddDBF
int CDbfFile::AddDBF(CStringArray* psDBFAttList,CString sDelimiter)
{
DBFHandle hDBF;
int kk;
CFileFind ShapeFile;
CString sTmp;
CStringArray *psDBFAtt;
psDBFAtt = new CStringArray();
if (_bInit)
{
_bInit = false;
ValidateDBF();
DBFSetColumn(&_psDBFAttList);
}
// Open/Create the database.
hDBF = DBFOpen("r+b" );
if( hDBF == NULL )
{
printf("DBFOpen failed: %s\n", _szDBFName);
return 1;
}
for (kk = 0; kk < psDBFAttList->GetSize(); kk++)
{
psDBFAtt->RemoveAll();
sTmp = psDBFAttList->GetAt(kk);
while (sTmp.Find(sDelimiter) != -1)
{
psDBFAtt->Add(sTmp.Left(sTmp.Find(sDelimiter)));
sTmp.Delete(0, (sTmp.Find(sDelimiter) + 1));
}
if (!sTmp.IsEmpty())
psDBFAtt->Add(sTmp);
DBFAddRecord(hDBF, psDBFAtt);
}
psDBFAtt->RemoveAll();
/* -------------------------------------------------------------------- */
/* Close and cleanup. */
/* -------------------------------------------------------------------- */
DBFClose( hDBF );
delete(psDBFAtt);
return 0;
}
示例12: ReadIni
BOOL INISetting::ReadIni(CString sFileName, CString sAppName, CStringArray& asKeyName, CStringArray& asKeyValue)
{
BOOL bReturn = TRUE;
CFileStatus fs;
if (CFile::GetStatus(sFileName,fs) == FALSE)
return false;
if (m_pBuffer != NULL)
delete [] m_pBuffer;
m_pBuffer=new char[int(fs.m_size*1.5)];
if (m_pBuffer == NULL)
{
CString sPrompt;
sPrompt.Format("ini文件分配内存错!\n[%d]字节",int(fs.m_size*1.2));
AfxMessageBox(sPrompt);
}
CStringArray saValue;
if (GetPrivateProfileSection(sAppName,m_pBuffer,256,sFileName) && Get00Strings(m_pBuffer,saValue))
{
for (int i=0;i<saValue.GetSize();i++)
{
CString sValue = saValue[i];
int n= sValue.ReverseFind('=');
if(n!=-1)
{
asKeyName.Add(sValue.Left(n));
asKeyValue.Add(sValue.Mid(n+1));
}
}
}
if ((asKeyName.GetSize() == 0) || (asKeyName.GetSize() != asKeyValue.GetSize()))
bReturn = FALSE;
return bReturn;
}
示例13: OnCreate
int CSimpleReportView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CXTPReportView::OnCreate(lpCreateStruct) == -1)
return -1;
CSimpleReport& m_list = (CSimpleReport&)GetReportCtrl();
// 컬럼 셋업
CXTPReportColumn* p = m_list.ColSet(0, "first", 100);
m_list.ColSet(1, "second", 200);
m_list.ColSet(2, "third", 200);
m_list.SetFontText("Arial", 16);
m_list.SetFontHeader("맑은 명조", 16);
// 콤보 박스
CStringArray s;
s.Add("hello");
s.Add("world");
s.Add("mind");
s.Add("boggling");
m_list.ColSetComboData(p, s);
// 레코드 삽입
for (int i = 0; i < 20; i++) {
CXTPReportRecord* pRec = m_list.RowAdd();
m_list.ColAdd(pRec, "hello");
m_list.ColAdd(pRec, i * 10.0, "%5.2f");
m_list.ColAdd(pRec, i, "%3.0f");
}
// 컬러/볼드 세팅
m_list.ColSetColor(0, 2, RGB(255, 255, 255), RGB(0, 200, 0));
m_list.ColSetBold(0, 1);
m_list.RowSetBold(1);
m_list.RowSetColor(5, RGB(255, 255, 255), RGB(200, 0, 0));
m_list.Populate();
return 0;
}
示例14: Wrap
//--------------------------------------------------------------------------------
bool CWordWrap::Wrap(CStringArray& sReturn, LPCTSTR pText, int nWidth, LPCTSTR pBreakChars)
{
// dont do anything if we dont have to
if(pText == NULL || nWidth < 1 || *pText == 0)
return false;
CString sText(pText);
if(sText.GetLength() < nWidth)
return false;
CString sBreak;
if(pBreakChars == NULL)
sBreak = " \t";
else
sBreak = pBreakChars;
int nBegin = 0;
int nEnd = nWidth;
if(sText[nEnd] == 0)
return false;
for(;;)
{
// find a place to break
while(sBreak.Find(sText[nEnd]) == -1 && nEnd > nBegin)
nEnd--;
// no place to break nicely so force a break
if(nBegin == nEnd)
nEnd = nBegin + nWidth;
// copy the string
sReturn.Add(sText.Mid(nBegin, nEnd - nBegin));
// advance indexes
nBegin = nEnd;
nEnd += nWidth;
// are we at the end?
if(nEnd >= sText.GetLength())
{
if(nBegin < sText.GetLength())
sReturn.Add(sText.Mid(nBegin));
break;
}
}
return true;
}
示例15: bAddString
BOOL COutWnd::bAddString(CStringArray& omStrArray)
{
BOOL bReturn = TRUE;
INT nTotalCount = (COMMANINT)omStrArray.GetSize();
INT nReturnAdd = 0;
// vResetContent();
MDIActivate();
omStrArray.Add(" ");
INT nCount; //nCount declared outside
for( nCount=0; nCount<nTotalCount; nCount++)
{
nReturnAdd = m_omListBox.AddString(omStrArray.GetAt(nCount));
if(nReturnAdd<0)
{
bReturn = FALSE;
}
}
// Set horizontal extent of the list box to max string availaable
// so that user can scroll
CSize sz(0,0);
CString omStrText = "";
CDC* pDC = m_omListBox.GetDC();
//Check for valid dc and then set the horizontal extent
if( pDC != nullptr)
{
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
//Select the new font object to calculte the extent
//because font is set for window not for CDC
CFont* pOldFont = pDC->SelectObject(&m_omNewFont);
INT nTotalItem = m_omListBox.GetCount();
INT nDx = 0;
for (nCount = 0; nCount < nTotalItem; nCount++)
{
m_omListBox.GetText( nCount, omStrText );
// remove space
omStrText.TrimRight();
sz = pDC->GetTextExtent(omStrText);
//Add avg char width for avoiding any wrapping up
sz.cx += tm.tmAveCharWidth;
if (sz.cx > nDx)
{
nDx = sz.cx;
}
}
//release the new font
pDC->SelectObject(pOldFont);
m_omListBox.ReleaseDC(pDC);
// Set the horizontal extent so every character of all strings
// can be scrolled to.
m_omListBox.SetHorizontalExtent(nDx);
}
else
{
bReturn = FALSE;
}
return bReturn;
}