本文整理汇总了C++中MutableArrayRef::data方法的典型用法代码示例。如果您正苦于以下问题:C++ MutableArrayRef::data方法的具体用法?C++ MutableArrayRef::data怎么用?C++ MutableArrayRef::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MutableArrayRef
的用法示例。
在下文中一共展示了MutableArrayRef::data方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readBytes
Error MappedBlockStream::readBytes(uint32_t Offset,
MutableArrayRef<uint8_t> Buffer) const {
uint32_t BlockNum = Offset / Pdb.getBlockSize();
uint32_t OffsetInBlock = Offset % Pdb.getBlockSize();
// Make sure we aren't trying to read beyond the end of the stream.
if (Buffer.size() > Data->getLength())
return make_error<RawError>(raw_error_code::insufficient_buffer);
if (Offset > Data->getLength() - Buffer.size())
return make_error<RawError>(raw_error_code::insufficient_buffer);
uint32_t BytesLeft = Buffer.size();
uint32_t BytesWritten = 0;
uint8_t *WriteBuffer = Buffer.data();
auto BlockList = Data->getStreamBlocks();
while (BytesLeft > 0) {
uint32_t StreamBlockAddr = BlockList[BlockNum];
auto Data = Pdb.getBlockData(StreamBlockAddr, Pdb.getBlockSize());
const uint8_t *ChunkStart = Data.data() + OffsetInBlock;
uint32_t BytesInChunk =
std::min(BytesLeft, Pdb.getBlockSize() - OffsetInBlock);
::memcpy(WriteBuffer + BytesWritten, ChunkStart, BytesInChunk);
BytesWritten += BytesInChunk;
BytesLeft -= BytesInChunk;
++BlockNum;
OffsetInBlock = 0;
}
return Error::success();
}
示例2: readBytes
std::error_code ByteStream::readBytes(uint32_t Offset,
MutableArrayRef<uint8_t> Buffer) const {
if (Data.size() < Buffer.size() + Offset)
return std::make_error_code(std::errc::bad_address);
::memcpy(Buffer.data(), Data.data() + Offset, Buffer.size());
return std::error_code();
}
示例3: readBytes
Error MappedBlockStream::readBytes(uint32_t Offset,
MutableArrayRef<uint8_t> Buffer) const {
uint32_t BlockNum = Offset / BlockSize;
uint32_t OffsetInBlock = Offset % BlockSize;
// Make sure we aren't trying to read beyond the end of the stream.
if (Buffer.size() > StreamLayout.Length)
return make_error<MSFError>(msf_error_code::insufficient_buffer);
if (Offset > StreamLayout.Length - Buffer.size())
return make_error<MSFError>(msf_error_code::insufficient_buffer);
uint32_t BytesLeft = Buffer.size();
uint32_t BytesWritten = 0;
uint8_t *WriteBuffer = Buffer.data();
while (BytesLeft > 0) {
uint32_t StreamBlockAddr = StreamLayout.Blocks[BlockNum];
ArrayRef<uint8_t> BlockData;
uint32_t Offset = blockToOffset(StreamBlockAddr, BlockSize);
if (auto EC = MsfData.readBytes(Offset, BlockSize, BlockData))
return EC;
const uint8_t *ChunkStart = BlockData.data() + OffsetInBlock;
uint32_t BytesInChunk = std::min(BytesLeft, BlockSize - OffsetInBlock);
::memcpy(WriteBuffer + BytesWritten, ChunkStart, BytesInChunk);
BytesWritten += BytesInChunk;
BytesLeft -= BytesInChunk;
++BlockNum;
OffsetInBlock = 0;
}
return Error::success();
}
示例4: readBytes
Error ByteStream::readBytes(uint32_t Offset,
MutableArrayRef<uint8_t> Buffer) const {
if (Data.size() < Buffer.size() + Offset)
return make_error<RawError>(raw_error_code::insufficient_buffer);
::memcpy(Buffer.data(), Data.data() + Offset, Buffer.size());
return Error::success();
}
示例5: writeBytes
static Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Src,
MutableArrayRef<uint8_t> Dest) {
if (Dest.size() < Src.size())
return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
if (Offset > Src.size() - Dest.size())
return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
::memcpy(Dest.data() + Offset, Src.data(), Src.size());
return Error::success();
}
示例6: remapTypesInSymbolRecord
static bool remapTypesInSymbolRecord(ObjectFile *File,
MutableArrayRef<uint8_t> Contents,
ArrayRef<TypeIndex> TypeIndexMap,
ArrayRef<TiReference> TypeRefs) {
for (const TiReference &Ref : TypeRefs) {
unsigned ByteSize = Ref.Count * sizeof(TypeIndex);
if (Contents.size() < Ref.Offset + ByteSize) {
log("ignoring short symbol record");
return false;
}
MutableArrayRef<TypeIndex> TIs(
reinterpret_cast<TypeIndex *>(Contents.data() + Ref.Offset), Ref.Count);
for (TypeIndex &TI : TIs)
if (!remapTypeIndex(TI, TypeIndexMap)) {
log("ignoring symbol record in " + File->getName() +
" with bad type index 0x" + utohexstr(TI.getIndex()));
return false;
}
}
return true;
}