From: Justin Bogner Date: Tue, 25 Mar 2014 01:04:44 +0000 (+0000) Subject: Support: Functions for consuming endian specific data from a buffer. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=93065647b8f0295434bd12aca58a0d0bd6323ffa;p=oota-llvm.git 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 --- diff --git a/include/llvm/Support/Endian.h b/include/llvm/Support/Endian.h index 81690605e87..2c5ab74aa36 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(ret); } +/// Read a value of a particular endianness from a buffer, and increment the +/// buffer past that value. +template +inline value_type readNext(const unsigned char *&memory) { + value_type ret = read(memory); + memory += sizeof(value_type); + return ret; +} + /// Write a value to memory with a particular endianness. template