source: NonGTP/Xerces/xerces/include/xercesc/util/HexBin.hpp @ 358

Revision 358, 4.1 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2001,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 * $Id: HexBin.hpp,v 1.6 2004/09/08 13:56:22 peiyongz Exp $
19 */
20
21#ifndef HEXBIN_HPP
22#define HEXBIN_HPP
23
24#include <xercesc/util/PlatformUtils.hpp>
25
26XERCES_CPP_NAMESPACE_BEGIN
27
28class XMLUTIL_EXPORT HexBin
29{
30public :
31    //@{
32
33    /**
34     * return the length of hexData in terms of HexBinary.
35     *
36     * @param hexData A string containing the HexBinary
37     *
38     * return: -1 if it contains any invalid HexBinary
39     *         the length of the HexNumber otherwise.
40     */
41
42    static int  getDataLength(const XMLCh* const hexData);
43
44     /**
45     * check an array of data against the Hex table.
46     *
47     * @param hexData A string containing the HexBinary
48     *
49     * return: false if it contains any invalid HexBinary
50     *         true otherwise.
51     */
52
53    static bool isArrayByteHex(const XMLCh* const hexData);
54
55     /**
56     * get canonical representation
57     *
58     * Caller is responsible for the proper deallcation
59     * of the string returned.
60     *
61     * @param hexData A string containing the HexBinary
62     * @param manager The MemoryManager to use to allocate the string
63     *
64     * return: the canonical representation of the HexBinary
65     *         if it is a valid HexBinary,
66     *         0 otherwise
67     */
68
69    static XMLCh* getCanonicalRepresentation
70                  (
71                      const XMLCh*          const hexData
72                    ,       MemoryManager*  const manager = XMLPlatformUtils::fgMemoryManager
73                  );
74
75    /**
76     * Decodes HexBinary data into XMLCh
77     *
78     * NOTE: The returned buffer is dynamically allocated and is the
79     * responsibility of the caller to delete it when not longer needed.
80     * You can call XMLString::release to release this returned buffer.
81     *
82     * If a memory manager is provided, ask the memory manager to de-allocate
83     * the returned buffer.
84     *
85     * @param hexData HexBinary data in XMLCh stream.
86     * @param manager client provided memory manager
87     * @return Decoded binary data in XMLCh stream,
88     *      or NULL if input data can not be decoded.
89     * @see   XMLString::release(XMLCh**)
90     */
91    static XMLCh* decode(
92                         const XMLCh*          const    hexData
93                       ,       MemoryManager*  const    manager = XMLPlatformUtils::fgMemoryManager
94                        );
95
96
97    //@}
98
99private :
100
101    // -----------------------------------------------------------------------
102    //  Helper methods
103    // -----------------------------------------------------------------------
104
105    static void init();
106
107    static bool isHex(const XMLCh& octect);
108
109    // -----------------------------------------------------------------------
110    //  Unimplemented constructors and operators
111    // -----------------------------------------------------------------------
112    HexBin();
113    HexBin(const HexBin&);
114    HexBin& operator=(const HexBin&);
115
116    // -----------------------------------------------------------------------
117    //  Private data members
118    //
119    //  isInitialized
120    //
121    //     set once hexNumberTable is initalized.
122    //
123    //  hexNumberTable
124    //
125    //     arrany holding valid hexNumber character.
126    //
127    // -----------------------------------------------------------------------
128    static bool       isInitialized;
129    static bool       hexNumberTable[];
130};
131
132XERCES_CPP_NAMESPACE_END
133
134#endif
Note: See TracBrowser for help on using the repository browser.