diff options
author | Justin Bogner <mail@justinbogner.com> | 2014-03-25 01:04:44 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2014-03-25 01:04:44 +0000 |
commit | 93065647b8f0295434bd12aca58a0d0bd6323ffa (patch) | |
tree | 5334c39940621e74da7381d728cf6f15fedd9729 /include | |
parent | 692d1830f3fc0fc583f1bb84f9ab3574bc546e3b (diff) | |
download | llvm-93065647b8f0295434bd12aca58a0d0bd6323ffa.tar.gz llvm-93065647b8f0295434bd12aca58a0d0bd6323ffa.tar.bz2 llvm-93065647b8f0295434bd12aca58a0d0bd6323ffa.tar.xz |
Support: Functions for consuming endian specific data from a buffer.
This adds a function to Endian.h that reads from and updates a pointer
into a buffer with endian specific data. This is more convenient for
stream-like reading of data than endian::read.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204693 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/Endian.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/llvm/Support/Endian.h b/include/llvm/Support/Endian.h index 81690605e8..2c5ab74aa3 100644 --- a/include/llvm/Support/Endian.h +++ b/include/llvm/Support/Endian.h @@ -56,6 +56,15 @@ inline value_type read(const void *memory) { return byte_swap<value_type, endian>(ret); } +/// Read a value of a particular endianness from a buffer, and increment the +/// buffer past that value. +template<typename value_type, endianness endian, std::size_t alignment> +inline value_type readNext(const unsigned char *&memory) { + value_type ret = read<value_type, endian, alignment>(memory); + memory += sizeof(value_type); + return ret; +} + /// Write a value to memory with a particular endianness. template<typename value_type, endianness endian, |