本文整理汇总了C++中CArray::ElementAt方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::ElementAt方法的具体用法?C++ CArray::ElementAt怎么用?C++ CArray::ElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::ElementAt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessStatisticsRequest
void CMMServer::ProcessStatisticsRequest(CMMData* data, CMMSocket* sender){
uint16 nWidth = data->ReadShort();
CArray<UpDown>* rawData = theApp.webserver->GetPointsForWeb();
int nRawDataSize = rawData->GetSize();
int nCompressEvery = (nRawDataSize > nWidth) ? nRawDataSize / nWidth : 1;
int nPos = (nRawDataSize > nWidth) ? (nRawDataSize % nWidth) : 0;
int nAddUp, nAddDown, nAddCon, i;
ASSERT (nPos + nCompressEvery * nWidth == nRawDataSize || (nPos == 0 && nRawDataSize < nWidth));
CMMPacket* packet = new CMMPacket(MMP_STATISTICSANS);
packet->WriteShort((uint16)((nRawDataSize-nPos)*thePrefs.GetTrafficOMeterInterval()));
packet->WriteShort((uint16)(min(nWidth, nRawDataSize)));
while (nPos < nRawDataSize){
nAddUp = nAddDown = nAddCon = 0;
for (i = 0; i != nCompressEvery; i++){
if (nPos >= nRawDataSize){
ASSERT ( false );
break;
}
else{
nAddUp += (int) (rawData->ElementAt(nPos).upload * 1024);
nAddDown += (int) (rawData->ElementAt(nPos).download * 1024);
nAddCon += rawData->ElementAt(nPos).connections;
}
nPos++;
}
packet->WriteInt((uint32)ROUND(nAddUp/i));
packet->WriteInt((uint32)ROUND(nAddDown/i));
packet->WriteShort((uint16)ROUND(nAddCon/i));
}
ASSERT ( nPos == nRawDataSize );
sender->SendPacket(packet);
}
示例2: IsStrInStrAarry
bool MusicUtils::IsStrInStrAarry(CString e,CString str)
{
CArray<CString,CString&> arrays;
SpliteCString(str,arrays,_T(","));
for (int i=0;i<arrays.GetSize();i++)
{
if (arrays.ElementAt(i)==e)
return true;
}
return false;
}
示例3: GetExportFunctionInfo
u32 CHookFunction_i::GetExportFunctionInfo(CArray<EXPORT_FUN_INFO, EXPORT_FUN_INFO&>& InfoArray,
const char* pszDllFile)
{
if(!pszDllFile)
{
return 0;
}
PLOADED_IMAGE pImage = ::ImageLoad((char*)pszDllFile, NULL);
if(!pImage)
{
return 0;
}
DWORD dwBase = (DWORD)pImage->MappedAddress;
PIMAGE_SECTION_HEADER pSections = (PIMAGE_SECTION_HEADER)((DWORD)pImage->FileHeader + sizeof(IMAGE_NT_HEADERS));
PIMAGE_EXPORT_DIRECTORY pExportDir = (PIMAGE_EXPORT_DIRECTORY)(RVA2RawAdr(pSections, pImage->FileHeader->OptionalHeader.DataDirectory[0].VirtualAddress) + dwBase);
InfoArray.RemoveAll();
EXPORT_FUN_INFO info;
DWORD* pFunOffsetAdr = (DWORD*)(RVA2RawAdr(pSections, pExportDir->AddressOfFunctions) + dwBase);
for(DWORD i = 0; i < pExportDir->NumberOfFunctions; i++)
{
info.dwOffset = 0;
info.strFunName = "";
info.dwOrdinal = 0;
info.dwOffset = *(pFunOffsetAdr + i);
info.dwOrdinal = i + 1;
InfoArray.Add(info);
}
DWORD* pFunNamesAdr = (DWORD*)(RVA2RawAdr(pSections, pExportDir->AddressOfNames) + dwBase);
WORD* pFunNamesOrdinalAdr = (WORD*)(RVA2RawAdr(pSections, pExportDir->AddressOfNameOrdinals) + dwBase);
char* pName = NULL;
for(i = 0; i < pExportDir->NumberOfNames; i++)
{
pName = (char*)(RVA2RawAdr(pSections, *(pFunNamesAdr+i)) + dwBase);
int idx = *(pFunNamesOrdinalAdr+i);
if(idx < InfoArray.GetSize())
{
EXPORT_FUN_INFO& tmpInfo = InfoArray.ElementAt(idx);
tmpInfo.strFunName = pName;
}
}
ImageUnload(pImage);
return InfoArray.GetSize();
}
示例4: ViewExportFunctionInfo
// CString strDllFile(_T("E:\\DevTools\\VC6\\VC6.0.Full.G\\VC98\\Bin\\C1.DLL"));
u32 CHookFunction_i::ViewExportFunctionInfo(LPCTSTR pszDllFile, LPCTSTR pszOutFile, bool bAutoOpenFile) // _T("[email protected]")
{
u32 ret = ERR_OK_I;
CArray<EXPORT_FUN_INFO, EXPORT_FUN_INFO&> InfoArray;
#ifdef HAVE_UNICODE_I
CHAR file[MAX_PATH] = {0, };
CStringUtl::wcs2mbsz(file, wcslen(pszDllFile), pszDllFile);
if(GetExportFunctionInfo(InfoArray, file) > 0)
#else
if(GetExportFunctionInfo(InfoArray, pszDllFile) > 0)
#endif
{
CFile fileTmp;
if(fileTmp.Open(pszOutFile, CFile::modeCreate | CFile::modeReadWrite))
{
CString strTmp;
strTmp.Format("%s Export Information:", pszDllFile);
fileTmp.Write(strTmp, strTmp.GetLength());
for (int i=0;i < InfoArray.GetSize();i++)
{
EXPORT_FUN_INFO& r = InfoArray.ElementAt(i); // return the reference.
if(r.dwOffset == 0)
continue;
strTmp.Format("\r\n%3d 0x%p %s", r.dwOrdinal, r.dwOffset, r.strFunName);
fileTmp.Write(strTmp, strTmp.GetLength());
}
fileTmp.Close();
if(bAutoOpenFile)
{
ShellExecute(NULL, "open", "notepad.exe", pszOutFile, NULL, SW_NORMAL);
}
}
}
return ret;
}
示例5: if
bool CTobCompiler::CompilePass2(F_ErrorHandler ErrorHandler)
{
bool haserr = false;
int i, j, m, n = m_exp.GetSize();
int pos, val, temp, factor;
int len = m_bin.GetSize();
CString err;
m_line = 0;
for(i = 0; i < n; ++i)
{
val = 0;
factor = 1;
const SExpInfo* ti = m_exp.ElementAt(i);
m = ti->m_item.GetSize();
pos = ti->m_pos;
for(j = 0; j < m; ++j)
{
CString& str = ti->m_item[j];
if(str == "+")
factor = 1;
else if(str == "-")
factor = -1;
else if(str == "@")
{
val += (pos + m_bit_i/8) * factor;
factor = 1;
}
else
{
char c = str[0];
if(c == '$')
{
str.Delete(0);
c = str[0];
}
if(c >= '0' && c <= '9')
val += atoi(str) * factor;
else
{
if(m_label.Lookup(str, temp))
val += temp * factor;
else
{
m_err.Format("not found token '%s' at line %d", (LPCTSTR)str, ti->m_line);
haserr = true;
if(!ErrorHandler(GetErrorString(err))) return false;
}
}
factor = 1;
}
}
if(pos + m_bit_i/8 > len)
{
m_err.Format("internal compiler error %d > %d", pos + m_bit_i/8, len);
haserr = true;
ErrorHandler(GetErrorString(err));
return false;
}
if(m_bit_i < 32 && val >= (1<<m_bit_i))
{
m_err.Format("overflow address (%p) when setting '.bit %u'", val, m_bit_i);
haserr = true;
if(!ErrorHandler(GetErrorString(err))) return false;
}
m_bin[pos ] = val & 255;
if(m_bit_i >= 16) m_bin[pos + 1] = (val >> 8) & 255;
if(m_bit_i >= 24) m_bin[pos + 2] = (val >> 16) & 255;
if(m_bit_i >= 32) m_bin[pos + 3] = val >> 24;
}
return !haserr;
}
示例6: FilesEqual
//.........这里部分代码省略.........
strMask = TempStr.Mid(nPos, nNextPos-nPos);
strMask.TrimLeft();
strMask.TrimRight();
if ( !m_CaseSensitive ) strMask.MakeUpper();
if (strMask != "") Words1.Add(strMask);
nPos = nNextPos + 1;
}
//
TempStr = FileInfo2.GetBaseName();
nPos = 0;
nNextPos = 0;
// add file masks
while (nPos < TempStr.GetLength())
{
nNextPos = TempStr.Find( _T(" ") ,nPos);
if (nNextPos == -1) nNextPos = TempStr.GetLength();
strMask = TempStr.Mid(nPos, nNextPos-nPos);
strMask.TrimLeft();
strMask.TrimRight();
if ( !m_CaseSensitive ) strMask.MakeUpper();
if (strMask != "") Words2.Add(strMask);
nPos = nNextPos + 1;
}
//
// remove duplicate words
for (x = Words1.GetSize()-1; x > 0 ; x--)
{
for (y = x-1; y >= 0; y--)
{
if ( Words1.ElementAt(x) == Words1.ElementAt(y) )
{
Words1.RemoveAt(x);
break;
}
}
}
//
// remove duplicate words
for (x = Words2.GetSize()-1; x > 0 ; x--)
{
for (y = x-1; y >= 0; y--)
{
if ( Words2.ElementAt(x) == Words2.ElementAt(y) )
{
Words2.RemoveAt(x);
break;
}
}
}
//
IgnoreWords.Add("-");
IgnoreWords.Add("A");
IgnoreWords.Add("THE");
IgnoreWords.Add("I");
IgnoreWords.Add("AT");
IgnoreWords.Add("OF");
IgnoreWords.Add("ON");
bool deleted;