本文整理汇总了C++中BinaryReader类的典型用法代码示例。如果您正苦于以下问题:C++ BinaryReader类的具体用法?C++ BinaryReader怎么用?C++ BinaryReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BinaryReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: receive
void RTMFPHandshake::receive(const SocketAddress& address, BinaryReader& request) {
if(!Session::receive(address, request))
return;
UInt8 marker = request.read8();
if(marker!=0x0b) {
ERROR("Marker handshake wrong : should be 0b and not ",Format<UInt8>("%.2x",marker));
return;
}
UInt16 time = request.read16();
UInt8 id = request.read8();
request.shrink(request.read16()); // length
BinaryWriter response(packet(),RTMFP_MAX_PACKET_SIZE);
response.clear(RTMFP_HEADER_SIZE+3); // header + type and size
UInt8 idResponse = handshakeHandler(id,address, request,response);
if (!idResponse)
return;
BinaryWriter(response.data() + RTMFP_HEADER_SIZE, 3).write8(idResponse).write16(response.size() - RTMFP_HEADER_SIZE - 3);
(UInt32&)farId = 0;
flush(0x0b, response.size());
}
示例2: OnStart
void OnStart()
{
asd::Engine::GetFile()->AddRootDirectory(asd::ToAString("Data/Texture.pack").c_str());
for (auto loop = 0; loop < 2; loop++)
{
//普通に読み込んだバイナリ
BinaryReader reader;
auto data = GetBinaryData(asd::ToAString("Data/Texture/Surface/Tile_Normal.png"));
reader.ReadIn(data.begin(), data.end());
//ファイル機能で読み込んだバイナリ
auto staticFile = asd::Engine::GetFile()->CreateStaticFile(asd::ToAString("Surface/Tile_Normal.png").c_str());
auto staticFileData = staticFile->GetBuffer();
int cnt = 0;
while (!reader.IsEmpty())
{
int8_t byteFromRaw = reader.Get<int8_t>();
int8_t byteFromFile = staticFileData[cnt++];
ASSERT_EQ(byteFromRaw, byteFromFile);
}
ASSERT_EQ(cnt, staticFileData.size());
}
}
示例3: OnStart
void OnStart()
{
//普通に読み込んだバイナリ
BinaryReader reader;
auto data = GetBinaryData(asd::ToAString("Data/Texture/Surface/Tile_Normal.png"));
reader.ReadIn(data.begin(), data.end());
//ファイル機能で読み込んだバイナリ
asd::Engine::GetFile()->AddRootPackage(asd::ToAString("Data/Texture.pack").c_str());
auto streamFile = asd::Engine::GetFile()->CreateStreamFile(asd::ToAString("Surface/Tile_Normal.png").c_str());
std::vector<uint8_t> buffer;
streamFile->Read(buffer, streamFile->GetSize());
int cnt = 0;
while (!reader.IsEmpty())
{
auto byteFromRaw = reader.Get<uint8_t>();
auto byteFromFile = buffer[cnt++];
ASSERT_EQ(byteFromRaw, byteFromFile);
}
ASSERT_EQ(cnt, buffer.size());
}
示例4: unserialize
void OutPoint::unserialize(BinaryReader & br)
{
if (br.getSizeRemaining() < 32)
throw BlockDeserializingException();
br.get_BinaryData(txHash_, 32);
txOutIndex_ = br.get_uint32_t();
}
示例5: reader
Record::Record(Guid &id, long long length, BinaryReader &reader,
DatabaseImpl *_database) : reader(reader), database(_database)
{
this->id = id;
this->length = length;
long childrenSize;
reader >> childrenSize;
long long childrenStartPosition;
reader >> childrenStartPosition;
dataPosition = reader.Position();
reader.Position(childrenStartPosition);
vchildren.reserve(childrenSize);
for(int i =0;i < childrenSize;i++)
{
long long startPosition = reader.Position();
Guid childId;
reader >> childId;
long long childLength;
reader >> childLength;
IRecord *childRecord = new Record(childId,childLength,reader,_database);
vchildren.push_back(childRecord);
reader.Position(startPosition+childLength);
database->AddRecord(childRecord);
}
}
示例6: Unmask
void WS::Unmask(BinaryReader& reader) {
UInt32 i;
UInt8 mask[4];
reader.read(sizeof(mask),mask);
UInt8* bytes = (UInt8*)reader.current();
for(i=0;i<reader.available();++i)
bytes[i] ^= mask[i%4];
}
示例7: rowBytes
void BmpImage::toGrayscale()
{
if (bitsPerPixel != 8 && bitsPerPixel != 24)
return;
int w = rowBytes();
int avg;
if (bitsPerPixel == 24)
{
ByteBuffer* bmpBuffer = new ByteBuffer(bitmapSize, bmpBits);
BinaryReader* reader = new BinaryReader(bmpBuffer);
byte blue, green, red;
for (unsigned int i = 0; i < height; i++)
{
for (unsigned int j = 0; j < width; j++)
{
blue = reader->readByte(i*w+j*3);
green = reader->readByte(i*w+j*3+1);
red = reader->readByte(i*w+j*3+2);
avg = (red + green + blue)/3;
avg = (avg << 16) | (avg << 8) | (avg);
bmpBuffer->seek(i*w+j*3);
bmpBuffer->addRGB(avg);
}
}
bmpBits = bmpBuffer->getBytes();
return;
}
int colorTableIndex;
for (unsigned int i = 0; i < height; i++)
{
for (unsigned int j = 0; j < width; j++)
{
colorTableIndex = bmpBits[i*w+j];
avg = (colorPalette[colorTableIndex] & 0x00FF0000) >> 16;
avg += (colorPalette[colorTableIndex] & 0x0000FF00) >> 8;
avg += (colorPalette[colorTableIndex] & 0x000000FF);
avg /= 3;
bmpBits[i*w+j] = avg;
}
}
for (int k = 0; k < colorPaletteSize; k++)
{
colorPalette[k] = (k << 16) | (k << 8) | (k);
}
}
示例8: readRawPacket
void PositionPacket::readRawPacket(BinaryReader& stream) {
stream.read(reinterpret_cast<char*>(&mNotUsed1), sizeof(mNotUsed1));
stream >> mGyro1 >> mTemp1 >> mAccel1X >> mAccel1Y >> mGyro2 >> mTemp2 >>
mAccel2X >> mAccel2Y >> mGyro3 >> mTemp3 >> mAccel3X >> mAccel3Y;
stream.read(reinterpret_cast<char*>(&mNotUsed2), sizeof(mNotUsed2));
stream >> mGPSTimestamp;
stream.read(reinterpret_cast<char*>(&mNotUsed3), sizeof(mNotUsed3));
stream.read(reinterpret_cast<char*>(&mNMEASentence), sizeof(mNMEASentence));
stream.read(reinterpret_cast<char*>(&mNotUsed4), sizeof(mNotUsed4));
}
示例9: ReadHeader
void ReadHeader(const BinaryReader& rd, bool bParent) override {
HashValue h;
rd >> Ver >> PrevBlockHash >> h;
m_merkleRoot = h;
Height = (uint32_t)rd.ReadInt64();
Timestamp = DateTime::from_time_t(rd.ReadUInt64());
rd >> Nonce1 >> Nonce2 >> Nonce3 >> Nonce;
rd.ReadStruct(MinerId);
DifficultyTargetBits = rd.ReadUInt32();
}
示例10:
BinaryReader<T> &operator>>(BinaryReader<T> &reader, Bone &b)
{
b.name=reader.getString(15);
reader
>> b.frame
>> b.pos
>> b.q
;
reader.getBytes(b.cInterpolationX, 16);
reader.getBytes(b.cInterpolationY, 16);
reader.getBytes(b.cInterpolationZ, 16);
reader.getBytes(b.cInterpolationRot, 16);
return reader;
}
示例11: distance
AffLoader::AffLoader(std::vector<uint8_t> &data)
{
BinaryReader reader;
reader.ReadIn(data.begin(), data.end());
auto header = AffHeader::Get(reader);
auto table = AffIndexTable::Get(reader);
auto indexes = table.GetIndexes();
auto fontNum = header.GetFontCount();
for (int16_t i = 0; i < fontNum; ++i)
{
auto charactor = distance(indexes.begin(), find(indexes.begin(), indexes.end(), i));
result[charactor] = GlyphData::Get(reader, charactor);
}
}
示例12: ReadModelArray
void ReadModelArray( Array< _type_ > & out, const char * string, const BinaryReader & bin, const int numElements )
{
if ( string != NULL && string[0] != '\0' && numElements > 0 )
{
if ( !bin.ReadArray( out, numElements ) )
{
StringUtils::StringTo( out, string );
}
}
}
示例13: Load
bool Model_IO::Load(const std::vector<uint8_t>& data, const achar* path)
{
Meshes.clear();
BinaryReader reader;
reader.ReadIn(data.begin(), data.end());
// ヘッダーチェック
uint8_t header_true [] = "MDL";
for (int32_t i = 0; i < 4; i++)
{
auto h = reader.Get<uint8_t>();
if (header_true[i] != h) return false;
}
// バージョン
int32_t version = reader.Get<int32_t>();
// ボーン
LoadDeformer(Deformer_, reader, path, version);
// メッシュ
LoadMeshes(Meshes, reader, path);
// アニメーション
int32_t sourceCount = reader.Get<int32_t>();
AnimationSources.resize(sourceCount);
for (int32_t i = 0; i < sourceCount; i++)
{
LoadAnimationSource(AnimationSources[i], reader, path);
}
int32_t clipCount = reader.Get<int32_t>();
AnimationClips.resize(clipCount);
for (int32_t i = 0; i < clipCount; i++)
{
LoadAnimationClip(AnimationClips[i], reader, path);
}
return true;
}
示例14: getMessageLength
uint Packet::getMessageLength(ushort lengthType, BinaryReader& reader)
{
uint length = 0;
switch(lengthType)
{
case 1:
length = static_cast<uint>(reader.readByte());
break;
case 2:
length = reader.readUShort();
break;
case 3:
length = static_cast<uint>(
((reader.readByte() & 255) << 16) +
((reader.readByte() & 255) << 8) +
(reader.readByte() & 255));
break;
default:
break;
}
return length;
}
示例15: read_tga_uncompressed
void read_tga_uncompressed(BinaryReader& br, uint32_t width, uint32_t height, uint8_t channels, ImageData& image)
{
if (channels == 2)
{
uint32_t i = 0;
for (uint32_t h = 0; h < height; h++)
{
for (uint32_t w = 0; w < width; w++)
{
uint16_t data;
br.read(data);
image.data[i + 0] = (data & 0x7c) >> 10;
image.data[i + 1] = (data & 0x3e) >> 5;
image.data[i + 2] = (data & 0x1f);
i += 3;
}
}
}