1 | /*
|
---|
2 | * Copyright 1999-2000,2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * $Log: BitOps.hpp,v $
|
---|
19 | * Revision 1.4 2004/09/08 13:56:21 peiyongz
|
---|
20 | * Apache License Version 2.0
|
---|
21 | *
|
---|
22 | * Revision 1.3 2003/03/07 18:11:54 tng
|
---|
23 | * Return a reference instead of void for operator=
|
---|
24 | *
|
---|
25 | * Revision 1.2 2002/11/04 15:22:03 tng
|
---|
26 | * C++ Namespace Support.
|
---|
27 | *
|
---|
28 | * Revision 1.1.1.1 2002/02/01 22:22:10 peiyongz
|
---|
29 | * sane_include
|
---|
30 | *
|
---|
31 | * Revision 1.7 2000/09/06 00:24:15 andyh
|
---|
32 | * Clean up misc compiler warnings
|
---|
33 | *
|
---|
34 | * Revision 1.6 2000/03/02 19:54:38 roddey
|
---|
35 | * This checkin includes many changes done while waiting for the
|
---|
36 | * 1.1.0 code to be finished. I can't list them all here, but a list is
|
---|
37 | * available elsewhere.
|
---|
38 | *
|
---|
39 | * Revision 1.5 2000/02/24 20:05:24 abagchi
|
---|
40 | * Swat for removing Log from API docs
|
---|
41 | *
|
---|
42 | * Revision 1.4 2000/02/17 22:49:17 aruna1
|
---|
43 | * Added comment on mask
|
---|
44 | *
|
---|
45 | * Revision 1.3 2000/02/17 22:32:45 aruna1
|
---|
46 | * Masking changes made due to swap of 16bit to 32 bit
|
---|
47 | *
|
---|
48 | * Revision 1.2 2000/02/06 07:48:01 rahulj
|
---|
49 | * Year 2K copyright swat.
|
---|
50 | *
|
---|
51 | * Revision 1.1.1.1 1999/11/09 01:04:08 twl
|
---|
52 | * Initial checkin
|
---|
53 | *
|
---|
54 | * Revision 1.3 1999/11/08 20:45:05 rahul
|
---|
55 | * Swat for adding in Product name and CVS comment log variable.
|
---|
56 | *
|
---|
57 | */
|
---|
58 |
|
---|
59 | #if !defined(BITOPS_HPP)
|
---|
60 | #define BITOPS_HPP
|
---|
61 |
|
---|
62 | #include <xercesc/util/XercesDefs.hpp>
|
---|
63 |
|
---|
64 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
65 |
|
---|
66 | class XMLUTIL_EXPORT BitOps
|
---|
67 | {
|
---|
68 | public:
|
---|
69 | // -----------------------------------------------------------------------
|
---|
70 | // Public static methods
|
---|
71 | // -----------------------------------------------------------------------
|
---|
72 | static inline XMLCh swapBytes(const XMLUInt16 toSwap)
|
---|
73 | {
|
---|
74 | //The mask is required to overcome a compiler error on solaris
|
---|
75 | return XMLCh(((toSwap >> 8) | (toSwap << 8)) & 0xFFFF);
|
---|
76 | }
|
---|
77 |
|
---|
78 | static inline unsigned int swapBytes(const XMLUInt32 toSwap)
|
---|
79 | {
|
---|
80 | return
|
---|
81 | (
|
---|
82 | (toSwap >> 24)
|
---|
83 | | (toSwap << 24)
|
---|
84 | | ((toSwap & 0xFF00) << 8)
|
---|
85 | | ((toSwap & 0xFF0000) >> 8)
|
---|
86 | );
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 | protected :
|
---|
92 | // -----------------------------------------------------------------------
|
---|
93 | // Unimplemented constructors and operators. (These ought to be private,
|
---|
94 | // but that produces spurious compiler warnings
|
---|
95 | // on some platforms.)
|
---|
96 | // -----------------------------------------------------------------------
|
---|
97 | BitOps();
|
---|
98 | BitOps(const BitOps&);
|
---|
99 | BitOps& operator=(const BitOps&);
|
---|
100 | };
|
---|
101 |
|
---|
102 | XERCES_CPP_NAMESPACE_END
|
---|
103 |
|
---|
104 | #endif
|
---|