class BinaryRef
Declaration
class BinaryRef { /* full declaration omitted */ };
Description
Specialized YAMLIO scalar type for representing a binary blob. A typical use case would be to represent the content of a section in a binary file. This class has custom YAMLIO traits for convenient reading and writing. It renders as a string of hex digits in a YAML file. For example, it might render as `DEADBEEFCAFEBABE` (YAML does not require the quotation marks, so for simplicity when outputting they are omitted). When reading, any string whose content is an even number of hex digits will be accepted. For example, all of the following are acceptable: `DEADBEEF`, `"DeADbEeF"`, `"\x44EADBEEF"` (Note: '\x44' == 'D') A significant advantage of using this class is that it never allocates temporary strings or buffers for any of its functionality. Example: The YAML mapping: Could be modeled in YAMLIO by the struct:
Declared at: llvm/include/llvm/ObjectYAML/YAML.h:63
Member Variables
- private ArrayRef<uint8_t> Data
- Either raw binary data, or a string of hex bytes (must always be an even number of characters).
- private bool DataIsHexString = true
- Discriminator between the two states of the `Data` member.
Method Overview
- public BinaryRef()
- public BinaryRef(ArrayRef<uint8_t> Data)
- public BinaryRef(llvm::StringRef Data)
- public ArrayRef<uint8_t>::size_type binary_size() const
- public void writeAsBinary(llvm::raw_ostream & OS, uint64_t N = (18446744073709551615UL)) const
- public void writeAsHex(llvm::raw_ostream & OS) const
Methods
¶BinaryRef()
BinaryRef()
Declared at: llvm/include/llvm/ObjectYAML/YAML.h:74
¶BinaryRef(ArrayRef<uint8_t> Data)
BinaryRef(ArrayRef<uint8_t> Data)
Declared at: llvm/include/llvm/ObjectYAML/YAML.h:75
Parameters
- ArrayRef<uint8_t> Data
¶BinaryRef(llvm::StringRef Data)
BinaryRef(llvm::StringRef Data)
Declared at: llvm/include/llvm/ObjectYAML/YAML.h:76
Parameters
- llvm::StringRef Data
¶ArrayRef<uint8_t>::size_type binary_size() const
ArrayRef<uint8_t>::size_type binary_size() const
Description
The number of bytes that are represented by this BinaryRef. This is the number of bytes that writeAsBinary() will write.
Declared at: llvm/include/llvm/ObjectYAML/YAML.h:80
¶void writeAsBinary(
llvm::raw_ostream& OS,
uint64_t N = (18446744073709551615UL)) const
void writeAsBinary(
llvm::raw_ostream& OS,
uint64_t N = (18446744073709551615UL)) const
Description
Write the contents (regardless of whether it is binary or a hex string) as binary to the given raw_ostream. N can be used to specify the maximum number of bytes.
Declared at: llvm/include/llvm/ObjectYAML/YAML.h:89
Parameters
- llvm::raw_ostream& OS
- uint64_t N = (18446744073709551615UL)
¶void writeAsHex(llvm::raw_ostream& OS) const
void writeAsHex(llvm::raw_ostream& OS) const
Description
Write the contents (regardless of whether it is binary or a hex string) as hex to the given raw_ostream. For example, a possible output could be `DEADBEEFCAFEBABE`.
Declared at: llvm/include/llvm/ObjectYAML/YAML.h:95