[Liblas-commits] hg-main-tree: add SWAP_LE_TO_BE method. Note that this is exact...

liblas-commits at liblas.org liblas-commits at liblas.org
Wed May 25 14:30:33 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/f76e3f575913
changeset: 736:f76e3f575913
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed May 25 13:30:18 2011 -0500
description:
add SWAP_LE_TO_BE method.  Note that this is exactly the same code as SWAP_BE_TO_LE which is merely just a byte swapping function.  It is valuable to read which way we're actually going in source code, however

diffstat:

 include/libpc/drivers/oci/Endian.hpp |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (20 lines):

diff -r e909219b4c5f -r f76e3f575913 include/libpc/drivers/oci/Endian.hpp
--- a/include/libpc/drivers/oci/Endian.hpp	Wed May 25 11:49:46 2011 -0500
+++ b/include/libpc/drivers/oci/Endian.hpp	Wed May 25 13:30:18 2011 -0500
@@ -58,6 +58,16 @@
             *first = x; \
         }} while(false)
 
+# define SWAP_LE_TO_BE(p) \
+    do { \
+        char* first = static_cast<char*>(static_cast<void*>(&p)); \
+        char* last = first + sizeof(p) - 1; \
+        for(; first < last; ++first, --last) { \
+            char const x = *last; \
+            *last = *first; \
+            *first = x; \
+        }} while(false)
+
 # define SWAP_BE_TO_LE_N(p, n) \
     do { \
         char* first = static_cast<char*>(static_cast<void*>(&p)); \


More information about the Liblas-commits mailing list