[Liblas-commits] hg-main-tree: add SWAP_LE_TO_BE_N method

liblas-commits at liblas.org liblas-commits at liblas.org
Wed May 25 14:58:43 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/49bdff0df0be
changeset: 738:49bdff0df0be
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed May 25 13:52:55 2011 -0500
description:
add SWAP_LE_TO_BE_N method
Subject: hg-main-tree: consolidate endianness handling for ByteSwappingFilter's usage as well as Oracle's

details:   http://hg.libpc.orghg-main-tree/rev/a2d1322426b1
changeset: 739:a2d1322426b1
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed May 25 13:58:37 2011 -0500
description:
consolidate endianness handling for ByteSwappingFilter's usage as well as Oracle's

diffstat:

 include/libpc/Endian.hpp             |  91 ++++++++++++++++++++++++++++++++++++
 include/libpc/drivers/oci/Common.hpp |   2 +-
 include/libpc/drivers/oci/Endian.hpp |  81 --------------------------------
 3 files changed, 92 insertions(+), 82 deletions(-)

diffs (192 lines):

diff -r f0ecde445a89 -r a2d1322426b1 include/libpc/Endian.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/Endian.hpp	Wed May 25 13:58:37 2011 -0500
@@ -0,0 +1,91 @@
+// Stolen from libLAS' endian.hpp
+/******************************************************************************
+ * $Id$
+ *
+ * Project:  libLAS - http://liblas.org - A BSD library for LAS format data.
+ * Purpose:  Endian macros
+ * Author:   Mateusz Loskot, mateusz at loskot.net
+ *
+ * This file has been stolen from <boost/endian.hpp> and
+ * modified for libLAS purposes.
+ * 
+ * (C) Copyright Mateusz Loskot 2007, mateusz at loskot.net
+ * (C) Copyright Caleb Epstein 2005
+ * (C) Copyright John Maddock 2006
+ * Distributed under the Boost  Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ * 
+ * Revision History
+ * 06 Feb 2006 - Initial Revision
+ * 09 Nov 2006 - fixed variant and version bits for v4 guids
+ * 13 Nov 2006 - added serialization
+ * 17 Nov 2006 - added name-based guid creation
+ * 20 Nov 2006 - add fixes for gcc (from Tim Blechmann)
+ * 07 Mar 2007 - converted to header only
+ * 20 Jan 2008 - removed dependency of Boost and modified for libLAS (by Mateusz Loskot)
+ ******************************************************************************
+ *
+ * Copyright (c) 1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.  Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ * 
+ *
+ * Copyright notice reproduced from <boost/detail/limits.hpp>, from
+ * which this code was originally taken.
+ *
+ * Modified by Caleb Epstein to use <endian.h> with GNU libc and to
+ * defined the BOOST_ENDIAN macro.
+ ****************************************************************************/
+#ifndef INCLUDED_LIBPC_ENDIAN_HPP
+#define INCLUDED_LIBPC_ENDIAN_HPP
+
+# define SWAP_BE_TO_LE(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_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)); \
+        char* last = first + n - 1; \
+        for(; first < last; ++first, --last) { \
+            char const x = *last; \
+            *last = *first; \
+            *first = x; \
+        }} while(false)
+
+# define SWAP_LE_TO_BE_N(p, n) \
+    do { \
+        char* first = static_cast<char*>(static_cast<void*>(&p)); \
+        char* last = first + n - 1; \
+        for(; first < last; ++first, --last) { \
+            char const x = *last; \
+            *last = *first; \
+            *first = x; \
+        }} while(false)
+
+#endif
diff -r f0ecde445a89 -r a2d1322426b1 include/libpc/drivers/oci/Common.hpp
--- a/include/libpc/drivers/oci/Common.hpp	Wed May 25 13:40:26 2011 -0500
+++ b/include/libpc/drivers/oci/Common.hpp	Wed May 25 13:58:37 2011 -0500
@@ -40,7 +40,7 @@
 #include <libpc/Options.hpp>
 
 #include "oci_wrapper.h"
-#include "Endian.hpp"
+#include <libpc/Endian.hpp>
 
 #include <boost/shared_ptr.hpp>
 #include <boost/scoped_ptr.hpp>
diff -r f0ecde445a89 -r a2d1322426b1 include/libpc/drivers/oci/Endian.hpp
--- a/include/libpc/drivers/oci/Endian.hpp	Wed May 25 13:40:26 2011 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-// Stolen from libLAS' endian.hpp
-/******************************************************************************
- * $Id$
- *
- * Project:  libLAS - http://liblas.org - A BSD library for LAS format data.
- * Purpose:  Endian macros
- * Author:   Mateusz Loskot, mateusz at loskot.net
- *
- * This file has been stolen from <boost/endian.hpp> and
- * modified for libLAS purposes.
- * 
- * (C) Copyright Mateusz Loskot 2007, mateusz at loskot.net
- * (C) Copyright Caleb Epstein 2005
- * (C) Copyright John Maddock 2006
- * Distributed under the Boost  Software License, Version 1.0.
- * (See accompanying file LICENSE_1_0.txt or copy at
- * http://www.boost.org/LICENSE_1_0.txt)
- * 
- * Revision History
- * 06 Feb 2006 - Initial Revision
- * 09 Nov 2006 - fixed variant and version bits for v4 guids
- * 13 Nov 2006 - added serialization
- * 17 Nov 2006 - added name-based guid creation
- * 20 Nov 2006 - add fixes for gcc (from Tim Blechmann)
- * 07 Mar 2007 - converted to header only
- * 20 Jan 2008 - removed dependency of Boost and modified for libLAS (by Mateusz Loskot)
- ******************************************************************************
- *
- * Copyright (c) 1997
- * Silicon Graphics Computer Systems, Inc.
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation.  Silicon Graphics makes no
- * representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied warranty.
- *
- * 
- *
- * Copyright notice reproduced from <boost/detail/limits.hpp>, from
- * which this code was originally taken.
- *
- * Modified by Caleb Epstein to use <endian.h> with GNU libc and to
- * defined the BOOST_ENDIAN macro.
- ****************************************************************************/
-#ifndef INCLUDED_DRIVER_OCI_ENDIAN_HPP
-#define INCLUDED_DRIVER_OCI_ENDIAN_HPP
-
-# define SWAP_BE_TO_LE(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_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)); \
-        char* last = first + n - 1; \
-        for(; first < last; ++first, --last) { \
-            char const x = *last; \
-            *last = *first; \
-            *first = x; \
-        }} while(false)
-
-#endif


More information about the Liblas-commits mailing list