[2674] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | #if !defined(TRANSENAMEMAP_HPP) |
---|
| 20 | #define TRANSENAMEMAP_HPP |
---|
| 21 | |
---|
| 22 | #include <xercesc/util/TransService.hpp> |
---|
| 23 | #include <xercesc/util/XMLString.hpp> |
---|
| 24 | |
---|
| 25 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 26 | |
---|
| 27 | // |
---|
| 28 | // This class is really private to the TransService class. However, some |
---|
| 29 | // compilers are too dumb to allow us to hide this class there in the Cpp |
---|
| 30 | // file that uses it. |
---|
| 31 | // |
---|
| 32 | class ENameMap : public XMemory |
---|
| 33 | { |
---|
| 34 | public : |
---|
| 35 | // ----------------------------------------------------------------------- |
---|
| 36 | // Destructor |
---|
| 37 | // ----------------------------------------------------------------------- |
---|
| 38 | virtual ~ENameMap() |
---|
| 39 | { |
---|
| 40 | //delete [] fEncodingName; |
---|
| 41 | XMLPlatformUtils::fgMemoryManager->deallocate(fEncodingName); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | // ----------------------------------------------------------------------- |
---|
| 47 | // Virtual factory method |
---|
| 48 | // ----------------------------------------------------------------------- |
---|
| 49 | virtual XMLTranscoder* makeNew |
---|
| 50 | ( |
---|
| 51 | const unsigned int blockSize |
---|
| 52 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
| 53 | ) const = 0; |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | // ----------------------------------------------------------------------- |
---|
| 57 | // Getter methods |
---|
| 58 | // ----------------------------------------------------------------------- |
---|
| 59 | const XMLCh* getKey() const |
---|
| 60 | { |
---|
| 61 | return fEncodingName; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | protected : |
---|
| 66 | // ----------------------------------------------------------------------- |
---|
| 67 | // Hidden constructors |
---|
| 68 | // ----------------------------------------------------------------------- |
---|
| 69 | ENameMap(const XMLCh* const encodingName) : |
---|
| 70 | fEncodingName(XMLString::replicate(encodingName, XMLPlatformUtils::fgMemoryManager)) |
---|
| 71 | { |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | private : |
---|
| 76 | // ----------------------------------------------------------------------- |
---|
| 77 | // Unimplemented constructors and operators |
---|
| 78 | // ----------------------------------------------------------------------- |
---|
| 79 | ENameMap(); |
---|
| 80 | ENameMap(const ENameMap&); |
---|
| 81 | ENameMap& operator=(const ENameMap&); |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | // ----------------------------------------------------------------------- |
---|
| 85 | // Private data members |
---|
| 86 | // |
---|
| 87 | // fEncodingName |
---|
| 88 | // This is the encoding name for the transcoder that is controlled |
---|
| 89 | // by this map instance. |
---|
| 90 | // ----------------------------------------------------------------------- |
---|
| 91 | XMLCh* fEncodingName; |
---|
| 92 | }; |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | template <class TType> class ENameMapFor : public ENameMap |
---|
| 96 | { |
---|
| 97 | public : |
---|
| 98 | // ----------------------------------------------------------------------- |
---|
| 99 | // Constructors and Destructor |
---|
| 100 | // ----------------------------------------------------------------------- |
---|
| 101 | ENameMapFor(const XMLCh* const encodingName); |
---|
| 102 | ~ENameMapFor(); |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | // ----------------------------------------------------------------------- |
---|
| 106 | // Implementation of virtual factory method |
---|
| 107 | // ----------------------------------------------------------------------- |
---|
| 108 | virtual XMLTranscoder* makeNew(const unsigned int blockSize, |
---|
| 109 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) const; |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | private : |
---|
| 113 | // ----------------------------------------------------------------------- |
---|
| 114 | // Unimplemented constructors and operators |
---|
| 115 | // ----------------------------------------------------------------------- |
---|
| 116 | ENameMapFor(); |
---|
| 117 | ENameMapFor(const ENameMapFor<TType>&); |
---|
| 118 | ENameMapFor<TType>& operator=(const ENameMapFor<TType>&); |
---|
| 119 | }; |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | template <class TType> class EEndianNameMapFor : public ENameMap |
---|
| 123 | { |
---|
| 124 | public : |
---|
| 125 | // ----------------------------------------------------------------------- |
---|
| 126 | // Constructors and Destructor |
---|
| 127 | // ----------------------------------------------------------------------- |
---|
| 128 | EEndianNameMapFor(const XMLCh* const encodingName, const bool swapped); |
---|
| 129 | ~EEndianNameMapFor(); |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | // ----------------------------------------------------------------------- |
---|
| 133 | // Implementation of virtual factory method |
---|
| 134 | // ----------------------------------------------------------------------- |
---|
| 135 | virtual XMLTranscoder* makeNew(const unsigned int blockSize, |
---|
| 136 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) const; |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | private : |
---|
| 140 | // ----------------------------------------------------------------------- |
---|
| 141 | // Unimplemented constructors and operators |
---|
| 142 | // ----------------------------------------------------------------------- |
---|
| 143 | EEndianNameMapFor(const EEndianNameMapFor<TType>&); |
---|
| 144 | EEndianNameMapFor<TType>& operator=(const EEndianNameMapFor<TType>&); |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | // ----------------------------------------------------------------------- |
---|
| 148 | // Private data members |
---|
| 149 | // |
---|
| 150 | // fSwapped |
---|
| 151 | // Indicates whether the endianess of the encoding is opposite of |
---|
| 152 | // that of the local host. |
---|
| 153 | // ----------------------------------------------------------------------- |
---|
| 154 | bool fSwapped; |
---|
| 155 | }; |
---|
| 156 | |
---|
| 157 | XERCES_CPP_NAMESPACE_END |
---|
| 158 | |
---|
| 159 | #if !defined(XERCES_TMPLSINC) |
---|
| 160 | #include <xercesc/util/TransENameMap.c> |
---|
| 161 | #endif |
---|
| 162 | |
---|
| 163 | #endif |
---|