本文整理汇总了C++中IOCallback类的典型用法代码示例。如果您正苦于以下问题:C++ IOCallback类的具体用法?C++ IOCallback怎么用?C++ IOCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IOCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadInternalHead
uint64 KaxInternalBlock::ReadInternalHead(IOCallback & input)
{
binary Buffer[5], *cursor = Buffer;
uint64 Result = input.read(cursor, 4);
if (Result != 4)
return Result;
// update internal values
TrackNumber = *cursor++;
if ((TrackNumber & 0x80) == 0) {
// there is extra data
if ((TrackNumber & 0x40) == 0) {
// We don't support track numbers that large !
return Result;
}
Result += input.read(&Buffer[4], 1);
TrackNumber = (TrackNumber & 0x3F) << 8;
TrackNumber += *cursor++;
} else {
TrackNumber &= 0x7F;
}
big_int16 b16;
b16.Eval(cursor);
assert(ParentCluster != NULL);
Timecode = ParentCluster->GetBlockGlobalTimecode(int16(b16));
bLocalTimecodeUsed = false;
cursor += 2;
return Result;
}
示例2: 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();
}
示例3: 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;
}
示例4: RenderData
uint32 EbmlVoid::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
// write dummy data by 4KB chunks
static binary DummyBuf[4*1024];
uint64 SizeToWrite = Size;
while (SizeToWrite > 4*1024)
{
output.writeFully(DummyBuf, 4*1024);
SizeToWrite -= 4*1024;
}
output.writeFully(DummyBuf, SizeToWrite);
return Size;
}
示例5: RenderData
filepos_t EbmlVoid::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{
// write dummy data by 4KB chunks
static binary DummyBuf[4*1024];
uint64 SizeToWrite = GetSize();
while (SizeToWrite > 4*1024)
{
output.writeFully(DummyBuf, 4*1024);
SizeToWrite -= 4*1024;
}
output.writeFully(DummyBuf, SizeToWrite);
return GetSize();
}
示例6: pb
/*!
\todo remove the hack for possible endianess pb (test on little & big endian)
*/
uint64 EbmlFloat::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary Buffer[20];
assert(Size <= 20);
input.readFully(Buffer, Size);
if (Size == 4) {
big_int32 TmpRead;
TmpRead.Eval(Buffer);
int32 tmpp = int32(TmpRead);
float val;
memcpy(&val, &tmpp, 4);
Value = val;
bValueIsSet = true;
} else if (Size == 8) {
big_int64 TmpRead;
TmpRead.Eval(Buffer);
int64 tmpp = int64(TmpRead);
double val;
memcpy(&val, &tmpp, 8);
Value = val;
bValueIsSet = true;
}
}
return Size;
}
示例7: assert
/*!
\todo handle exception on errors
\todo write all the Mandatory elements in the Context, otherwise assert
*/
filepos_t EbmlMaster::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{
filepos_t Result = 0;
size_t Index;
if (!bForceRender) {
assert(CheckMandatory());
}
if (!bChecksumUsed) { // old school
for (Index = 0; Index < ElementList.size(); Index++) {
if (!bWithDefault && (ElementList[Index])->IsDefaultValue())
continue;
Result += (ElementList[Index])->Render(output, bWithDefault, false ,bForceRender);
}
} else { // new school
MemIOCallback TmpBuf(GetSize() - 6);
for (Index = 0; Index < ElementList.size(); Index++) {
if (!bWithDefault && (ElementList[Index])->IsDefaultValue())
continue;
(ElementList[Index])->Render(TmpBuf, bWithDefault, false ,bForceRender);
}
Checksum.FillCRC32(TmpBuf.GetDataBuffer(), TmpBuf.GetDataBufferSize());
Result += Checksum.Render(output, true, false ,bForceRender);
output.writeFully(TmpBuf.GetDataBuffer(), TmpBuf.GetDataBufferSize());
Result += TmpBuf.GetDataBufferSize();
}
return Result;
}
示例8: pb
/*!
\todo remove the hack for possible endianess pb (test on little & big endian)
*/
filepos_t EbmlFloat::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA) {
binary Buffer[20];
assert(GetSize() <= 20);
input.readFully(Buffer, GetSize());
if (GetSize() == 4) {
big_int32 TmpRead;
TmpRead.Eval(Buffer);
int32 tmpp = int32(TmpRead);
float val;
memcpy(&val, &tmpp, 4);
Value = val;
SetValueIsSet();
} else if (GetSize() == 8) {
big_int64 TmpRead;
TmpRead.Eval(Buffer);
int64 tmpp = int64(TmpRead);
double val;
memcpy(&val, &tmpp, 8);
Value = val;
SetValueIsSet();
}
}
return GetSize();
}
示例9: 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();
}
示例10: write
uint32 MemIOCallback::write(IOCallback & IOToRead, size_t Size)
{
if (dataBufferMemorySize < dataBufferPos + Size) {
//We need more memory!
dataBuffer = (binary *)realloc((void *)dataBuffer, dataBufferPos + Size);
}
IOToRead.readFully(&dataBuffer[dataBufferPos], Size);
dataBufferTotalSize = Size;
return Size;
}
示例11: RenderData
/*!
\todo handle exception on errors
\todo handle 10 bits precision
*/
uint32 EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
assert(Size == 4 || Size == 8);
if (Size == 4) {
float val = Value;
int Tmp;
memcpy(&Tmp, &val, 4);
big_int32 TmpToWrite(Tmp);
output.writeFully(&TmpToWrite.endian(), Size);
} else if (Size == 8) {
double val = Value;
int64 Tmp;
memcpy(&Tmp, &val, 8);
big_int64 TmpToWrite(Tmp);
output.writeFully(&TmpToWrite.endian(), Size);
}
return Size;
}
示例12: RenderData
/*!
\todo handle exception on errors
*/
filepos_t EbmlString::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
{
filepos_t Result;
output.writeFully(Value.c_str(), Value.length());
Result = Value.length();
if (Result < GetDefaultSize()) {
// pad the rest with 0
binary *Pad = new (std::nothrow) binary[GetDefaultSize() - Result];
if (Pad == NULL) {
return Result;
}
memset(Pad, 0x00, GetDefaultSize() - Result);
output.writeFully(Pad, GetDefaultSize() - Result);
Result = GetDefaultSize();
delete [] Pad;
}
return Result;
}
示例13: RenderData
filepos_t EbmlDate::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
{
if (GetSize() != 0) {
assert(GetSize() == 8);
big_int64 b64(myDate);
output.writeFully(&b64.endian(),GetSize());
}
return GetSize();
}
示例14: RenderData
/*!
\todo handle exception on errors
\todo handle 10 bits precision
*/
filepos_t EbmlFloat::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
{
assert(GetSize() == 4 || GetSize() == 8);
if (GetSize() == 4) {
float val = Value;
int Tmp;
memcpy(&Tmp, &val, 4);
big_int32 TmpToWrite(Tmp);
output.writeFully(&TmpToWrite.endian(), GetSize());
} else if (GetSize() == 8) {
double val = Value;
int64 Tmp;
memcpy(&Tmp, &val, 8);
big_int64 TmpToWrite(Tmp);
output.writeFully(&TmpToWrite.endian(), GetSize());
}
return GetSize();
}
示例15: RenderData
/*!
\todo handle exception on errors
*/
uint32 EbmlString::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
uint32 Result;
output.writeFully(Value.c_str(), Value.length());
Result = Value.length();
if (Result < DefaultSize) {
// pad the rest with 0
binary *Pad = new binary[DefaultSize - Result];
if (Pad == NULL)
{
return Result;
}
memset(Pad, 0x00, DefaultSize - Result);
output.writeFully(Pad, DefaultSize - Result);
Result = DefaultSize;
delete [] Pad;
}
return Result;
}