本文整理汇总了C++中llvm::ArrayRef::data方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayRef::data方法的具体用法?C++ ArrayRef::data怎么用?C++ ArrayRef::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::ArrayRef
的用法示例。
在下文中一共展示了ArrayRef::data方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: consumeObject
// Minidump string
llvm::Optional<std::string>
lldb_private::minidump::parseMinidumpString(llvm::ArrayRef<uint8_t> &data) {
std::string result;
const uint32_t *source_length;
Status error = consumeObject(data, source_length);
if (error.Fail() || *source_length > data.size() || *source_length % 2 != 0)
return llvm::None;
auto source_start = reinterpret_cast<const llvm::UTF16 *>(data.data());
// source_length is the length of the string in bytes
// we need the length of the string in UTF-16 characters/code points (16 bits
// per char)
// that's why it's divided by 2
const auto source_end = source_start + (*source_length) / 2;
// resize to worst case length
result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * (*source_length) / 2);
auto result_start = reinterpret_cast<llvm::UTF8 *>(&result[0]);
const auto result_end = result_start + result.size();
llvm::ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end,
llvm::strictConversion);
const auto result_size =
std::distance(reinterpret_cast<llvm::UTF8 *>(&result[0]), result_start);
result.resize(result_size); // shrink to actual length
return result;
}
示例2:
void
PythonBytes::SetBytes(llvm::ArrayRef<uint8_t> bytes)
{
const char *data = reinterpret_cast<const char *>(bytes.data());
PyObject *py_bytes = PyBytes_FromStringAndSize(data, bytes.size());
PythonObject::Reset(PyRefType::Owned, py_bytes);
}
示例3: DumpDWARFExpr
static void DumpDWARFExpr(Stream &s, llvm::ArrayRef<uint8_t> expr, Thread *thread) {
if (auto order_and_width = GetByteOrderAndAddrSize(thread)) {
DataExtractor extractor(expr.data(), expr.size(), order_and_width->first,
order_and_width->second);
if (!DWARFExpression::PrintDWARFExpression(s, extractor,
order_and_width->second,
/*dwarf_ref_size*/ 4,
/*location_expression*/ false))
s.PutCString("invalid-dwarf-expr");
} else
s.PutCString("dwarf-expr");
}
示例4: makeArrayRef
llvm::ArrayRef<MinidumpMemoryDescriptor>
MinidumpMemoryDescriptor::ParseMemoryList(llvm::ArrayRef<uint8_t> &data) {
const llvm::support::ulittle32_t *mem_ranges_count;
Status error = consumeObject(data, mem_ranges_count);
if (error.Fail() ||
*mem_ranges_count * sizeof(MinidumpMemoryDescriptor) > data.size())
return {};
return llvm::makeArrayRef(
reinterpret_cast<const MinidumpMemoryDescriptor *>(data.data()),
*mem_ranges_count);
}
示例5: write
/// \brief Write a block of data, and get the offset that it starts at.
/// \param Bytes the array of bytes to be written.
/// \return the offset that this block was written at.
///
offset_uint write(llvm::ArrayRef<char> Bytes) {
// If the stream doesn't exist, silently ignore the write request.
if (!Out)
return noOffset();
auto const Size = Bytes.size();
Out->write(Bytes.data(), Size);
// Update the current offset and return the original value.
auto const WrittenAt = Offset;
Offset += Size;
return WrittenAt;
}
示例6: make_pair
std::pair<llvm::ArrayRef<MinidumpMemoryDescriptor64>, uint64_t>
MinidumpMemoryDescriptor64::ParseMemory64List(llvm::ArrayRef<uint8_t> &data) {
const llvm::support::ulittle64_t *mem_ranges_count;
Status error = consumeObject(data, mem_ranges_count);
if (error.Fail() ||
*mem_ranges_count * sizeof(MinidumpMemoryDescriptor64) > data.size())
return {};
const llvm::support::ulittle64_t *base_rva;
error = consumeObject(data, base_rva);
if (error.Fail())
return {};
return std::make_pair(
llvm::makeArrayRef(
reinterpret_cast<const MinidumpMemoryDescriptor64 *>(data.data()),
*mem_ranges_count),
*base_rva);
}
示例7:
// Linux Proc Status
// it's stored as an ascii string in the file
llvm::Optional<LinuxProcStatus>
LinuxProcStatus::Parse(llvm::ArrayRef<uint8_t> &data) {
LinuxProcStatus result;
result.proc_status =
llvm::StringRef(reinterpret_cast<const char *>(data.data()), data.size());
data = data.drop_front(data.size());
llvm::SmallVector<llvm::StringRef, 0> lines;
result.proc_status.split(lines, '\n', 42);
// /proc/$pid/status has 41 lines, but why not use 42?
for (auto line : lines) {
if (line.consume_front("Pid:")) {
line = line.trim();
if (!line.getAsInteger(10, result.pid))
return result;
}
}
return llvm::None;
}
示例8: PythonByteArray
PythonByteArray::PythonByteArray(llvm::ArrayRef<uint8_t> bytes)
: PythonByteArray(bytes.data(), bytes.size()) {}