本文整理汇总了C++中Stream::GetPos方法的典型用法代码示例。如果您正苦于以下问题:C++ Stream::GetPos方法的具体用法?C++ Stream::GetPos怎么用?C++ Stream::GetPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::GetPos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Serialize
void DockCont::Serialize(Stream& s)
{
int ctrl = 'D';
int cont = 'C';
const Vector<DockableCtrl *> &dcs = base->GetDockableCtrls();
if (s.IsStoring()) {
if (GetCount() == 1 && IsDockCont(tabbar.Get(0)))
return ContCast(tabbar.Get(0))->Serialize(s);
int cnt = GetCount();
s / cont / cnt;
for (int i = GetCount() - 1; i >= 0; i--) {
if (IsDockCont(tabbar.Get(i)))
ContCast(tabbar.Get(i))->Serialize(s);
else {
DockableCtrl *dc = DockCast(tabbar.Get(i));
int ix = base->FindDocker(dc);
s / ctrl / ix;
}
}
int cursor = tabbar.GetCursor();
int groupix = tabbar.GetGroup();
s / cursor / groupix;
}
else {
int cnt;
int type;
s / type / cnt;
ASSERT(type == cont);
for (int i = 0; i < cnt; i++) {
int64 pos = s.GetPos();
s / type;
if (type == cont) {
s.Seek(pos);
DockCont *dc = base->CreateContainer();
dc->Serialize(s);
base->DockContainerAsTab(*this, *dc, true);
}
else if (type == ctrl) {
int ix;
s / ix;
if (ix >= 0 && ix <= dcs.GetCount())
Add(*dcs[ix]);
}
else
ASSERT(false);
}
int cursor, groupix;
s / cursor / groupix;
tabbar.SetGroup(groupix);
tabbar.SetCursor(min(tabbar.GetCount()-1, cursor));
TabSelected();
}
}
示例2: PutOctalString
static void PutOctalString(Stream& out, const char *b, const char *e, bool split = false)
{
out.Put('\"');
int64 start = out.GetPos();
while(b < e) {
if(split && out.GetPos() >= start + 200u) {
out.Put("\"\r\n\t\"");
start = out.GetPos();
}
if((byte)*b >= ' ' && *b != '\x7F' && *b != '\xFF') {
if(*b == '\\' || *b == '\"' || *b == '\'')
out.Put('\\');
out.Put(*b++);
}
else if(IsDigit(b[1]))
out.Put(Sprintf("\\%03o", (byte)*b++));
else
out.Put(Sprintf("\\%o", (byte)*b++));
}
out.Put('\"');
}
示例3: FindSubChunkOffset
int32 Chunk::FindSubChunkOffset(std::string name)
{
// Reverse the name
name = std::string(name.rbegin(), name.rend());
if (name.size() != 4)
return -1;
Stream* stream = GetStream();
uint32 matched = 0;
while (stream->GetPos() < stream->GetSize())
{
char b = stream->Read<char>();
if (b != name[matched])
matched = 0;
else
++matched;
if (matched == 4)
return stream->GetPos() - 4;
}
return -1;
}