ICU 4.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LESwaps.h
Go to the documentation of this file.
1 
2 /*
3  *
4  * (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved
5  *
6  */
7 
8 #ifndef __LESWAPS_H
9 #define __LESWAPS_H
10 
11 #include "LETypes.h"
12 
19 
26 #define SWAPW(value) LESwaps::swapWord((const le_uint16 &) (value))
27 
34 #define SWAPL(value) LESwaps::swapLong((const le_uint32 &) (value))
35 
45 class U_LAYOUT_API LESwaps /* not : public UObject because all methods are static */ {
46 public:
47 
58  static le_uint16 swapWord(const le_uint16 &value)
59  {
60  const le_uint8 *p = (const le_uint8 *) &value;
61 
62  return ((p[0] << 8) + p[1]);
63  };
64 
75  static le_uint32 swapLong(const le_uint32 &value)
76  {
77  const le_uint8 *p = (const le_uint8 *) &value;
78 
79  return ((p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3]);
80  };
81 
82 private:
83  LESwaps() {} // private - forbid instantiation
84 };
85 
87 #endif
This class is used to access data which stored in big endian order regardless of the conventions of t...
Definition: LESwaps.h:45
uint32_t le_uint32
A type used for unsigned, 32-bit integers.
Definition: LETypes.h:41
static le_uint16 swapWord(const le_uint16 &value)
This method does the byte swap required on little endian platforms to correctly access a (16-bit) wor...
Definition: LESwaps.h:58
uint16_t le_uint16
A type used for unsigned, 16-bit integers.
Definition: LETypes.h:55
#define U_LAYOUT_API
Set to export library symbols from inside the layout engine library, and to import them from outside...
Definition: utypes.h:476
C API: Basic definitions for the ICU LayoutEngine.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:183
uint8_t le_uint8
A type used for unsigned, 8-bit integers.
Definition: LETypes.h:69
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API If the compiler doesn&#39;t support namespaces...
Definition: uversion.h:184
static le_uint32 swapLong(const le_uint32 &value)
This method does the byte swapping required on little endian platforms to correctly access a (32-bit)...
Definition: LESwaps.h:75