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

Last change on this file since 615 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 23.3 KB
RevLine 
[2]1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
[561]4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
[2]6**
7** This file is part of the QtXmlPatterns module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
[561]24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
[2]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**
[561]36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
[2]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
[561]83 * @author Frans Englich <[email protected]>
[2]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
[561]105 * @author Frans Englich <[email protected]>
[2]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
[561]118 * @author Frans Englich <[email protected]>
[2]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
[561]131 * @author Frans Englich <[email protected]>
[2]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
[561]144 * @author Frans Englich <[email protected]>
[2]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
[561]157 * @author Frans Englich <[email protected]>
[2]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