Qt 4.8
Public Functions | List of all members
QPatternist::NumericToDerivedIntegerCaster< type > Class Template Reference

Casts any numeric instance to a derived type of xs:integer. More...

#include <qatomiccasters_p.h>

Inheritance diagram for QPatternist::NumericToDerivedIntegerCaster< type >:
QPatternist::AtomicCaster QPatternist::AtomicTypeVisitorResult QSharedData

Public Functions

virtual Item castFrom (const Item &from, const QExplicitlySharedDataPointer< DynamicContext > &context) const
 
- Public Functions inherited from QPatternist::AtomicCaster
 AtomicCaster ()
 
virtual ~AtomicCaster ()
 
- Public Functions inherited from QPatternist::AtomicTypeVisitorResult
 AtomicTypeVisitorResult ()
 
virtual ~AtomicTypeVisitorResult ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Additional Inherited Members

- Public Types inherited from QPatternist::AtomicCaster
typedef QExplicitlySharedDataPointer< AtomicCasterPtr
 
- Public Types inherited from QPatternist::AtomicTypeVisitorResult
typedef QExplicitlySharedDataPointer< AtomicTypeVisitorResultPtr
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

template<TypeOfDerivedInteger type>
class QPatternist::NumericToDerivedIntegerCaster< type >

Casts any numeric instance to a derived type of xs:integer.

Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 674 of file qatomiccasters_p.h.

Functions

◆ castFrom()

template<TypeOfDerivedInteger type>
virtual Item QPatternist::NumericToDerivedIntegerCaster< type >::castFrom ( const Item from,
const QExplicitlySharedDataPointer< DynamicContext > &  context 
) const
inlinevirtual

Casts from to an atomic value of the type this class casts to, and returns that value. The context is used for reporting errors in case the casting fails, and to in general access information from the dynamic context.

Implements QPatternist::AtomicCaster.

Definition at line 678 of file qatomiccasters_p.h.

680  {
681  const ItemType::Ptr t(from.type());
682  const Numeric *const num = from.template as<Numeric>();
683 
684  if(BuiltinTypes::xsDouble->xdtTypeMatches(t) || BuiltinTypes::xsFloat->xdtTypeMatches(t))
685  {
686  if(num->isInf() || num->isNaN())
687  {
689  .arg(formatType(context->namePool(), DerivedInteger<type>::itemType()))
690  .arg(formatType(context->namePool(), t))
691  .arg(formatData(num->stringValue())),
693  }
694  }
695 
696  return toItem(DerivedInteger<type>::fromValue(context->namePool(), from.template as<Numeric>()->toInteger()));
697  }
static AtomicValue::Ptr fromValue(const NamePool::Ptr &np, const TemporaryStorageType num)
QString formatType(const NamePool::Ptr &np, const T &type)
Formats ItemType and SequenceType.
static AtomicValue::Ptr createError(const QString &description=QString(), const ReportContext::ErrorCode=ReportContext::FORG0001)
Item toItem(const QExplicitlySharedDataPointer< T > atomicValue)
Definition: qitem_p.h:431
static const AtomicType::Ptr xsDouble
static QString formatData(const QString &data)
QExplicitlySharedDataPointer< ItemType > Ptr
Definition: qitemtype_p.h:88
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static const AtomicType::Ptr xsFloat
static ItemType::Ptr itemType()

The documentation for this class was generated from the following file: