[llvm] r204693 - Support: Functions for consuming endian specific data from a buffer.

Justin Bogner mail at justinbogner.com
Mon Mar 24 18:04:45 PDT 2014


Author: bogner
Date: Mon Mar 24 20:04:44 2014
New Revision: 204693

URL: http://llvm.org/viewvc/llvm-project?rev=204693&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/Support/Endian.h

Modified: llvm/trunk/include/llvm/Support/Endian.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Endian.h?rev=204693&r1=204692&r2=204693&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Endian.h (original)
+++ llvm/trunk/include/llvm/Support/Endian.h Mon Mar 24 20:04:44 2014
@@ -56,6 +56,15 @@ inline value_type read(const void *memor
   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,





More information about the llvm-commits mailing list