本文整理汇总了C++中readUint32函数的典型用法代码示例。如果您正苦于以下问题:C++ readUint32函数的具体用法?C++ readUint32怎么用?C++ readUint32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readUint32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readUint8
ICOImageDecoder::IconDirectoryEntry ICOImageDecoder::readDirectoryEntry() {
// Read icon data.
// The following calls to readUint8() return a uint8_t, which is appropriate
// because that's the on-disk type of the width and height values. Storing
// them in ints (instead of matching uint8_ts) is so we can record dimensions
// of size 256 (which is what a zero byte really means).
int width = readUint8(0);
if (!width)
width = 256;
int height = readUint8(1);
if (!height)
height = 256;
IconDirectoryEntry entry;
entry.m_size = IntSize(width, height);
if (m_fileType == CURSOR) {
entry.m_bitCount = 0;
entry.m_hotSpot = IntPoint(readUint16(4), readUint16(6));
} else {
entry.m_bitCount = readUint16(6);
entry.m_hotSpot = IntPoint();
}
entry.m_byteSize = readUint32(8);
entry.m_imageOffset = readUint32(12);
// Some icons don't have a bit depth, only a color count. Convert the
// color count to the minimum necessary bit depth. It doesn't matter if
// this isn't quite what the bitmap info header says later, as we only use
// this value to determine which icon entry is best.
if (!entry.m_bitCount) {
int colorCount = readUint8(2);
if (!colorCount)
colorCount = 256; // Vague in the spec, needed by real-world icons.
for (--colorCount; colorCount; colorCount >>= 1)
++entry.m_bitCount;
}
示例2: Valid_
TOptIAPrefix::TOptIAPrefix(const char * buf, size_t len, TMsg* parent)
:TOpt(OPTION_IAPREFIX, parent), Valid_(false)
{
if (len >= 25)
{
PrefLifetime_ = readUint32(buf);
buf += sizeof(uint32_t);
len -= sizeof(uint32_t);
ValidLifetime_ = readUint32(buf);
buf += sizeof(uint32_t);
len -= sizeof(uint32_t);
PrefixLength_ = *buf;
buf += 1;
len -= 1;
Prefix_ = new TIPv6Addr(buf);
buf += 16;
len -= 16;
Valid_ = parseOptions(SubOptions, buf, len, parent, OPTION_IAPREFIX,
"IAPrefix option");
}
}
示例3: parseIndexList
IsoMediaFile::Auxiliary WriterConfig::readAuxiliary(const Json::Value& auxValues) const
{
IsoMediaFile::Auxiliary aux;
aux.file_path = auxValues["file_path"].asString();
aux.idxs_list = parseIndexList(auxValues["idxs_list"]);
aux.refs_list = parseRefsList(auxValues["refs_list"]);
aux.uniq_bsid = readOptionalUint(auxValues["uniq_bsid"]);
aux.disp_xdim = readUint32(auxValues, "disp_xdim");
aux.disp_ydim = readUint32(auxValues, "disp_ydim");
aux.hidden = readBool(auxValues["hidden"], true);
aux.urn = auxValues["urn"].asString();
return aux;
}
示例4: ASSERT
bool BMPImageReader::readInfoHeaderSize() {
// Get size of info header.
ASSERT(m_decodedOffset == m_headerOffset);
if ((m_decodedOffset > m_data->size()) ||
((m_data->size() - m_decodedOffset) < 4))
return false;
m_infoHeader.biSize = readUint32(0);
// Don't increment m_decodedOffset here, it just makes the code in
// processInfoHeader() more confusing.
// Don't allow the header to overflow (which would be harmless here, but
// problematic or at least confusing in other places), or to overrun the
// image data.
const size_t headerEnd = m_headerOffset + m_infoHeader.biSize;
if ((headerEnd < m_headerOffset) ||
(m_imgDataOffset && (m_imgDataOffset < headerEnd)))
return m_parent->setFailed();
// See if this is a header size we understand:
// OS/2 1.x: 12
if (m_infoHeader.biSize == 12)
m_isOS21x = true;
// Windows V3: 40
else if ((m_infoHeader.biSize == 40) || isWindowsV4Plus())
;
// OS/2 2.x: any multiple of 4 between 16 and 64, inclusive, or 42 or 46
else if ((m_infoHeader.biSize >= 16) && (m_infoHeader.biSize <= 64) &&
(!(m_infoHeader.biSize & 3) || (m_infoHeader.biSize == 42) ||
(m_infoHeader.biSize == 46)))
m_isOS22x = true;
else
return m_parent->setFailed();
return true;
}
示例5: decodeGpuDynamic
CudaDecodedContext *decodeGpu(DecoderMetadata decoderMetadata) {
if (useDynamicParallelism) {
return decodeGpuDynamic(decoderMetadata);
}
uint8_t *pduBuffers = decoderMetadata.pduBuffers;
uint32_t size = decoderMetadata.size;
uint64_t bufferCapacity = decoderMetadata.bufferCapacity;
uint32_t correlationIdLength = decoderMetadata.correlationIdLength;
ByteBufferContext byteBufferContext = {pduBuffers, 0, (uint64_t) bufferCapacity};
CudaPduContext *pduContexts = cudaPduContext;
int i;
int startPosition = 0;
for (i = 0; i < size; i++) {
byteBufferContext.readIndex += 12;
char *correlationId = readStringByLength(&byteBufferContext, correlationIdLength);
uint32_t pduLength = readUint32(&byteBufferContext);
int startIndex = startPosition + correlationIdLength + 12;
strncpy(pduContexts[i].correlationId, correlationId, sizeof(char) * (correlationIdLength + 1));
pduContexts[i].start = (uint32_t) startIndex;
pduContexts[i].length = pduLength;
startPosition += (correlationIdLength + pduLength + 12);
byteBufferContext.readIndex = (uint64_t) startPosition;
}
CudaDecodedContext *decodedPduStructList = malloc(sizeof(CudaDecodedContext) * size);
CudaMetadata metadata = {size, pduBuffers, pduContexts, decodedPduStructList, (uint64_t) bufferCapacity,
decoderMetadata.blockDim, decoderMetadata.gridDim};
decodeCuda(metadata);
return decodedPduStructList;
}
示例6: checkExifHeader
static bool checkExifHeader(jpeg_saved_marker_ptr marker, bool& isBigEndian, unsigned& ifdOffset)
{
// For exif data, the APP1 block is followed by 'E', 'x', 'i', 'f', '\0',
// then a fill byte, and then a tiff file that contains the metadata.
// A tiff file starts with 'I', 'I' (intel / little endian byte order) or
// 'M', 'M' (motorola / big endian byte order), followed by (uint16_t)42,
// followed by an uint32_t with the offset to the tag block, relative to the
// tiff file start.
const unsigned exifHeaderSize = 14;
if (!(marker->marker == exifMarker
&& marker->data_length >= exifHeaderSize
&& marker->data[0] == 'E'
&& marker->data[1] == 'x'
&& marker->data[2] == 'i'
&& marker->data[3] == 'f'
&& marker->data[4] == '\0'
// data[5] is a fill byte
&& ((marker->data[6] == 'I' && marker->data[7] == 'I')
|| (marker->data[6] == 'M' && marker->data[7] == 'M'))))
return false;
isBigEndian = marker->data[6] == 'M';
if (readUint16(marker->data + 8, isBigEndian) != 42)
return false;
ifdOffset = readUint32(marker->data + 10, isBigEndian);
return true;
}
示例7: ObjectFile
WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
: ObjectFile(Binary::ID_Wasm, Buffer) {
ErrorAsOutParameter ErrAsOutParam(&Err);
Header.Magic = getData().substr(0, 4);
if (Header.Magic != StringRef("\0asm", 4)) {
Err = make_error<StringError>("Bad magic number",
object_error::parse_failed);
return;
}
const uint8_t *Ptr = getPtr(4);
Header.Version = readUint32(Ptr);
if (Header.Version != wasm::WasmVersion) {
Err = make_error<StringError>("Bad version number",
object_error::parse_failed);
return;
}
const uint8_t *Eof = getPtr(getData().size());
wasm::WasmSection Sec;
while (Ptr < Eof) {
if ((Err = readSection(Sec, Ptr, getPtr(0))))
return;
if (Sec.Type == wasm::WASM_SEC_USER) {
if ((Err = parseUserSection(Sec, Sec.Content.data(), Sec.Content.size())))
return;
}
Sections.push_back(Sec);
}
}
示例8: IntSize
ICOImageDecoder::IconDirectoryEntry ICOImageDecoder::readDirectoryEntry()
{
// Read icon data.
// The casts to uint8_t in the next few lines are because that's the on-disk
// type of the width and height values. Storing them in ints (instead of
// matching uint8_ts) is so we can record dimensions of size 256 (which is
// what a zero byte really means).
int width = static_cast<uint8_t>(m_data->data()[m_decodedOffset]);
if (!width)
width = 256;
int height = static_cast<uint8_t>(m_data->data()[m_decodedOffset + 1]);
if (!height)
height = 256;
IconDirectoryEntry entry;
entry.m_size = IntSize(width, height);
if (m_fileType == CURSOR) {
entry.m_bitCount = 0;
entry.m_hotSpot = IntPoint(readUint16(4), readUint16(6));
} else {
entry.m_bitCount = readUint16(6);
entry.m_hotSpot = IntPoint();
}
entry.m_imageOffset = readUint32(12);
// Some icons don't have a bit depth, only a color count. Convert the
// color count to the minimum necessary bit depth. It doesn't matter if
// this isn't quite what the bitmap info header says later, as we only use
// this value to determine which icon entry is best.
if (!entry.m_bitCount) {
int colorCount = static_cast<uint8_t>(m_data->data()[m_decodedOffset + 2]);
if (!colorCount)
colorCount = 256; // Vague in the spec, needed by real-world icons.
for (--colorCount; colorCount; colorCount >>= 1)
++entry.m_bitCount;
}
示例9: readUint32
float IFileStream::readFloat()
{
Uint32 tmp = readUint32();
float tmp2;
memcpy(&tmp2,&tmp,sizeof(Uint32)); // workaround for a strange optimization in gcc 4.1
return tmp2;
}
示例10: ASSERT
bool BMPImageDecoder::processFileHeader(size_t* imgDataOffset)
{
ASSERT(imgDataOffset);
// Read file header.
ASSERT(!m_decodedOffset);
if (m_data->size() < sizeOfFileHeader)
return false;
const uint16_t fileType = (m_data->data()[0] << 8) | static_cast<uint8_t>(m_data->data()[1]);
*imgDataOffset = readUint32(10);
m_decodedOffset = sizeOfFileHeader;
// See if this is a bitmap filetype we understand.
enum {
BMAP = 0x424D, // "BM"
// The following additional OS/2 2.x header values (see
// http://www.fileformat.info/format/os2bmp/egff.htm ) aren't widely
// decoded, and are unlikely to be in much use.
/*
ICON = 0x4943, // "IC"
POINTER = 0x5054, // "PT"
COLORICON = 0x4349, // "CI"
COLORPOINTER = 0x4350, // "CP"
BITMAPARRAY = 0x4241, // "BA"
*/
};
return (fileType == BMAP) || setFailed();
}
示例11: Valid_
TOptIAAddress::TOptIAAddress(char * &buf, int& n, TMsg* parent)
:TOpt(OPTION_IAADDR, parent), Valid_(false)
{
if ( n >= 24) {
Addr_ = new TIPv6Addr(buf);
buf += 16;
n -= 16;
PrefLifetime_ = readUint32(buf);
buf += sizeof(uint32_t);
n -= sizeof(uint32_t);
ValidLifetime_ = readUint32(buf);
buf += sizeof(uint32_t);
n -= sizeof(uint32_t);
Valid_ = true;
}
}
示例12: loadModules
void loadModules(void * payloadStart, void ** targetModuleAddress)
{
int i;
uint8_t * currentModule = (uint8_t*)payloadStart;
uint32_t moduleCount = readUint32(¤tModule);
for (i = 0; i < moduleCount; i++)
loadModule(¤tModule, targetModuleAddress[i]);
}
示例13: edpCommandReqParse
/*
* edpCommandReqParse
* 按照EDP命令请求协议,解析数据
*/
int edpCommandReqParse(edp_pkt* pkt, char *id, char *cmd, int32 *rmlen, int32 *id_len, int32 *cmd_len)
{
readUint8(pkt); /* 包类型 */
*rmlen = readRemainlen(pkt); /* 剩余长度 */
*id_len = readUint16(pkt); /* ID长度 */
readStr(pkt, id, *id_len); /* 命令ID */
*cmd_len = readUint32(pkt); /* 命令长度 */
readStr(pkt, cmd, *cmd_len); /* 命令内容 */
}
示例14: readUint32
glm::vec4 kit::readVec4i(std::istream & s)
{
glm::ivec4 v;
for (int x = 0; x < 4; x++)
{
v[x] = readUint32(s);
}
return v;
}
示例15: ASSERT
uint cVirtualMemoryAccesser::readUint(addressNumericValue address) const
{
// If this change, than the implementation must be changed also
ASSERT(sizeof(uint) == sizeof(uint32));
uint8 buf[4];
if (!memread(address, &buf, sizeof(buf), NULL))
XSTL_THROW(cException, EXCEPTION_OUT_OF_RANGE);
return readUint32(buf);
}