rasdaman complete source
endian.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
33 #ifndef _R_ENDIANTOOLS_HH_
34 #define _R_ENDIANTOOLS_HH_
35 
36 #include <iostream>
37 
38 class r_Minterval;
39 class r_Base_Type;
40 class r_Primitive_Type;
41 #include "raslib/odmgtypes.hh"
42 #include "raslib/mddtypes.hh"
43 
44 //@ManMemo: Module {\bf raslib}
45 
46 /*@Doc:
47  Class to check the endianness of the host machine and to
48  swap the endianness of types and arrays. Don't instantiate,
49  static members only.
50 */
51 
52 class r_Endian
53 {
54 public:
57  {
60  };
61 
63  static r_Short swap( r_Short val );
64  static r_UShort swap( r_UShort val );
65  static r_Long swap( r_Long val );
66  static r_ULong swap( r_ULong val );
67  static r_Float swap( r_Float val );
68  static r_Double swap( r_Double val );
69 
71  static r_Endianness get_endianness( void );
72 
74  static void swap_array( const r_Primitive_Type *type, r_Bytes size, const void *src, void *dest );
75 
77  static void swap_array( r_Bytes size, const r_Octet *src, r_Octet *dest ); // dummy
78  static void swap_array( r_Bytes size, const r_Char *src, r_Char *dest ); // dummy
79  static void swap_array( r_Bytes size, const r_Short *src, r_Short *dest );
80  static void swap_array( r_Bytes size, const r_UShort *src, r_UShort *dest );
81  static void swap_array( r_Bytes size, const r_Long *src, r_Long *dest );
82  static void swap_array( r_Bytes size, const r_ULong *src, r_ULong *dest );
83  static void swap_array( r_Bytes size, const r_Float *src, r_Float *dest );
84  static void swap_array( r_Bytes size, const r_Double *src, r_Double *dest );
85 
87  static void swap_array( r_Bytes size, r_Bytes tsize, const void *src, void *dest);
88 
91  static void swap_array( const r_Primitive_Type *type, const r_Minterval &srcDom,
92  const r_Minterval &srcIterDom, const void *src, void *dest,
93  r_ULong step );
94 
96  static void swap_array( const r_Base_Type *type, const r_Minterval &srcDom,
97  const r_Minterval &srcIterDom, const void *src, void *dest );
98 
101  static void swap_array( const r_Primitive_Type *type, const r_Minterval &srcDom,
102  const r_Minterval &srcIterDom, const r_Minterval &destDom,
103  const r_Minterval &destIterDom, const void *src, void *dest,
104  r_ULong step );
105 
107  static void swap_array( const r_Base_Type *type, const r_Minterval &srcDom,
108  const r_Minterval &srcIterDom, const r_Minterval &destDom,
109  const r_Minterval &destIterDom, const void *src, void *dest );
110 };
111 
112 //@ManMemo: Module: {\bf raslib}
116 extern std::ostream& operator<<( std::ostream& s, r_Endian::r_Endianness& e );
117 
118 
119 #endif
r_Endianness
endianness identifiers
Definition: endian.hh:56
unsigned short r_UShort
Definition: odmgtypes.hh:87
Definition: raslib/basetype.hh:47
unsigned int r_ULong
Definition: odmgtypes.hh:114
Definition: endian.hh:58
double r_Double
Definition: odmgtypes.hh:138
Definition: endian.hh:52
float r_Float
Definition: odmgtypes.hh:125
signed char r_Octet
Definition: odmgtypes.hh:60
unsigned char r_Char
Definition: odmgtypes.hh:47
unsigned int r_Bytes
Definition: mddtypes.hh:56
static r_Short swap(r_Short val)
swap endianness of atomic types
Definition: primitivetype.hh:49
int r_Long
Definition: odmgtypes.hh:100
std::ostream & operator<<(std::ostream &s, r_Endian::r_Endianness &e)
short r_Short
Definition: odmgtypes.hh:74
Definition: minterval.hh:249
Definition: endian.hh:59
static r_Endianness get_endianness(void)
query host machine's endianness
static void swap_array(const r_Primitive_Type *type, r_Bytes size, const void *src, void *dest)
change the endianness of a linear array of size and type