source: trunk/VUT/GtpVisibilityPreprocessor/support/xerces/include/xercesc/util/KVStringPair.hpp @ 358

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

xerces added

Line 
1/*
2 * Copyright 1999-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: KVStringPair.hpp,v $
19 * Revision 1.8  2004/09/08 13:56:22  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.7  2004/01/29 11:48:46  cargilld
23 * Code cleanup changes to get rid of various compiler diagnostic messages.
24 *
25 * Revision 1.6  2003/09/25 22:23:25  peiyongz
26 * Implementation of Serialization/Deserialization
27 *
28 * Revision 1.5  2003/05/18 14:02:05  knoaman
29 * Memory manager implementation: pass per instance manager.
30 *
31 * Revision 1.4  2003/05/16 06:01:52  knoaman
32 * Partial implementation of the configurable memory manager.
33 *
34 * Revision 1.3  2003/05/15 19:04:35  knoaman
35 * Partial implementation of the configurable memory manager.
36 *
37 * Revision 1.2  2002/11/04 15:22:04  tng
38 * C++ Namespace Support.
39 *
40 * Revision 1.1.1.1  2002/02/01 22:22:11  peiyongz
41 * sane_include
42 *
43 * Revision 1.6  2001/05/11 13:26:27  tng
44 * Copyright update.
45 *
46 * Revision 1.5  2001/01/15 21:26:34  tng
47 * Performance Patches by David Bertoni.
48 *
49 * Details: (see xerces-c-dev mailing Jan 14)
50 * XMLRecognizer.cpp: the internal encoding string XMLUni::fgXMLChEncodingString
51 * was going through this function numerous times.  As a result, the top hot-spot
52 * for the parse was _wcsicmp().  The real problem is that the Microsofts wide string
53 * functions are unbelievably slow.  For things like encodings, it might be
54 * better to use a special comparison function that only considers a-z and
55 * A-Z as characters with case.  This works since the character set for
56 * encodings is limit to printable ASCII characters.
57 *
58 *  XMLScanner2.cpp: This also has some case-sensitive vs. insensitive compares.
59 * They are also much faster.  The other tweak is to only make a copy of an attribute
60 * string if it needs to be split.  And then, the strategy is to try to use a
61 * stack-based buffer, rather than a dynamically-allocated one.
62 *
63 * SAX2XMLReaderImpl.cpp: Again, more case-sensitive vs. insensitive comparisons.
64 *
65 * KVStringPair.cpp & hpp: By storing the size of the allocation, the storage can
66 * likely be re-used many times, cutting down on dynamic memory allocations.
67 *
68 * XMLString.hpp: a more efficient implementation of stringLen().
69 *
70 * DTDValidator.cpp: another case of using a stack-based buffer when possible
71 *
72 * These patches made a big difference in parse time in some of our test
73 * files, especially the ones are very attribute-heavy.
74 *
75 * Revision 1.4  2000/03/02 19:54:40  roddey
76 * This checkin includes many changes done while waiting for the
77 * 1.1.0 code to be finished. I can't list them all here, but a list is
78 * available elsewhere.
79 *
80 * Revision 1.3  2000/02/24 20:05:24  abagchi
81 * Swat for removing Log from API docs
82 *
83 * Revision 1.2  2000/02/06 07:48:02  rahulj
84 * Year 2K copyright swat.
85 *
86 * Revision 1.1.1.1  1999/11/09 01:04:37  twl
87 * Initial checkin
88 *
89 * Revision 1.2  1999/11/08 20:45:08  rahul
90 * Swat for adding in Product name and CVS comment log variable.
91 *
92 */
93
94#if !defined(KVSTRINGPAIR_HPP)
95#define KVSTRINGPAIR_HPP
96
97#include <xercesc/util/XMemory.hpp>
98#include <xercesc/util/PlatformUtils.hpp>
99
100#include <xercesc/internal/XSerializable.hpp>
101
102XERCES_CPP_NAMESPACE_BEGIN
103
104//
105//  This class provides a commonly used data structure, which is that of
106//  a pair of strings which represent a 'key=value' type mapping. It works
107//  only in terms of XMLCh type raw strings.
108//
109class XMLUTIL_EXPORT KVStringPair : public XSerializable, public XMemory
110{
111public:
112    // -----------------------------------------------------------------------
113    //  Constructors and Destructor
114    // -----------------------------------------------------------------------
115    KVStringPair(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
116    KVStringPair
117    (
118        const XMLCh* const key
119        , const XMLCh* const value
120        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
121    );
122    KVStringPair(const KVStringPair& toCopy);
123    ~KVStringPair();
124
125
126    // -----------------------------------------------------------------------
127    //  Getters
128    //
129    //  We support the
130    // -----------------------------------------------------------------------
131    const XMLCh* getKey() const;
132    XMLCh* getKey();
133    const XMLCh* getValue() const;
134    XMLCh* getValue();
135
136
137    // -----------------------------------------------------------------------
138    //  Setters
139    // -----------------------------------------------------------------------
140    void setKey(const XMLCh* const newKey);
141    void setValue(const XMLCh* const newValue);
142    void set
143    (
144        const   XMLCh* const    newKey
145        , const XMLCh* const    newValue
146    );
147
148
149    /***
150     * Support for Serialization/De-serialization
151     ***/
152    DECL_XSERIALIZABLE(KVStringPair)
153
154private :
155    // unimplemented:
156       
157    KVStringPair& operator=(const KVStringPair&);
158    // -----------------------------------------------------------------------
159    //  Private data members
160    //
161    //  fKey
162    //      The string that represents the key field of this object.
163    //
164    //  fKeyAllocSize
165    //      The amount of memory allocated for fKey.
166    //
167    //  fValue
168    //      The string that represents the value of this pair object.
169    //
170    //  fValueAllocSize
171    //      The amount of memory allocated for fValue.
172    //
173    // -----------------------------------------------------------------------
174    MemoryManager* fMemoryManager;
175    XMLCh*         fKey;
176    unsigned long  fKeyAllocSize;
177    XMLCh*         fValue;
178    unsigned long  fValueAllocSize;
179};
180
181// ---------------------------------------------------------------------------
182//  KVStringPair: Getters
183// ---------------------------------------------------------------------------
184inline const XMLCh* KVStringPair::getKey() const
185{
186    return fKey;
187}
188
189inline XMLCh* KVStringPair::getKey()
190{
191    return fKey;
192}
193
194inline const XMLCh* KVStringPair::getValue() const
195{
196    return fValue;
197}
198
199inline XMLCh* KVStringPair::getValue()
200{
201    return fValue;
202}
203
204XERCES_CPP_NAMESPACE_END
205
206#endif
Note: See TracBrowser for help on using the repository browser.