• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ readUint32函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中readUint32函数的典型用法代码示例。如果您正苦于以下问题:C++ readUint32函数的具体用法?C++ readUint32怎么用?C++ readUint32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了readUint32函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
  }
开发者ID:mirror,项目名称:chromium,代码行数:35,代码来源:ICOImageDecoder.cpp


示例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");
    }
}
开发者ID:hernancmartinez,项目名称:dibbler,代码行数:25,代码来源:OptIAPrefix.cpp


示例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;
}
开发者ID:pstanczyk,项目名称:heif,代码行数:15,代码来源:writercfg.cpp


示例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;
}
开发者ID:mirror,项目名称:chromium,代码行数:35,代码来源:BMPImageReader.cpp


示例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;
}
开发者ID:psawmora,项目名称:couldhopper-gpu,代码行数:30,代码来源:smpp_codec.c


示例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;
}
开发者ID:jeremyroman,项目名称:blink,代码行数:28,代码来源:JPEGImageDecoder.cpp


示例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);
  }
}
开发者ID:compor,项目名称:llvm,代码行数:29,代码来源:WasmObjectFile.cpp


示例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;
    }
开发者ID:3163504123,项目名称:phantomjs,代码行数:35,代码来源:ICOImageDecoder.cpp


示例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;
}
开发者ID:mathdesc,项目名称:dunelegacy,代码行数:7,代码来源:IFileStream.cpp


示例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();
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:28,代码来源:BMPImageDecoder.cpp


示例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;
    }
}
开发者ID:DorChen,项目名称:dibbler,代码行数:17,代码来源:OptIAAddress.cpp


示例12: loadModules

void loadModules(void * payloadStart, void ** targetModuleAddress)
{
	int i;
	uint8_t * currentModule = (uint8_t*)payloadStart;
	uint32_t moduleCount = readUint32(&currentModule);

	for (i = 0; i < moduleCount; i++)
		loadModule(&currentModule, targetModuleAddress[i]);
}
开发者ID:jcaracciolo,项目名称:Arqui2016,代码行数:9,代码来源:moduleLoader.c


示例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);    /* 命令内容 */
}
开发者ID:wi-cuckoo,项目名称:IOT-Programming,代码行数:13,代码来源:edp.c


示例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;
}
开发者ID:xHaVoK87,项目名称:kit,代码行数:10,代码来源:Types.cpp


示例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);
}
开发者ID:eladraz,项目名称:xStl,代码行数:11,代码来源:virtualMemoryAccesser.cpp


示例16: malloc

DecodedContext *decodePthread(DecoderMetadata 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, bufferCapacity};
    DirectPduContext *pduContexts = malloc(sizeof(DirectPduContext) * size);
    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;
        pduContexts[i].correlationId = correlationId;
        pduContexts[i].pduBuffer = pduBuffers;
        pduContexts[i].start = startIndex;
        pduContexts[i].length = pduLength;
        startPosition += (correlationIdLength + pduLength + 12);
        byteBufferContext.readIndex = startPosition;
    }

    int nThread = nCpuCores;
    int index = 0;
    int batchSize = size > nThread ? size / nThread : size;
    DecodedContext *decodedPduStructList = malloc(sizeof(DecodedContext) * size);
    ThreadParam *threadParams[nThread];

    pthread_t threads[nThread];
    int threadIndex = 0;
    while (index < size) {
        int startIndex = index;
        int length = (size - index) <= batchSize ? (size - index) : batchSize;
        index += length;
        ThreadParam *threadParam = malloc(sizeof(ThreadParam));
        threadParam->startIndex = startIndex;
        threadParam->length = length;
        threadParam->pduContexts = pduContexts;
        threadParam->decodedPduStructList = decodedPduStructList;
        threadParams[threadIndex] = threadParam;
        int state = pthread_create(&threads[threadIndex], NULL, decode, (void *) threadParam);
        threadIndex++;
    }

    for (i = 0; i < threadIndex; i++) {
        pthread_join(threads[i], NULL);
    }
    free(pduContexts);
    return decodedPduStructList;
}
开发者ID:psawmora,项目名称:couldhopper-gpu,代码行数:52,代码来源:smpp_codec.c


