本文整理汇总了C++中Segment::GetSerializedLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Segment::GetSerializedLength方法的具体用法?C++ Segment::GetSerializedLength怎么用?C++ Segment::GetSerializedLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segment
的用法示例。
在下文中一共展示了Segment::GetSerializedLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSerializedLength
int HexDoc::GetSerializedLength(THSIZE nOffset, THSIZE nSize)
{
int sSize = sizeof(SerialDataHeader);
std::vector<DataSource*> sources;
std::vector<DataSource*>::const_iterator iter;
THSIZE segStart;
Segment *ts = GetSegment(nOffset, &segStart);
THSIZE segOffset = nOffset - segStart;
while (ts != NULL && segStart < nOffset + nSize)
{
int nSource = 0;
if (ts->pDS)
{
iter = std::find(sources.begin(), sources.end(), ts->pDS);
if (iter == sources.end())
{
sources.push_back(ts->pDS);
sSize += ts->pDS->GetSerializedLength();
}
}
THSIZE copySize = min(nSize, ts->size - segOffset);
sSize += ts->GetSerializedLength(segOffset, copySize);
segStart += ts->size;
segOffset = 0;
ts = ts->next;
}
return sSize;
}
示例2: Serialize
void HexDoc::Serialize(THSIZE nOffset, THSIZE nSize, uint8 *target)
{
SerialDataHeader &hdr = *(SerialDataHeader*)target;
int sOffset = sizeof(hdr);
hdr.endianMode = NATIVE_ENDIAN_MODE;
hdr.nSegments = 0;
hdr.nSources = 0;
std::vector<DataSource*> sources;
std::vector<DataSource*>::const_iterator iter;
THSIZE segStart;
Segment *ts = GetSegment(nOffset, &segStart);
THSIZE segOffset = nOffset - segStart;
while (ts != NULL && segStart < nOffset + nSize)
{
hdr.nSegments++;
int nSource = 0;
if (ts->pDS)
{
iter = std::find(sources.begin(), sources.end(), ts->pDS);
if (iter == sources.end())
{
sources.push_back(ts->pDS);
hdr.nSources++;
}
}
THSIZE copySize = min(nOffset + nSize, segStart + ts->size) - (segStart + segOffset);
int sSize = ts->GetSerializedLength(segOffset, copySize);
ts->Serialize(segOffset, copySize, nSource, target + sOffset);
sOffset += sSize;
segStart += ts->size;
segOffset = 0;
ts = ts->next;
}
for (iter = sources.begin(); iter < sources.end(); iter++)
{
DataSource *pDS = *iter;
int sSize = pDS->GetSerializedLength();
pDS->Serialize(target + sOffset);
sOffset += sSize;
}
}