LLVM: llvm::yaml::BinaryRef Class Reference (original) (raw)
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:
struct FooHolder {
BinaryRef Foo;
};
template <>
static void mapping(IO &IO, FooHolder &FH) {
}
};
}
}
void mapRequired(StringRef Key, T &Val)
This is an optimization pass for GlobalISel generic memory operations.
This class should be specialized by any type that needs to be converted to/from a YAML mapping.