本文整理汇总了C++中readU16函数的典型用法代码示例。如果您正苦于以下问题:C++ readU16函数的具体用法?C++ readU16怎么用?C++ readU16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readU16函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is
bool DecoSchematic::loadSchematicFile() {
std::ifstream is(filename.c_str(), std::ios_base::binary);
u32 signature = readU32(is);
if (signature != MTSCHEM_FILE_SIGNATURE) {
errorstream << "loadSchematicFile: invalid schematic "
"file" << std::endl;
return false;
}
u16 version = readU16(is);
if (version != 1) {
errorstream << "loadSchematicFile: unsupported schematic "
"file version" << std::endl;
return false;
}
size = readV3S16(is);
int nodecount = size.X * size.Y * size.Z;
u16 nidmapcount = readU16(is);
node_names = new std::vector<std::string>;
for (int i = 0; i != nidmapcount; i++) {
std::string name = deSerializeString(is);
node_names->push_back(name);
}
delete schematic;
schematic = new MapNode[nodecount];
MapNode::deSerializeBulk(is, SER_FMT_VER_HIGHEST, schematic,
nodecount, 2, 2, true);
return true;
}
示例2: readU16
WideString TankFile::readWNString()
{
auto lenInChars = readU16();
if (lenInChars == 0)
{
readU16(); // Waste another word to make this a dword
return WideString();
}
// NSTRINGs are stored aligned at dword boundary:
lenInChars = alignToDword(lenInChars + 2) - 2; // 2 for the word we've just read
assert(((lenInChars + 2) % sizeof(uint32_t)) == 0);
if (lenInChars >= utils::MaxTempStringLen)
{
SiegeThrow(TankFile::Error, "String overflow in TankFile::readWNString()! "
<< lenInChars << " >= " << utils::MaxTempStringLen);
}
WideChar buffer[utils::MaxTempStringLen];
readBytes(buffer, lenInChars * sizeof(WideChar));
buffer[lenInChars] = 0;
return buffer;
}
示例3: deSerialize
void deSerialize(std::istream &is)
{
clear();
int version = readU8(is);
if(version != 1)
throw SerializationError("unsupported NodeDefinitionManager version");
u16 count = readU16(is);
std::istringstream is2(deSerializeLongString(is), std::ios::binary);
for(u16 n=0; n<count; n++){
u16 i = readU16(is2);
if(i > MAX_CONTENT){
errorstream<<"ContentFeatures::deSerialize(): "
<<"Too large content id: "<<i<<std::endl;
continue;
}
/*// Do not deserialize special types
if(i == CONTENT_IGNORE || i == CONTENT_AIR)
continue;*/
ContentFeatures *f = &m_content_features[i];
// Read it from the string wrapper
std::string wrapper = deSerializeString(is2);
std::istringstream wrapper_is(wrapper, std::ios::binary);
f->deSerialize(wrapper_is);
verbosestream<<"deserialized "<<f->name<<std::endl;
if(f->name != "")
addNameIdMapping(i, f->name);
}
}
示例4: readU32
bool WPGHeader::load(WPXInputStream *input)
{
input->seek(0, WPX_SEEK_SET);
size_t n = 0;
unsigned char * prefix = (unsigned char *) input->read(26, n);
if(n < 26)
return false;
m_identifier[0] = prefix[0];
m_identifier[1] = prefix[1];
m_identifier[2] = prefix[2];
m_identifier[3] = prefix[3];
m_startOfDocument = readU32(prefix+4);
m_productType = prefix[8];
m_fileType = prefix[9];
m_majorVersion = prefix[10];
m_minorVersion = prefix[11];
m_encryptionKey = readU16(prefix+12);
m_startOfPacketData = readU16(prefix+14);
WPG_DEBUG_MSG(("Header Identifier = %c%c%c\n", m_identifier[1],
m_identifier[2], m_identifier[3]));
WPG_DEBUG_MSG(("Product type = 0x%x\n", m_productType));
WPG_DEBUG_MSG(("File type = 0x%x\n", m_fileType));
WPG_DEBUG_MSG(("Major version = 0x%x\n", m_majorVersion));
WPG_DEBUG_MSG(("Minor version = 0x%x\n", m_minorVersion));
WPG_DEBUG_MSG(("Encryption key = 0x%x\n", m_encryptionKey));
return true;
}
示例5: deSerialize
void deSerialize(std::istream &is)
{
// Clear everything
clear();
// Deserialize
int version = readU8(is);
if(version != 0)
throw SerializationError("unsupported ItemDefManager version");
u16 count = readU16(is);
for(u16 i=0; i<count; i++)
{
// Deserialize a string and grab an ItemDefinition from it
std::istringstream tmp_is(deSerializeString(is), std::ios::binary);
ItemDefinition def;
def.deSerialize(tmp_is);
// Register
registerItem(def);
}
u16 num_aliases = readU16(is);
for(u16 i=0; i<num_aliases; i++)
{
std::string name = deSerializeString(is);
std::string convert_to = deSerializeString(is);
registerAlias(name, convert_to);
}
}
示例6: readU32
void libvisio::VSDMetaData::readPropertySetStream(librevenge::RVNGInputStream *input)
{
// ByteOrder
input->seek(2, librevenge::RVNG_SEEK_CUR);
// Version
input->seek(2, librevenge::RVNG_SEEK_CUR);
// SystemIdentifier
input->seek(4, librevenge::RVNG_SEEK_CUR);
// CLSID
input->seek(16, librevenge::RVNG_SEEK_CUR);
// NumPropertySets
input->seek(4, librevenge::RVNG_SEEK_CUR);
// FMTID0
//input->seek(16, librevenge::RVNG_SEEK_CUR);
uint32_t data1 = readU32(input);
uint16_t data2 = readU16(input);
uint16_t data3 = readU16(input);
uint8_t data4[8];
for (int i = 0; i < 8; i++)
{
data4[i] = readU8(input);
}
char FMTID0[36];
sprintf(FMTID0, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", data1, data2, data3,
data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7]);
uint32_t offset0 = readU32(input);
readPropertySet(input, offset0, FMTID0);
}
示例7: readU8
void ObjectProperties::deSerialize(std::istream &is)
{
int version = readU8(is);
if(version != 1) throw SerializationError(
"unsupported ObjectProperties version");
hp_max = readS16(is);
physical = readU8(is);
weight = readF1000(is);
collisionbox.MinEdge = readV3F1000(is);
collisionbox.MaxEdge = readV3F1000(is);
visual = deSerializeString(is);
meshfile = deSerializeString(is);
visual_size = readV2F1000(is);
textures.clear();
u32 texture_count = readU16(is);
for(u32 i=0; i<texture_count; i++){
textures.push_back(deSerializeString(is));
}
textures_3d.clear();
u32 texture_3d_count = readU16(is);
for(u32 i=0; i<texture_3d_count; i++){
textures_3d.push_back(deSerializeString(is));
}
spritediv = readV2S16(is);
initial_sprite_basepos = readV2S16(is);
is_visible = readU8(is);
makes_footstep_sound = readU8(is);
try{
automatic_rotate = readF1000(is);
}catch(SerializationError &e){}
}
示例8: readU32
void libvisio::VSDMetaData::readPropertySetStream(librevenge::RVNGInputStream *input)
{
// ByteOrder
input->seek(2, librevenge::RVNG_SEEK_CUR);
// Version
input->seek(2, librevenge::RVNG_SEEK_CUR);
// SystemIdentifier
input->seek(4, librevenge::RVNG_SEEK_CUR);
// CLSID
input->seek(16, librevenge::RVNG_SEEK_CUR);
// NumPropertySets
input->seek(4, librevenge::RVNG_SEEK_CUR);
// FMTID0
//input->seek(16, librevenge::RVNG_SEEK_CUR);
uint32_t data1 = readU32(input);
uint16_t data2 = readU16(input);
uint16_t data3 = readU16(input);
uint8_t data4[8];
for (unsigned char &i : data4)
{
i = readU8(input);
}
// Pretty-printed GUID is 36 bytes + the terminating null-character.
char FMTID0[37];
sprintf(FMTID0, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", data1, data2, data3,
data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7]);
uint32_t offset0 = readU32(input);
readPropertySet(input, offset0, FMTID0);
}
示例9: readU16
void WP6GraphicsFilenamePacket::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
{
if ((m_flags & 0x01) == 0x00)
return;
unsigned short tmpNumChildIds = readU16(input, encryption);
for (unsigned short i = 0; i < tmpNumChildIds; i++)
m_childIds.push_back(readU16(input, encryption));
}
示例10: while
void FlcPlayer::decodeVideo(bool skipLastFrame)
{
bool videoFrameFound = false;
while (!videoFrameFound)
{
if (!isValidFrame(_videoFrameData, _videoFrameSize, _videoFrameType))
{
_playingState = FINISHED;
break;
}
switch (_videoFrameType)
{
case FRAME_TYPE:
Uint32 delay;
readU16(_frameChunks, _videoFrameData + 6);
readU16(_delayOverride, _videoFrameData + 8);
if (_headerType == FLI_TYPE)
{
delay = _delayOverride > 0 ? _delayOverride : _headerSpeed * (1000.0 / 70.0);
}
else
{
delay = _videoDelay;
}
waitForNextFrame(delay);
// Skip the frame header, we are not interested in the rest
_chunkData = _videoFrameData + 16;
_videoFrameData += _videoFrameSize;
// If this frame is the last one, don't play it
if(isEndOfFile(_videoFrameData))
_playingState = FINISHED;
if(!shouldQuit() || !skipLastFrame)
playVideoFrame();
videoFrameFound = true;
break;
case AUDIO_CHUNK:
_videoFrameData += _videoFrameSize + 16;
break;
case PREFIX_CHUNK:
// Just skip it
_videoFrameData += _videoFrameSize;
break;
}
}
}
示例11: readU8
void NodeTimerList::deSerialize(std::istream &is, u8 map_format_version)
{
m_data.clear();
if(map_format_version == 24){
u8 timer_version = readU8(is);
if(timer_version == 0)
return;
if(timer_version != 1)
throw SerializationError("unsupported NodeTimerList version");
}
if(map_format_version >= 25){
u8 timer_data_len = readU8(is);
if(timer_data_len != 2+4+4)
throw SerializationError("unsupported NodeTimer data length");
}
u16 count = readU16(is);
for(u16 i=0; i<count; i++)
{
u16 p16 = readU16(is);
v3s16 p;
p.Z = p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
p16 &= MAP_BLOCKSIZE * MAP_BLOCKSIZE - 1;
p.Y = p16 / MAP_BLOCKSIZE;
p16 &= MAP_BLOCKSIZE - 1;
p.X = p16;
NodeTimer t;
t.deSerialize(is);
if(t.timeout <= 0)
{
infostream<<"WARNING: NodeTimerList::deSerialize(): "
<<"invalid data at position"
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
<<std::endl;
continue;
}
if(m_data.find(p) != m_data.end())
{
infostream<<"WARNING: NodeTimerList::deSerialize(): "
<<"already set data at position"
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
<<std::endl;
continue;
}
m_data.insert(std::make_pair(p, t));
}
}
示例12: readU8
void TileDef::deSerialize(std::istream &is)
{
int version = readU8(is);
name = deSerializeString(is);
animation.type = (TileAnimationType)readU8(is);
animation.aspect_w = readU16(is);
animation.aspect_h = readU16(is);
animation.length = readF1000(is);
if(version >= 1)
backface_culling = readU8(is);
}
示例13: readU8
void TileDef::deSerialize(std::istream &is)
{
int version = readU8(is);
if(version != 0)
throw SerializationError("unsupported TileDef version");
name = deSerializeString(is);
animation.type = (TileAnimationType)readU8(is);
animation.aspect_w = readU16(is);
animation.aspect_h = readU16(is);
animation.length = readF1000(is);
}
示例14: readU16
void STTBF::init( U16 lid, OLEStreamReader* reader, const U8* ptr )
{
bool extended = false;
U16 count = readU16( reader, &ptr );
// "extended" characters?
if ( count == 0xffff ) {
extended = true;
// read the real size
count = readU16( reader, &ptr );
}
m_extraDataLength = readU16( reader, &ptr );
// If we don't read unicode strings we have to set up a text converter
TextConverter* textconverter = 0;
if ( !extended )
textconverter = new TextConverter( lid );
// read one string after the other
for ( U16 i = 0; i < count; ++i ) {
U16 len = 0;
if ( extended ) // double byte count!
len = readU16( reader, &ptr );
else
len = readU8( reader, &ptr );
if ( len != 0 ) {
if ( extended ) {
XCHAR* string = new XCHAR[ len ];
for ( U16 j = 0; j < len; ++j )
string[ j ] = readU16( reader, &ptr );
UString ustring( reinterpret_cast<const wvWare::UChar *>( string ), len );
delete [] string;
m_strings.push_back( ustring );
}
else {
U8* string = new U8[ len ];
read( reader, &ptr, string, len );
UString ustring( textconverter->convert( reinterpret_cast<char*>( string ),
static_cast<unsigned int>( len ) ) );
delete [] string;
m_strings.push_back( ustring );
}
}
else
m_strings.push_back( UString("") );
if ( m_extraDataLength != 0 ) {
U8* extra = new U8[ m_extraDataLength ];
read( reader, &ptr, extra, m_extraDataLength );
m_extraData.push_back( extra );
}
}
delete textconverter;
}
示例15: deSerializeString
void CraftDefinitionShaped::deSerializeBody(std::istream &is, int version)
{
if(version != 1) throw SerializationError(
"unsupported CraftDefinitionShaped version");
output = deSerializeString(is);
width = readU16(is);
recipe.clear();
u32 count = readU16(is);
for(u32 i=0; i<count; i++)
recipe.push_back(deSerializeString(is));
replacements.deSerialize(is);
}