本文整理汇总了C++中IOCallback::setFilePointer方法的典型用法代码示例。如果您正苦于以下问题:C++ IOCallback::setFilePointer方法的具体用法?C++ IOCallback::setFilePointer怎么用?C++ IOCallback::setFilePointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOCallback
的用法示例。
在下文中一共展示了IOCallback::setFilePointer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadData
filepos_t EbmlString::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (GetSize() == 0) {
Value = "";
SetValueIsSet();
} else {
char *Buffer = new char[GetSize() + 1];
if (Buffer == NULL) {
// unable to store the data, skip it
input.setFilePointer(GetSize(), seek_current);
} else {
input.readFully(Buffer, GetSize());
if (Buffer[GetSize()-1] != '\0') {
Buffer[GetSize()] = '\0';
}
Value = Buffer;
delete [] Buffer;
SetValueIsSet();
}
}
}
return GetSize();
}
示例2: ReadData
uint64 EbmlString::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (Size == 0) {
Value = "";
bValueIsSet = true;
} else {
char *Buffer = new char[Size + 1];
if (Buffer == NULL) {
// unable to store the data, skip it
input.setFilePointer(Size, seek_current);
} else {
input.readFully(Buffer, Size);
if (Buffer[Size-1] != '\0') {
Buffer[Size] = '\0';
}
Value = Buffer;
delete [] Buffer;
bValueIsSet = true;
}
}
}
return Size;
}
示例3: Overwrite
uint64 EbmlVoid::Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward, bool bWithDefault)
{
// EltToVoid.UpdateSize(bWithDefault);
if (EltToVoid.GetElementPosition() == 0) {
// this element has never been written
return 0;
}
if (EltToVoid.GetSize() + EltToVoid.HeadSize() <2) {
// the element can't be written here !
return 0;
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(EltToVoid.GetElementPosition());
// compute the size of the voided data based on the original one
SetSize(EltToVoid.GetSize() + EltToVoid.HeadSize() - 1); // 1 for the ID
SetSize(GetSize() - CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()));
// make sure we handle even the strange cases
//uint32 A1 = GetSize() + HeadSize();
//uint32 A2 = EltToVoid.GetSize() + EltToVoid.HeadSize();
if (GetSize() + HeadSize() != EltToVoid.GetSize() + EltToVoid.HeadSize()) {
SetSize(GetSize()-1);
SetSizeLength(CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()) + 1);
}
if (GetSize() != 0) {
RenderHead(output, false, bWithDefault); // the rest of the data is not rewritten
}
if (ComeBackAfterward) {
output.setFilePointer(CurrentPosition);
}
return EltToVoid.GetSize() + EltToVoid.HeadSize();
}
示例4: ReplaceWith
uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bWithDefault)
{
EltToReplaceWith.UpdateSize(bWithDefault);
if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) {
// the element can't be written here !
return INVALID_FILEPOS_T;
}
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() == 1) {
// there is not enough space to put a filling element
return INVALID_FILEPOS_T;
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(GetElementPosition());
EltToReplaceWith.Render(output, bWithDefault);
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() > 1) {
// fill the rest with another void element
EbmlVoid aTmp;
aTmp.SetSize_(HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() - 1); // 1 is the length of the Void ID
int HeadBefore = aTmp.HeadSize();
aTmp.SetSize_(aTmp.GetSize() - CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()));
int HeadAfter = aTmp.HeadSize();
if (HeadBefore != HeadAfter) {
aTmp.SetSizeLength(CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()) - (HeadAfter - HeadBefore));
}
aTmp.RenderHead(output, false, bWithDefault); // the rest of the data is not rewritten
}
if (ComeBackAfterward) {
output.setFilePointer(CurrentPosition);
}
return GetSize() + HeadSize();
}
示例5: GetSize
filepos_t EbmlCrc32::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary *Buffer = new binary[GetSize()];
if (Buffer == NULL) {
// impossible to read, skip it
input.setFilePointer(GetSize(), seek_current);
} else {
input.readFully(Buffer, GetSize());
memcpy((void *)&m_crc_final, Buffer, 4);
delete [] Buffer;
SetValueIsSet();
}
}
return GetSize();
}
示例6: ReadData
/*!
\todo this code is very suspicious !
*/
filepos_t EbmlMaster::ReadData(IOCallback & input, ScopeMode ReadFully)
{
input.setFilePointer(GetSize(), seek_current);
return GetSize();
}