本文整理汇总了C++中CArray::Insert方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::Insert方法的具体用法?C++ CArray::Insert怎么用?C++ CArray::Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::Insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addRecordsToIndex
/*-----------------------------------------------CIRexxApp::addRecordsToIndex-+
| |
+----------------------------------------------------------------------------*/
void CIRexxApp::addRecordsToIndex(CArray<ScriptRecord *> & records, CDatabase * db, UInt16 cat, char * dbi)
{
UInt16 index = 0;
UInt32 rowId;
MemHandle hMem;
Int16 recordPosition = 0;
CHash<unsigned int, Int16> recordPositionBySegmentId;
ScriptRecord * scriptRecord;
if (db == 0) { return; }
while ((hMem = db->QueryNextInCategory(index, cat))) {
db->GetRecordUniqueID(index, rowId);
UInt32 size = MemHandleSize(hMem);
const char * pMem = (char *)MemHandleLock(hMem);
/*
| FORMAT:
| %6s #segment.<no>#\ndate() time() <id>\nTitle: <tit>\nCategory: <cat>
*/
char * scanner;
if ( // if it's segmented, combine the segments
(scanner = StrStr(pMem, "#segment.")) &&
(scanner = StrChr(scanner + 1, '#'))
) {
char segmentNoAsString[5];
memcpy(segmentNoAsString, scanner - 4, 4);
segmentNoAsString[4] = '\0';
int segmentNo = StrAToI(segmentNoAsString);
++scanner;
int peditHeaderSize = size - (scanner - pMem);
if (peditHeaderSize > ScriptRecord::MAX_PEDITHEADERLEN) {
peditHeaderSize = ScriptRecord::MAX_PEDITHEADERLEN;
}
RexxString header(scanner, peditHeaderSize);
RexxString segmentIdAsString;
segmentIdAsString.wordAt(header, 3);
unsigned int segmentId = hex2uint(
(char const *)segmentIdAsString, segmentIdAsString.length()
);
int titWordNo = RexxString("Title:").wordpos(header, 1);
int catWordNo = RexxString("Category:").wordpos(header, 1);
RexxString title;
title.subword(header, titWordNo + 1, catWordNo - (titWordNo + 1));
// create the script record
Int16 * psegmentedRecordPosition = (Int16 *)recordPositionBySegmentId.Lookup(segmentId);
// if this segment has already been encountered, then create a chain of segments
if (psegmentedRecordPosition) {
ScriptRecord * sr = records[*psegmentedRecordPosition];
sr->m_indexes.Insert(sr->m_indexes.GetCount(), index);
sr->m_segments.Insert(sr->m_segments.GetCount(), segmentNo);
// otherwise just add it
}else {
scriptRecord = new ScriptRecord(db, dbi, title, index, segmentNo);
recordPositionBySegmentId.SetAt(segmentId, recordPosition);
records.Insert(recordPosition++, scriptRecord);
}
}else { // otherwise just add it
unsigned int i;
for (i=0; pMem[i] && pMem[i] != linefeedChr && i < ScriptRecord::MAX_TITLELEN; ++i) {
;
}
char * t = new char[i + 1];
memcpy(t, pMem, i);
t[i] = '\0';
RexxString title(t);
scriptRecord = new ScriptRecord(db, dbi, title, index);
delete [] t;
records.Insert(recordPosition++, scriptRecord);
}
MemHandleUnlock(hMem);
++index;
}
}