1//===-- DataExtractor.h -----------------------------------------*- C++ -*-===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 9#ifndef LLVM_SUPPORT_DATAEXTRACTOR_H 10#define LLVM_SUPPORT_DATAEXTRACTOR_H 18/// An auxiliary type to facilitate extraction of 3-byte entities. 28int LoIx = IsLittleEndian ? 0 : 2;
34static_assert(
sizeof(
uint24_t) == 3,
"sizeof(uint24_t) != 3");
36/// Needed by swapByteOrder(). 46 /// A class representing a position in a DataExtractor, as well as any error 47 /// encountered during extraction. It enables one to extract a sequence of 48 /// values without error-checking and then checking for errors in bulk at the 49 /// end. The class holds an Error object, so failing to check the result of 50 /// the parse will result in a runtime error. The error flag is sticky and 51 /// will cause all subsequent extraction functions to fail without even 52 /// attempting to parse and without updating the Cursor offset. After clearing 53 /// the error flag, one can again use the Cursor object for parsing. 61 /// Construct a cursor for extraction from the given offset. 64 /// Checks whether the cursor is valid (i.e. no errors were encountered). In 65 /// case of errors, this does not clear the error flag -- one must call 66 /// takeError() instead. 67explicitoperatorbool() {
return !Err; }
69 /// Return the current position of this Cursor. In the error state this is 70 /// the position of the Cursor before the first error was encountered. 73 /// Set the cursor to the new offset. This does not impact the error state. 76 /// Return error contained inside this Cursor, if any. Clears the internal 81 /// Construct with a buffer that is owned by the caller. 83 /// This constructor allows us to use data that is owned by the 84 /// caller. The data must stay around as long as this object is 87 : Data(Data), IsLittleEndian(IsLittleEndian), AddressSize(AddressSize) {}
92 IsLittleEndian(IsLittleEndian), AddressSize(AddressSize) {}
94 /// Get the data pointed to by this extractor. 96 /// Get the endianness for this extractor. 98 /// Get the address size for this extractor. 100 /// Set the address size for this extractor. 103 /// Extract a C string from \a *offset_ptr. 105 /// Returns a pointer to a C String from the data at the offset 106 /// pointed to by \a offset_ptr. A variable length NULL terminated C 107 /// string will be extracted and the \a offset_ptr will be 108 /// updated with the offset of the byte that follows the NULL 111 /// @param[in,out] OffsetPtr 112 /// A pointer to an offset within the data that will be advanced 113 /// by the appropriate number of bytes if the value is extracted 114 /// correctly. If the offset is out of bounds or there are not 115 /// enough bytes to extract this value, the offset will be left 118 /// @param[in,out] Err 119 /// A pointer to an Error object. Upon return the Error object is set to 120 /// indicate the result (success/failure) of the function. If the Error 121 /// object is already set when calling this function, no extraction is 125 /// A pointer to the C string value in the data. If the offset 126 /// pointed to by \a offset_ptr is out of bounds, or if the 127 /// offset plus the length of the C string is out of bounds, 128 /// NULL will be returned. 133 /// Extract a C string from the location given by the cursor. In case of an 134 /// extraction error, or if the cursor is already in an error state, a 135 /// nullptr is returned. 138 /// Extract a C string from \a *offset_ptr. 140 /// Returns a StringRef for the C String from the data at the offset 141 /// pointed to by \a offset_ptr. A variable length NULL terminated C 142 /// string will be extracted and the \a offset_ptr will be 143 /// updated with the offset of the byte that follows the NULL 146 /// \param[in,out] OffsetPtr 147 /// A pointer to an offset within the data that will be advanced 148 /// by the appropriate number of bytes if the value is extracted 149 /// correctly. If the offset is out of bounds or there are not 150 /// enough bytes to extract this value, the offset will be left 153 /// @param[in,out] Err 154 /// A pointer to an Error object. Upon return the Error object is set to 155 /// indicate the result (success/failure) of the function. If the Error 156 /// object is already set when calling this function, no extraction is 160 /// A StringRef for the C string value in the data. If the offset 161 /// pointed to by \a offset_ptr is out of bounds, or if the 162 /// offset plus the length of the C string is out of bounds, 163 /// a default-initialized StringRef will be returned. 166 /// Extract a C string (as a StringRef) from the location given by the cursor. 167 /// In case of an extraction error, or if the cursor is already in an error 168 /// state, a default-initialized StringRef is returned. 173 /// Extract a fixed length string from \a *OffsetPtr and consume \a Length 176 /// Returns a StringRef for the string from the data at the offset 177 /// pointed to by \a OffsetPtr. A fixed length C string will be extracted 178 /// and the \a OffsetPtr will be advanced by \a Length bytes. 180 /// \param[in,out] OffsetPtr 181 /// A pointer to an offset within the data that will be advanced 182 /// by the appropriate number of bytes if the value is extracted 183 /// correctly. If the offset is out of bounds or there are not 184 /// enough bytes to extract this value, the offset will be left 187 /// \param[in] Length 188 /// The length of the fixed length string to extract. If there are not 189 /// enough bytes in the data to extract the full string, the offset will 190 /// be left unmodified. 192 /// \param[in] TrimChars 193 /// A set of characters to trim from the end of the string. Fixed length 194 /// strings are commonly either NULL terminated by one or more zero 195 /// bytes. Some clients have one or more spaces at the end of the string, 196 /// but a good default is to trim the NULL characters. 199 /// A StringRef for the C string value in the data. If the offset 200 /// pointed to by \a OffsetPtr is out of bounds, or if the 201 /// offset plus the length of the C string is out of bounds, 202 /// a default-initialized StringRef will be returned. 206 /// Extract a fixed number of bytes from the specified offset. 208 /// Returns a StringRef for the bytes from the data at the offset 209 /// pointed to by \a OffsetPtr. A fixed length C string will be extracted 210 /// and the \a OffsetPtr will be advanced by \a Length bytes. 212 /// \param[in,out] OffsetPtr 213 /// A pointer to an offset within the data that will be advanced 214 /// by the appropriate number of bytes if the value is extracted 215 /// correctly. If the offset is out of bounds or there are not 216 /// enough bytes to extract this value, the offset will be left 219 /// \param[in] Length 220 /// The number of bytes to extract. If there are not enough bytes in the 221 /// data to extract all of the bytes, the offset will be left unmodified. 223 /// @param[in,out] Err 224 /// A pointer to an Error object. Upon return the Error object is set to 225 /// indicate the result (success/failure) of the function. If the Error 226 /// object is already set when calling this function, no extraction is 230 /// A StringRef for the extracted bytes. If the offset pointed to by 231 /// \a OffsetPtr is out of bounds, or if the offset plus the length 232 /// is out of bounds, a default-initialized StringRef will be returned. 234 Error *Err =
nullptr)
const;
236 /// Extract a fixed number of bytes from the location given by the cursor. In 237 /// case of an extraction error, or if the cursor is already in an error 238 /// state, a default-initialized StringRef is returned. 243 /// Extract an unsigned integer of size \a byte_size from \a 246 /// Extract a single unsigned integer value and update the offset 247 /// pointed to by \a offset_ptr. The size of the extracted integer 248 /// is specified by the \a byte_size argument. \a byte_size should 249 /// have a value greater than or equal to one and less than or equal 250 /// to eight since the return value is 64 bits wide. Any 251 /// \a byte_size values less than 1 or greater than 8 will result in 252 /// nothing being extracted, and zero being returned. 254 /// @param[in,out] offset_ptr 255 /// A pointer to an offset within the data that will be advanced 256 /// by the appropriate number of bytes if the value is extracted 257 /// correctly. If the offset is out of bounds or there are not 258 /// enough bytes to extract this value, the offset will be left 261 /// @param[in] byte_size 262 /// The size in byte of the integer to extract. 264 /// @param[in,out] Err 265 /// A pointer to an Error object. Upon return the Error object is set to 266 /// indicate the result (success/failure) of the function. If the Error 267 /// object is already set when calling this function, no extraction is 271 /// The unsigned integer value that was extracted, or zero on 274Error *Err =
nullptr)
const;
276 /// Extract an unsigned integer of the given size from the location given by 277 /// the cursor. In case of an extraction error, or if the cursor is already in 278 /// an error state, zero is returned. 283 /// Extract an signed integer of size \a byte_size from \a *offset_ptr. 285 /// Extract a single signed integer value (sign extending if required) 286 /// and update the offset pointed to by \a offset_ptr. The size of 287 /// the extracted integer is specified by the \a byte_size argument. 288 /// \a byte_size should have a value greater than or equal to one 289 /// and less than or equal to eight since the return value is 64 290 /// bits wide. Any \a byte_size values less than 1 or greater than 291 /// 8 will result in nothing being extracted, and zero being returned. 293 /// @param[in,out] offset_ptr 294 /// A pointer to an offset within the data that will be advanced 295 /// by the appropriate number of bytes if the value is extracted 296 /// correctly. If the offset is out of bounds or there are not 297 /// enough bytes to extract this value, the offset will be left 301 /// The size in bytes of the integer to extract. 304 /// The sign extended signed integer value that was extracted, 305 /// or zero on failure. 308//------------------------------------------------------------------ 309 /// Extract an pointer from \a *offset_ptr. 311 /// Extract a single pointer from the data and update the offset 312 /// pointed to by \a offset_ptr. The size of the extracted pointer 313 /// is \a getAddressSize(), so the address size has to be 314 /// set correctly prior to extracting any pointer values. 316 /// @param[in,out] offset_ptr 317 /// A pointer to an offset within the data that will be advanced 318 /// by the appropriate number of bytes if the value is extracted 319 /// correctly. If the offset is out of bounds or there are not 320 /// enough bytes to extract this value, the offset will be left 324 /// The extracted pointer value as a 64 integer. 329 /// Extract a pointer-sized unsigned integer from the location given by the 330 /// cursor. In case of an extraction error, or if the cursor is already in 331 /// an error state, zero is returned. 334 /// Extract a uint8_t value from \a *offset_ptr. 336 /// Extract a single uint8_t from the binary data at the offset 337 /// pointed to by \a offset_ptr, and advance the offset on success. 339 /// @param[in,out] offset_ptr 340 /// A pointer to an offset within the data that will be advanced 341 /// by the appropriate number of bytes if the value is extracted 342 /// correctly. If the offset is out of bounds or there are not 343 /// enough bytes to extract this value, the offset will be left 346 /// @param[in,out] Err 347 /// A pointer to an Error object. Upon return the Error object is set to 348 /// indicate the result (success/failure) of the function. If the Error 349 /// object is already set when calling this function, no extraction is 353 /// The extracted uint8_t value. 356 /// Extract a single uint8_t value from the location given by the cursor. In 357 /// case of an extraction error, or if the cursor is already in an error 358 /// state, zero is returned. 361 /// Extract \a count uint8_t values from \a *offset_ptr. 363 /// Extract \a count uint8_t values from the binary data at the 364 /// offset pointed to by \a offset_ptr, and advance the offset on 365 /// success. The extracted values are copied into \a dst. 367 /// @param[in,out] offset_ptr 368 /// A pointer to an offset within the data that will be advanced 369 /// by the appropriate number of bytes if the value is extracted 370 /// correctly. If the offset is out of bounds or there are not 371 /// enough bytes to extract this value, the offset will be left 375 /// A buffer to copy \a count uint8_t values into. \a dst must 376 /// be large enough to hold all requested data. 379 /// The number of uint8_t values to extract. 382 /// \a dst if all values were properly extracted and copied, 386 /// Extract \a Count uint8_t values from the location given by the cursor and 387 /// store them into the destination buffer. In case of an extraction error, or 388 /// if the cursor is already in an error state, a nullptr is returned and the 389 /// destination buffer is left unchanged. 392 /// Extract \a Count uint8_t values from the location given by the cursor and 393 /// store them into the destination vector. The vector is resized to fit the 394 /// extracted data. In case of an extraction error, or if the cursor is 395 /// already in an error state, the destination vector is left unchanged and 396 /// cursor is placed into an error state. 401// This relies on the fact that getU8 will not attempt to write to the 402// buffer if isValidOffsetForDataOfSize(C.Offset, Count) is false. 403getU8(
C, Dst.data(), Count);
406//------------------------------------------------------------------ 407 /// Extract a uint16_t value from \a *offset_ptr. 409 /// Extract a single uint16_t from the binary data at the offset 410 /// pointed to by \a offset_ptr, and update the offset on success. 412 /// @param[in,out] offset_ptr 413 /// A pointer to an offset within the data that will be advanced 414 /// by the appropriate number of bytes if the value is extracted 415 /// correctly. If the offset is out of bounds or there are not 416 /// enough bytes to extract this value, the offset will be left 419 /// @param[in,out] Err 420 /// A pointer to an Error object. Upon return the Error object is set to 421 /// indicate the result (success/failure) of the function. If the Error 422 /// object is already set when calling this function, no extraction is 426 /// The extracted uint16_t value. 427//------------------------------------------------------------------ 430 /// Extract a single uint16_t value from the location given by the cursor. In 431 /// case of an extraction error, or if the cursor is already in an error 432 /// state, zero is returned. 435 /// Extract \a count uint16_t values from \a *offset_ptr. 437 /// Extract \a count uint16_t values from the binary data at the 438 /// offset pointed to by \a offset_ptr, and advance the offset on 439 /// success. The extracted values are copied into \a dst. 441 /// @param[in,out] offset_ptr 442 /// A pointer to an offset within the data that will be advanced 443 /// by the appropriate number of bytes if the value is extracted 444 /// correctly. If the offset is out of bounds or there are not 445 /// enough bytes to extract this value, the offset will be left 449 /// A buffer to copy \a count uint16_t values into. \a dst must 450 /// be large enough to hold all requested data. 453 /// The number of uint16_t values to extract. 456 /// \a dst if all values were properly extracted and copied, 460 /// Extract a 24-bit unsigned value from \a *offset_ptr and return it 463 /// Extract 3 bytes from the binary data at the offset pointed to by 464 /// \a offset_ptr, construct a uint32_t from them and update the offset 467 /// @param[in,out] OffsetPtr 468 /// A pointer to an offset within the data that will be advanced 469 /// by the 3 bytes if the value is extracted correctly. If the offset 470 /// is out of bounds or there are not enough bytes to extract this value, 471 /// the offset will be left unmodified. 473 /// @param[in,out] Err 474 /// A pointer to an Error object. Upon return the Error object is set to 475 /// indicate the result (success/failure) of the function. If the Error 476 /// object is already set when calling this function, no extraction is 480 /// The extracted 24-bit value represented in a uint32_t. 483 /// Extract a single 24-bit unsigned value from the location given by the 484 /// cursor. In case of an extraction error, or if the cursor is already in an 485 /// error state, zero is returned. 488 /// Extract a uint32_t value from \a *offset_ptr. 490 /// Extract a single uint32_t from the binary data at the offset 491 /// pointed to by \a offset_ptr, and update the offset on success. 493 /// @param[in,out] offset_ptr 494 /// A pointer to an offset within the data that will be advanced 495 /// by the appropriate number of bytes if the value is extracted 496 /// correctly. If the offset is out of bounds or there are not 497 /// enough bytes to extract this value, the offset will be left 500 /// @param[in,out] Err 501 /// A pointer to an Error object. Upon return the Error object is set to 502 /// indicate the result (success/failure) of the function. If the Error 503 /// object is already set when calling this function, no extraction is 507 /// The extracted uint32_t value. 510 /// Extract a single uint32_t value from the location given by the cursor. In 511 /// case of an extraction error, or if the cursor is already in an error 512 /// state, zero is returned. 515 /// Extract \a count uint32_t values from \a *offset_ptr. 517 /// Extract \a count uint32_t values from the binary data at the 518 /// offset pointed to by \a offset_ptr, and advance the offset on 519 /// success. The extracted values are copied into \a dst. 521 /// @param[in,out] offset_ptr 522 /// A pointer to an offset within the data that will be advanced 523 /// by the appropriate number of bytes if the value is extracted 524 /// correctly. If the offset is out of bounds or there are not 525 /// enough bytes to extract this value, the offset will be left 529 /// A buffer to copy \a count uint32_t values into. \a dst must 530 /// be large enough to hold all requested data. 533 /// The number of uint32_t values to extract. 536 /// \a dst if all values were properly extracted and copied, 540 /// Extract a uint64_t value from \a *offset_ptr. 542 /// Extract a single uint64_t from the binary data at the offset 543 /// pointed to by \a offset_ptr, and update the offset on success. 545 /// @param[in,out] offset_ptr 546 /// A pointer to an offset within the data that will be advanced 547 /// by the appropriate number of bytes if the value is extracted 548 /// correctly. If the offset is out of bounds or there are not 549 /// enough bytes to extract this value, the offset will be left 552 /// @param[in,out] Err 553 /// A pointer to an Error object. Upon return the Error object is set to 554 /// indicate the result (success/failure) of the function. If the Error 555 /// object is already set when calling this function, no extraction is 559 /// The extracted uint64_t value. 562 /// Extract a single uint64_t value from the location given by the cursor. In 563 /// case of an extraction error, or if the cursor is already in an error 564 /// state, zero is returned. 567 /// Extract \a count uint64_t values from \a *offset_ptr. 569 /// Extract \a count uint64_t values from the binary data at the 570 /// offset pointed to by \a offset_ptr, and advance the offset on 571 /// success. The extracted values are copied into \a dst. 573 /// @param[in,out] offset_ptr 574 /// A pointer to an offset within the data that will be advanced 575 /// by the appropriate number of bytes if the value is extracted 576 /// correctly. If the offset is out of bounds or there are not 577 /// enough bytes to extract this value, the offset will be left 581 /// A buffer to copy \a count uint64_t values into. \a dst must 582 /// be large enough to hold all requested data. 585 /// The number of uint64_t values to extract. 588 /// \a dst if all values were properly extracted and copied, 592 /// Extract a signed LEB128 value from \a *offset_ptr. 594 /// Extracts an signed LEB128 number from this object's data 595 /// starting at the offset pointed to by \a offset_ptr. The offset 596 /// pointed to by \a offset_ptr will be updated with the offset of 597 /// the byte following the last extracted byte. 599 /// @param[in,out] OffsetPtr 600 /// A pointer to an offset within the data that will be advanced 601 /// by the appropriate number of bytes if the value is extracted 602 /// correctly. If the offset is out of bounds or there are not 603 /// enough bytes to extract this value, the offset will be left 606 /// @param[in,out] Err 607 /// A pointer to an Error object. Upon return the Error object is set to 608 /// indicate the result (success/failure) of the function. If the Error 609 /// object is already set when calling this function, no extraction is 613 /// The extracted signed integer value. 616 /// Extract an signed LEB128 value from the location given by the cursor. 617 /// In case of an extraction error, or if the cursor is already in an error 618 /// state, zero is returned. 621 /// Extract a unsigned LEB128 value from \a *offset_ptr. 623 /// Extracts an unsigned LEB128 number from this object's data 624 /// starting at the offset pointed to by \a offset_ptr. The offset 625 /// pointed to by \a offset_ptr will be updated with the offset of 626 /// the byte following the last extracted byte. 628 /// @param[in,out] offset_ptr 629 /// A pointer to an offset within the data that will be advanced 630 /// by the appropriate number of bytes if the value is extracted 631 /// correctly. If the offset is out of bounds or there are not 632 /// enough bytes to extract this value, the offset will be left 635 /// @param[in,out] Err 636 /// A pointer to an Error object. Upon return the Error object is set to 637 /// indicate the result (success/failure) of the function. If the Error 638 /// object is already set when calling this function, no extraction is 642 /// The extracted unsigned integer value. 645 /// Extract an unsigned LEB128 value from the location given by the cursor. 646 /// In case of an extraction error, or if the cursor is already in an error 647 /// state, zero is returned. 650 /// Advance the Cursor position by the given number of bytes. No-op if the 651 /// cursor is in an error state. 654 /// Return true iff the cursor is at the end of the buffer, regardless of the 655 /// error state of the cursor. The only way both eof and error states can be 656 /// true is if one attempts a read while the cursor is at the very end of the 660 /// Test the validity of \a offset. 663 /// \b true if \a offset is a valid offset into the data in this 664 /// object, \b false otherwise. 667 /// Test the availability of \a length bytes of data from \a offset. 670 /// \b true if \a offset is a valid offset and there are \a 671 /// length bytes available at that offset, \b false otherwise. 673return offset + length >= offset &&
isValidOffset(offset + length - 1);
676 /// Test the availability of enough bytes of data for a pointer from 677 /// \a offset. The size of a pointer is \a getAddressSize(). 680 /// \b true if \a offset is a valid offset and there are enough 681 /// bytes for a pointer available at that offset, \b false 687 /// Return the number of bytes in the underlying buffer. 688size_tsize()
const{
return Data.size(); }
691// Make it possible for subclasses to access these fields without making them 697 /// If it is possible to read \a Size bytes at offset \a Offset, returns \b 698 /// true. Otherwise, returns \b false. If \a E is not nullptr, also sets the 699 /// error object to indicate an error. static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
A class representing a position in a DataExtractor, as well as any error encountered during extractio...
Cursor(uint64_t Offset)
Construct a cursor for extraction from the given offset.
uint64_t tell() const
Return the current position of this Cursor.
Error takeError()
Return error contained inside this Cursor, if any.
void seek(uint64_t NewOffSet)
Set the cursor to the new offset. This does not impact the error state.
StringRef getFixedLengthString(uint64_t *OffsetPtr, uint64_t Length, StringRef TrimChars={"\0", 1}) const
Extract a fixed length string from *OffsetPtr and consume Length bytes.
uint32_t getU32(Cursor &C) const
Extract a single uint32_t value from the location given by the cursor.
uint64_t getUnsigned(uint64_t *offset_ptr, uint32_t byte_size, Error *Err=nullptr) const
Extract an unsigned integer of size byte_size from *offset_ptr.
uint32_t getU32(uint64_t *offset_ptr, Error *Err=nullptr) const
Extract a uint32_t value from *offset_ptr.
size_t size() const
Return the number of bytes in the underlying buffer.
const char * getCStr(uint64_t *OffsetPtr, Error *Err=nullptr) const
Extract a C string from *offset_ptr.
void getU8(Cursor &C, SmallVectorImpl< uint8_t > &Dst, uint32_t Count) const
Extract Count uint8_t values from the location given by the cursor and store them into the destinatio...
int64_t getSLEB128(Cursor &C) const
Extract an signed LEB128 value from the location given by the cursor.
static uint64_t & getOffset(Cursor &C)
bool eof(const Cursor &C) const
Return true iff the cursor is at the end of the buffer, regardless of the error state of the cursor.
StringRef getCStrRef(uint64_t *OffsetPtr, Error *Err=nullptr) const
Extract a C string from *offset_ptr.
uint64_t getAddress(uint64_t *offset_ptr) const
Extract an pointer from *offset_ptr.
uint8_t getU8(uint64_t *offset_ptr, Error *Err=nullptr) const
Extract a uint8_t value from *offset_ptr.
DataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
Construct with a buffer that is owned by the caller.
int64_t getSigned(uint64_t *offset_ptr, uint32_t size) const
Extract an signed integer of size byte_size from *offset_ptr.
uint64_t getULEB128(uint64_t *offset_ptr, llvm::Error *Err=nullptr) const
Extract a unsigned LEB128 value from *offset_ptr.
uint8_t getAddressSize() const
Get the address size for this extractor.
uint64_t getUnsigned(Cursor &C, uint32_t Size) const
Extract an unsigned integer of the given size from the location given by the cursor.
uint64_t getULEB128(Cursor &C) const
Extract an unsigned LEB128 value from the location given by the cursor.
uint32_t getU24(Cursor &C) const
Extract a single 24-bit unsigned value from the location given by the cursor.
DataExtractor(ArrayRef< uint8_t > Data, bool IsLittleEndian, uint8_t AddressSize)
StringRef getData() const
Get the data pointed to by this extractor.
int64_t getSLEB128(uint64_t *OffsetPtr, Error *Err=nullptr) const
Extract a signed LEB128 value from *offset_ptr.
StringRef getCStrRef(Cursor &C) const
Extract a C string (as a StringRef) from the location given by the cursor.
StringRef getBytes(Cursor &C, uint64_t Length)
Extract a fixed number of bytes from the location given by the cursor.
const char * getCStr(Cursor &C) const
Extract a C string from the location given by the cursor.
uint16_t getU16(uint64_t *offset_ptr, Error *Err=nullptr) const
Extract a uint16_t value from *offset_ptr.
uint16_t getU16(Cursor &C) const
Extract a single uint16_t value from the location given by the cursor.
void skip(Cursor &C, uint64_t Length) const
Advance the Cursor position by the given number of bytes.
uint64_t getU64(Cursor &C) const
Extract a single uint64_t value from the location given by the cursor.
uint64_t getU64(uint64_t *offset_ptr, Error *Err=nullptr) const
Extract a uint64_t value from *offset_ptr.
uint8_t getU8(Cursor &C) const
Extract a single uint8_t value from the location given by the cursor.
void setAddressSize(uint8_t Size)
Set the address size for this extractor.
static Error & getError(Cursor &C)
bool isValidOffset(uint64_t offset) const
Test the validity of offset.
bool isValidOffsetForDataOfSize(uint64_t offset, uint64_t length) const
Test the availability of length bytes of data from offset.
bool isLittleEndian() const
Get the endianness for this extractor.
uint64_t getAddress(Cursor &C) const
Extract a pointer-sized unsigned integer from the location given by the cursor.
StringRef getBytes(uint64_t *OffsetPtr, uint64_t Length, Error *Err=nullptr) const
Extract a fixed number of bytes from the specified offset.
uint32_t getU24(uint64_t *OffsetPtr, Error *Err=nullptr) const
Extract a 24-bit unsigned value from *offset_ptr and return it in a uint32_t.
bool isValidOffsetForAddress(uint64_t offset) const
Test the availability of enough bytes of data for a pointer from offset.
Lightweight error class with error context and mandatory checking.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
uint24_t getSwappedBytes(uint24_t C)
Needed by swapByteOrder().
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
An auxiliary type to facilitate extraction of 3-byte entities.
uint32_t getAsUint32(bool IsLittleEndian) const
Uint24(uint8_t U0, uint8_t U1, uint8_t U2)