]>
git.saurik.com Git - apple/icu.git/blob - icuSources/layout/LESwaps.h
3 * (C) Copyright IBM Corp. 1998-2010 - All Rights Reserved
14 * \brief C++ API: Endian independent access to data for LayoutEngine
20 * A convenience macro which invokes the swapWord member function
21 * from a concise call.
25 #define SWAPW(value) LESwaps::swapWord((le_uint16)(value))
28 * A convenience macro which invokes the swapLong member function
29 * from a concise call.
33 #define SWAPL(value) LESwaps::swapLong((le_uint32)(value))
36 * This class is used to access data which stored in big endian order
37 * regardless of the conventions of the platform.
39 * All methods are static and inline in an attempt to induce the compiler
40 * to do most of the calculations at compile time.
44 class U_LAYOUT_API LESwaps
/* not : public UObject because all methods are static */ {
48 * This method does the byte swap required on little endian platforms
49 * to correctly access a (16-bit) word.
51 * @param value - the word to be byte swapped
53 * @return the byte swapped word
57 static le_uint16
swapWord(le_uint16 value
)
59 return (le_uint16
)((value
<< 8) | (value
>> 8));
63 * This method does the byte swapping required on little endian platforms
64 * to correctly access a (32-bit) long.
66 * @param value - the long to be byte swapped
68 * @return the byte swapped long
72 static le_uint32
swapLong(le_uint32 value
)
76 ((value
<< 8) & 0xff0000) |
77 ((value
>> 8) & 0xff00) |
82 LESwaps() {} // private - forbid instantiation