source: trunk/src/xmlpatterns/data/qatomiccasters_p.h@ 99

Last change on this file since 99 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 23.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42//
43// W A R N I N G
44// -------------
45//
46// This file is not part of the Qt API. It exists purely as an
47// implementation detail. This header file may change from version to
48// version without notice, or even be removed.
49//
50// We mean it.
51
52#ifndef Patternist_AtomicCasters_H
53#define Patternist_AtomicCasters_H
54
55#include "qatomiccaster_p.h"
56#include "qdecimal_p.h"
57#include "qderivedinteger_p.h"
58#include "qderivedstring_p.h"
59#include "qinteger_p.h"
60#include "qvalidationerror_p.h"
61
62/**
63 * @file
64 * @short Contains classes sub-classing AtomicCaster and which
65 * are responsible of casting an atomic value to another type.
66 */
67
68QT_BEGIN_HEADER
69
70QT_BEGIN_NAMESPACE
71
72namespace QPatternist
73{
74
75 /**
76 * @short Casts any atomic value to @c xs:string.
77 *
78 * This class uses Item::stringValue() for retrieving a string
79 * representation, and thus supports casting from atomic values
80 * of any type.
81 *
82 * @ingroup Patternist_xdm
83 * @author Frans Englich <[email protected]>
84 */
85 template<TypeOfDerivedString DerivedType>
86 class ToStringCaster : public AtomicCaster
87 {
88 public:
89 virtual Item castFrom(const Item &from,
90 const QExplicitlySharedDataPointer<DynamicContext> &context) const
91 {
92 Q_ASSERT(from);
93 return DerivedString<DerivedType>::fromLexical(context->namePool(), from.stringValue());
94 }
95 };
96
97 /**
98 * @short Casts any atomic value to @c xs:untypedAtomic.
99 *
100 * This class uses Item::stringValue() for retrieving a string
101 * representation, and thus supports casting from atomic values
102 * of any type. The implementation is similar to ToStringCaster.
103 *
104 * @ingroup Patternist_xdm
105 * @author Frans Englich <[email protected]>
106 */
107 class ToUntypedAtomicCaster : public AtomicCaster
108 {
109 public:
110 virtual Item castFrom(const Item &from,
111 const QExplicitlySharedDataPointer<DynamicContext> &context) const;
112 };
113
114 /**
115 * @short Casts a string value to @c xs:anyURI.
116 *
117 * @ingroup Patternist_xdm
118 * @author Frans Englich <[email protected]>
119 */
120 class ToAnyURICaster : public AtomicCaster
121 {
122 public:
123 virtual Item castFrom(const Item &from,
124 const QExplicitlySharedDataPointer<DynamicContext> &context) const;
125 };
126
127 /**
128 * @short Casts a @c xs:hexBinary atomic value to @c xs:base64Binary.
129 *
130 * @ingroup Patternist_xdm
131 * @author Frans Englich <[email protected]>
132 */
133 class HexBinaryToBase64BinaryCaster : public AtomicCaster
134 {
135 public:
136 virtual Item castFrom(const Item &from,
137 const QExplicitlySharedDataPointer<DynamicContext> &context) const;
138 };
139
140 /**
141 * @short Casts a @c xs:base64Binary atomic value to @c xs:hexBinary.
142 *
143 * @ingroup Patternist_xdm
144 * @author Frans Englich <[email protected]>
145 */
146 class Base64BinaryToHexBinaryCaster : public AtomicCaster
147 {
148 public:
149 virtual Item castFrom(const Item &from,
150 const QExplicitlySharedDataPointer<DynamicContext> &context) const;
151 };
152
153 /**
154 * @short Casts a @c xs:string or @c xs:untypedAtomic atomic value to @c xs:base64Binary.
155 *
156 * @ingroup Patternist_xdm
157 * @author Frans Englich <[email protected]>
158 */
159 class StringToBase64BinaryCaster : public AtomicCaster
160 {
161 public:
162 virtual Item castFrom(const Item &from,
163 const QExplicitlySharedDataPointer<DynamicContext> &context) const;
164 };
165
166 /**
167 * @short Casts a @c xs:string or @c xs:untypedAtomic atomic value to @c xs:hexBinary.
168 *
169 * @ingroup Patternist_xdm
170 * @author Frans Englich <[email protected]>
171 */
172 class StringToHexBinaryCaster : public AtomicCaster
173 {
174 public:
175 virtual Item castFrom(const Item &from,
176 const QExplicitlySharedDataPointer<DynamicContext> &context) const;
177 };
178
179 /**
180 * @short Casts any @c numeric value to @c xs:boolean.
181 *
182 * @ingroup Patternist_xdm