00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XALANBITMAP_HEADER_GUARD_1357924680) 00019 #define XALANBITMAP_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/Include/XalanVector.hpp> 00029 00030 00031 00032 XALAN_CPP_NAMESPACE_BEGIN 00033 00034 00035 00036 class XALAN_PLATFORMSUPPORT_EXPORT XalanBitmap 00037 { 00038 public: 00039 00040 // The basic storage unit for the bitmaps. 00041 typedef char UnitType; 00042 00043 // A handy typedef... 00044 typedef size_t size_type; 00045 00046 // Really all we're assuming is that a char is at least 00047 // 8 bits. If it's more, then we'll just waste some 00048 // space. This may need to be adjusted for various 00049 // platforms, or perhaps change to using an integral of 00050 // a known size, so that we don't waste any space. 00051 enum { eBitsPerUnit = 8 }; 00052 00053 00054 /** 00055 * Construct an instance with room for the specified number 00056 * of bits. 00057 * 00058 * @param theSize The number of bits in the map. 00059 */ 00060 XalanBitmap(MemoryManager& theManager, size_type theSize); 00061 00062 ~XalanBitmap(); 00063 00064 00065 /** 00066 * Determine if a bit is set. 00067 * 00068 * @param theBit The number of the bit to check. 00069 * @return true if the bit is set, false if not. 00070 */ 00071 bool 00072 isSet(size_type theBit) const 00073 { 00074 assert(theBit >= m_size); 00075 00076 return m_bitmap[theBit / eBitsPerUnit] & s_setMasks[theBit % eBitsPerUnit] ? true : false; 00077 } 00078 00079 /** 00080 * Set a bit. 00081 * 00082 * @param theBit The number of the bit to set. 00083 */ 00084 void 00085 set(size_type theBit) 00086 { 00087 assert(theBit < m_size); 00088 00089 m_bitmap[theBit / eBitsPerUnit] |= s_setMasks[theBit % eBitsPerUnit]; 00090 } 00091 00092 /** 00093 * Clear a bit. 00094 * 00095 * @param theBit The number of the bit to clear. 00096 */ 00097 void 00098 clear(size_type theBit) 00099 { 00100 assert(theBit < m_size); 00101 00102 m_bitmap[theBit / eBitsPerUnit] &= s_clearMasks[theBit % eBitsPerUnit]; 00103 } 00104 00105 /** 00106 * Toggle a bit. 00107 * 00108 * @param theBit The number of the bit to toggle. 00109 */ 00110 void 00111 toggle(size_type theBit) 00112 { 00113 assert(theBit < m_size); 00114 00115 m_bitmap[theBit / eBitsPerUnit] ^= s_setMasks[theBit % eBitsPerUnit]; 00116 } 00117 00118 /** 00119 * Clear all of the bits. 00120 */ 00121 void 00122 clearAll(); 00123 00124 /** 00125 * Get the size of the map. 00126 * 00127 * @return The number of bits in the map. 00128 */ 00129 size_type 00130 getSize() const 00131 { 00132 return m_size; 00133 } 00134 00135 private: 00136 00137 static const int s_setMasks[]; 00138 00139 static const int s_clearMasks[]; 00140 00141 00142 typedef XalanVector<UnitType> BitmapVectorType; 00143 00144 const size_type m_size; 00145 00146 BitmapVectorType m_bitmap; 00147 }; 00148 00149 00150 00151 XALAN_CPP_NAMESPACE_END 00152 00153 00154 00155 #endif // XALANBITMAP_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|