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: StringToken.hpp,v 1.7 2004/09/08 13:56:47 peiyongz Exp $
|
---|
19 | */
|
---|
20 |
|
---|
21 | #if !defined(STRINGTOKEN_HPP)
|
---|
22 | #define STRINGTOKEN_HPP
|
---|
23 |
|
---|
24 | // ---------------------------------------------------------------------------
|
---|
25 | // Includes
|
---|
26 | // ---------------------------------------------------------------------------
|
---|
27 | #include <xercesc/util/regx/Token.hpp>
|
---|
28 | #include <xercesc/util/XMLString.hpp>
|
---|
29 |
|
---|
30 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
31 |
|
---|
32 | class XMLUTIL_EXPORT StringToken : public Token {
|
---|
33 | public:
|
---|
34 | // -----------------------------------------------------------------------
|
---|
35 | // Public Constructors and Destructor
|
---|
36 | // -----------------------------------------------------------------------
|
---|
37 | StringToken(const unsigned short tokType,
|
---|
38 | const XMLCh* const literal,
|
---|
39 | const int refNo,
|
---|
40 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
41 | ~StringToken();
|
---|
42 |
|
---|
43 | // -----------------------------------------------------------------------
|
---|
44 | // Getter methods
|
---|
45 | // -----------------------------------------------------------------------
|
---|
46 | int getReferenceNo() const;
|
---|
47 | const XMLCh* getString() const;
|
---|
48 |
|
---|
49 | // -----------------------------------------------------------------------
|
---|
50 | // Setter methods
|
---|
51 | // -----------------------------------------------------------------------
|
---|
52 | void setString(const XMLCh* const literal);
|
---|
53 |
|
---|
54 | private:
|
---|
55 | // -----------------------------------------------------------------------
|
---|
56 | // Unimplemented constructors and operators
|
---|
57 | // -----------------------------------------------------------------------
|
---|
58 | StringToken(const StringToken&);
|
---|
59 | StringToken& operator=(const StringToken&);
|
---|
60 |
|
---|
61 | // -----------------------------------------------------------------------
|
---|
62 | // Private data members
|
---|
63 | // -----------------------------------------------------------------------
|
---|
64 | int fRefNo;
|
---|
65 | XMLCh* fString;
|
---|
66 | MemoryManager* fMemoryManager;
|
---|
67 | };
|
---|
68 |
|
---|
69 |
|
---|
70 | // ---------------------------------------------------------------------------
|
---|
71 | // StringToken: getter methods
|
---|
72 | // ---------------------------------------------------------------------------
|
---|
73 | inline int StringToken::getReferenceNo() const {
|
---|
74 |
|
---|
75 | return fRefNo;
|
---|
76 | }
|
---|
77 |
|
---|
78 | inline const XMLCh* StringToken::getString() const {
|
---|
79 |
|
---|
80 | return fString;
|
---|
81 | }
|
---|
82 |
|
---|
83 | // ---------------------------------------------------------------------------
|
---|
84 | // StringToken: Setter methods
|
---|
85 | // ---------------------------------------------------------------------------
|
---|
86 | inline void StringToken::setString(const XMLCh* const literal) {
|
---|
87 |
|
---|
88 | fMemoryManager->deallocate(fString);//delete [] fString;
|
---|
89 | fString = XMLString::replicate(literal, fMemoryManager);
|
---|
90 | }
|
---|
91 |
|
---|
92 | XERCES_CPP_NAMESPACE_END
|
---|
93 |
|
---|
94 | #endif
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * End of file StringToken.hpp
|
---|
98 | */
|
---|