Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:12

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  *
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_HEXBIN_HPP)
0023 #define XERCESC_INCLUDE_GUARD_HEXBIN_HPP
0024 
0025 #include <xercesc/util/PlatformUtils.hpp>
0026 
0027 XERCES_CPP_NAMESPACE_BEGIN
0028 
0029 class XMLUTIL_EXPORT HexBin
0030 {
0031 public :
0032     //@{
0033 
0034     /**
0035      * return the length of hexData in terms of HexBinary.
0036      *
0037      * @param hexData A string containing the HexBinary
0038      *
0039      * return: -1 if it contains any invalid HexBinary
0040      *         the length of the HexNumber otherwise.
0041      */
0042 
0043     static int  getDataLength(const XMLCh* const hexData);
0044 
0045      /**
0046      * check an array of data against the Hex table.
0047      *
0048      * @param hexData A string containing the HexBinary
0049      *
0050      * return: false if it contains any invalid HexBinary
0051      *         true otherwise.
0052      */
0053 
0054     static bool isArrayByteHex(const XMLCh* const hexData);
0055 
0056      /**
0057      * get canonical representation
0058      *
0059      * Caller is responsible for the proper deallocation
0060      * of the string returned.
0061      *
0062      * @param hexData A string containing the HexBinary
0063      * @param manager The MemoryManager to use to allocate the string
0064      *
0065      * return: the canonical representation of the HexBinary
0066      *         if it is a valid HexBinary,
0067      *         0 otherwise
0068      */
0069 
0070     static XMLCh* getCanonicalRepresentation
0071                   (
0072                       const XMLCh*          const hexData
0073                     ,       MemoryManager*  const manager = XMLPlatformUtils::fgMemoryManager
0074                   );
0075 
0076    /**
0077      * Decodes HexBinary data into XMLByte
0078      *
0079      * NOTE: The returned buffer is dynamically allocated and is the
0080      * responsibility of the caller to delete it when not longer needed.
0081      * Use the memory manager to release the returned buffer.
0082      *
0083      * @param hexData HexBinary data in XMLCh stream.
0084      * @param manager client provided memory manager
0085      * @return Decoded binary data in XMLByte stream,
0086      *      or NULL if input data can not be decoded.
0087      */
0088     static XMLByte* decodeToXMLByte(
0089                          const XMLCh*          const    hexData
0090                        ,       MemoryManager*  const    manager = XMLPlatformUtils::fgMemoryManager
0091                         );
0092 
0093 
0094     //@}
0095 
0096 private :
0097 
0098     // -----------------------------------------------------------------------
0099     //  Helper methods
0100     // -----------------------------------------------------------------------
0101 
0102     static bool isHex(const XMLCh& octet);
0103 
0104     // -----------------------------------------------------------------------
0105     //  Unimplemented constructors and operators
0106     // -----------------------------------------------------------------------
0107     HexBin();
0108     HexBin(const HexBin&);
0109     HexBin& operator=(const HexBin&);
0110 
0111     // -----------------------------------------------------------------------
0112     //  Private data members
0113     //
0114     //  isInitialized
0115     //
0116     //     set once hexNumberTable is initialized.
0117     //
0118     //  hexNumberTable
0119     //
0120     //     arrany holding valid hexNumber character.
0121     //
0122     // -----------------------------------------------------------------------
0123     static const XMLByte    hexNumberTable[];
0124 };
0125 
0126 XERCES_CPP_NAMESPACE_END
0127 
0128 #endif