示例17: readUint32

std::string BufferObjectReader::readString()
{
   // Note: If you change this, you need to change STRING_LENGTH_SIZE
   vpr::Uint32 str_len = readUint32();
   std::string ret_val;
   char tempChar;
   for(vpr::Uint32 i=0; i<str_len;++i)
   {
      tempChar = static_cast<char>(*readRaw(1));
      ret_val += tempChar;
   }
   return ret_val;
}
开发者ID:Michael-Lfx,项目名称:vrjuggler,代码行数:13,代码来源:BufferObjectReader.cpp


示例18: State_Payload_read

char* State_Payload_read(struct Packet* p, char* buffer, int ascii) {
    if (!ascii) {
        buffer = readUint32(&(p->seq), buffer);
        buffer = readUint16((uint16_t*)&(p->state.leftEncoder), buffer);
        buffer = readUint16((uint16_t*)&(p->state.rightEncoder), buffer);
    } else {
        long int a, b, c = 0;
        sscanf(buffer, "%ld %ld %ld", &a, &b, &c);
        p->seq = (uint32_t) a;
        p->state.leftEncoder = (uint16_t) b;
        p->state.rightEncoder = (uint16_t) c;

    }
    return buffer;
}
开发者ID:atzenigor,项目名称:capybarauno,代码行数:15,代码来源:state_payload.cpp


示例19: loadModule

static void loadModule(uint8_t ** module, void * targetModuleAddress)
{
	uint32_t moduleSize = readUint32(module);

	ncPrint("  Will copy module at 0x");
	ncPrintHex((uint64_t)*module);
	ncPrint(" to 0x");
	ncPrintHex((uint64_t)targetModuleAddress);
	ncPrint(" (");
	ncPrintDec(moduleSize);
	ncPrint(" bytes)");

	memcpy(targetModuleAddress, *module, moduleSize);
	*module += moduleSize;

	ncPrint(" [Done]");
	ncNewline();
}
开发者ID:jcaracciolo,项目名称:Arqui2016,代码行数:18,代码来源:moduleLoader.c


示例20: ninitialPosition

eaio::size_type eaio::readString(IStream* pIS, char8_t* pBuffer, size_type nMaxCount, eaio::Endian endianSource)
{
    const off_type ninitialPosition(pIS->getPosition());

    char8_t   cCurrent;
    uint32_t  nLength(0);
    size_type nCount(0); // Number of chars returned to user.
    size_type nResult;

    if(!readUint32(pIS, nLength, endianSource))
        return kSizeTypeError;

    // If no buffer has been provided, just reset the stream and return the length.
    if(!pBuffer)
    {
        pIS->setPosition(ninitialPosition);
        return (size_type)nLength;
    }

    // Determine how many characters we'll actually read into the buffer.
    // 'nMaxCount - 1' because we want to leave room for terminating NUL.
    size_type nreadLength = (nLength < nMaxCount - 1) ? nLength : nMaxCount - 1;

    while(pBuffer && (nCount < nreadLength)) 
    {
        nResult = pIS->read(&cCurrent, sizeof(cCurrent));

        if(nResult != sizeof(cCurrent))
            break;

        *pBuffer++ = cCurrent;
        ++nCount;
    }

    // We may not have been able to read the entire string out of the stream
    // due to the nMaxCount limit, but we still want to advance the stream's
    // position to the end of the string.
    pIS->setPosition(ninitialPosition + (off_type)sizeof(uint32_t) + (off_type)nLength);

    if(pBuffer)
        *pBuffer = '\0';

    return nLength; // Note that we return nLength and not nCount.
}
开发者ID:jjiezheng,项目名称:eaio,代码行数:44,代码来源:StreamAdapter.cpp



注:本文中的readUint32函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ readValue函数代码示例发布时间:2022-05-30
下一篇:
C++ readU8函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap