当前位置: 首页>>代码示例>>C++>>正文


C++ DataBufferSP类代码示例

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


在下文中一共展示了DataBufferSP类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetData

//----------------------------------------------------------------------
// Assign the data for this object to be a subrange of the shared data in
// "data_sp" starting "data_offset" bytes into "data_sp" and ending
// "data_length" bytes later. If "data_offset" is not a valid offset into
// "data_sp", then this object will contain no bytes. If "data_offset" is
// within "data_sp" yet "data_length" is too large, the length will be capped
// at the number of bytes remaining in "data_sp". A ref counted pointer to the
// data in "data_sp" will be made in this object IF the number of bytes this
// object refers to in greater than zero (if at least one byte was available
// starting at "data_offset") to ensure the data stays around as long as it is
// needed. The address size and endian swap settings will remain unchanged from
// their current settings.
//----------------------------------------------------------------------
uint32_t DataEncoder::SetData(const DataBufferSP &data_sp, uint32_t data_offset,
                              uint32_t data_length) {
  m_start = m_end = nullptr;

  if (data_length > 0) {
    m_data_sp = data_sp;
    if (data_sp) {
      const size_t data_size = data_sp->GetByteSize();
      if (data_offset < data_size) {
        m_start = data_sp->GetBytes() + data_offset;
        const size_t bytes_left = data_size - data_offset;
        // Cap the length of we asked for too many
        if (data_length <= bytes_left)
          m_end = m_start + data_length; // We got all the bytes we wanted
        else
          m_end = m_start + bytes_left; // Not all the bytes requested were
                                        // available in the shared data
      }
    }
  }

  uint32_t new_size = GetByteSize();

  // Don't hold a shared pointer to the data buffer if we don't share any valid
  // bytes in the shared buffer.
  if (new_size == 0)
    m_data_sp.reset();

  return new_size;
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:43,代码来源:DataEncoder.cpp

示例2: GetDescriptor

Error
File::Read (size_t &num_bytes, off_t &offset, bool null_terminate, DataBufferSP &data_buffer_sp)
{
    Error error;
    
    if (num_bytes > 0)
    {
        int fd = GetDescriptor();
        if (fd != kInvalidDescriptor)
        {
            struct stat file_stats;
            if (::fstat (fd, &file_stats) == 0)
            {
                if (file_stats.st_size > offset)
                {
                    const size_t bytes_left = file_stats.st_size - offset;
                    if (num_bytes > bytes_left)
                        num_bytes = bytes_left;
                        
                    size_t num_bytes_plus_nul_char = num_bytes + (null_terminate ? 1 : 0);
                    std::unique_ptr<DataBufferHeap> data_heap_ap;
                    data_heap_ap.reset(new DataBufferHeap());
                    data_heap_ap->SetByteSize(num_bytes_plus_nul_char);
                        
                    if (data_heap_ap.get())
                    {
                        error = Read (data_heap_ap->GetBytes(), num_bytes, offset);
                        if (error.Success())
                        {
                            // Make sure we read exactly what we asked for and if we got
                            // less, adjust the array
                            if (num_bytes_plus_nul_char < data_heap_ap->GetByteSize())
                                data_heap_ap->SetByteSize(num_bytes_plus_nul_char);
                            data_buffer_sp.reset(data_heap_ap.release());
                            return error;
                        }
                    }
                }
                else 
                    error.SetErrorString("file is empty");
            }
            else
                error.SetErrorToErrno();
        }
        else 
            error.SetErrorString("invalid file handle");
    }
    else
        error.SetErrorString("invalid file handle");

    num_bytes = 0;
    data_buffer_sp.reset();
    return error;
}
开发者ID:wiltonlazary,项目名称:swift-lldb,代码行数:54,代码来源:File.cpp

示例3: ReadAllRegisterValues

bool RegisterContextPOSIXProcessMonitor_powerpc::ReadAllRegisterValues(
    DataBufferSP &data_sp) {
  bool success = false;
  data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
  if (data_sp && ReadGPR() && ReadFPR()) {
    uint8_t *dst = data_sp->GetBytes();
    success = dst != 0;

    if (success) {
      ::memcpy(dst, &m_gpr_powerpc, GetGPRSize());
      dst += GetGPRSize();
    }
  }
  return success;
}
开发者ID:CodaFi,项目名称:swift-lldb,代码行数:15,代码来源:RegisterContextPOSIXProcessMonitor_powerpc.cpp

示例4: process_sp

bool
RegisterContextMemory::WriteAllRegisterValues (const DataBufferSP &data_sp)
{
    if (m_reg_data_addr != LLDB_INVALID_ADDRESS)
    {
        ProcessSP process_sp (CalculateProcess());
        if (process_sp)
        {
            Error error;
            SetAllRegisterValid (false);
            if (process_sp->WriteMemory(m_reg_data_addr, data_sp->GetBytes(), data_sp->GetByteSize(), error) == data_sp->GetByteSize())
                return true;
        }
    }
    return false;
}
开发者ID:carlokok,项目名称:lldb,代码行数:16,代码来源:RegisterContextMemory.cpp

示例5: data_sp

Error
AdbClient::SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data)
{
    const DataBufferSP data_sp (new DataBufferHeap (kSyncPacketLen, 0));
    DataEncoder encoder (data_sp, eByteOrderLittle, sizeof (void*));
    auto offset = encoder.PutData (0, request_id, strlen(request_id));
    encoder.PutU32 (offset, data_len);

    Error error;
    ConnectionStatus status;
    m_conn.Write (data_sp->GetBytes (), kSyncPacketLen, status, &error);
    if (error.Fail ())
        return error;

    if (data)
        m_conn.Write (data, data_len, status, &error);
    return error;
}
开发者ID:CodaFi,项目名称:swift-lldb,代码行数:18,代码来源:AdbClient.cpp

示例6: WriteAllRegisterValues

bool RegisterContextPOSIXProcessMonitor_powerpc::WriteAllRegisterValues(
    const DataBufferSP &data_sp) {
  bool success = false;
  if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE) {
    uint8_t *src = data_sp->GetBytes();
    if (src) {
      ::memcpy(&m_gpr_powerpc, src, GetGPRSize());

      if (WriteGPR()) {
        src += GetGPRSize();
        ::memcpy(&m_fpr_powerpc, src, sizeof(m_fpr_powerpc));

        success = WriteFPR();
      }
    }
  }
  return success;
}
开发者ID:CodaFi,项目名称:swift-lldb,代码行数:18,代码来源:RegisterContextPOSIXProcessMonitor_powerpc.cpp

示例7: MakeLocationExpressionInternal

static DWARFExpression MakeLocationExpressionInternal(lldb::ModuleSP module,
                                                      StreamWriter &&writer) {
  const ArchSpec &architecture = module->GetArchitecture();
  ByteOrder byte_order = architecture.GetByteOrder();
  uint32_t address_size = architecture.GetAddressByteSize();
  uint32_t byte_size = architecture.GetDataByteSize();
  if (byte_order == eByteOrderInvalid || address_size == 0)
    return DWARFExpression(nullptr);

  RegisterKind register_kind = eRegisterKindDWARF;
  StreamBuffer<32> stream(Stream::eBinary, address_size, byte_order);

  if (!writer(stream, register_kind))
    return DWARFExpression(nullptr);

  DataBufferSP buffer =
      std::make_shared<DataBufferHeap>(stream.GetData(), stream.GetSize());
  DataExtractor extractor(buffer, byte_order, address_size, byte_size);
  DWARFExpression result(module, extractor, nullptr, 0, buffer->GetByteSize());
  result.SetRegisterKind(register_kind);

  return result;
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:23,代码来源:DWARFLocationExpression.cpp


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