Qt 4.8
Public Types | Public Functions | Static Public Functions | Protected Functions | Properties | List of all members
QPatternist::Integer Class Reference

Implements the value instance of the xs:integer type. More...

#include <qinteger_p.h>

Inheritance diagram for QPatternist::Integer:
QPatternist::Numeric QPatternist::AtomicValue QSharedData QPatternist::CppCastingHelper< AtomicValue >

Public Types

typedef Numeric::Ptr Ptr
 
- Public Types inherited from QPatternist::Numeric
typedef QExplicitlySharedDataPointer< NumericPtr
 
- Public Types inherited from QPatternist::AtomicValue
typedef QList< AtomicValue::PtrList
 
typedef QExplicitlySharedDataPointer< AtomicValuePtr
 

Public Functions

virtual Numeric::Ptr abs () const
 
virtual Numeric::Ptr ceiling () const
 
bool evaluateEBV (const QExplicitlySharedDataPointer< DynamicContext > &) const
 
virtual Numeric::Ptr floor () const
 
virtual bool isInf () const
 
virtual bool isNaN () const
 
virtual bool isSigned () const
 Returns always true. More...
 
virtual Numeric::Ptr round () const
 
virtual Numeric::Ptr roundHalfToEven (const xsInteger scale) const
 
virtual QString stringValue () const
 
virtual xsDecimal toDecimal () const
 
virtual xsDouble toDouble () const
 
virtual xsFloat toFloat () const
 
virtual xsInteger toInteger () const
 
virtual Item toNegated () const
 
virtual qulonglong toUnsignedInteger () const
 
virtual ItemType::Ptr type () const
 
- Public Functions inherited from QPatternist::AtomicValue
virtual bool hasError () const
 
virtual ~AtomicValue ()
 
- 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...
 
- Public Functions inherited from QPatternist::CppCastingHelper< AtomicValue >
const TCastTarget * as () const
 
TCastTarget * as ()
 

Static Public Functions

static AtomicValue::Ptr fromLexical (const QString &strNumeric)
 
static Item fromValue (const xsInteger num)
 
- Static Public Functions inherited from QPatternist::Numeric
static AtomicValue::Ptr fromLexical (const QString &number)
 
- Static Public Functions inherited from QPatternist::AtomicValue
static ItemType::Ptr qtToXDMType (const QXmlItem &item)
 
static QVariant toQt (const AtomicValue *const value)
 
static QVariant toQt (const AtomicValue::Ptr &value)
 
static Item toXDM (const QVariant &value)
 

Protected Functions

 Integer (const xsInteger num)
 
- Protected Functions inherited from QPatternist::AtomicValue
 AtomicValue ()
 
- Protected Functions inherited from QPatternist::CppCastingHelper< AtomicValue >
 CppCastingHelper ()
 

Properties

const xsInteger m_value
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Static Protected Functions inherited from QPatternist::Numeric
static xsDouble roundFloat (const xsDouble val)
 Implements fn:round() for types implemented with floating point. More...
 

Detailed Description

Implements the value instance of the xs:integer type.

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

Definition at line 70 of file qinteger_p.h.

Typedefs

◆ Ptr

Definition at line 74 of file qinteger_p.h.

Constructors and Destructors

◆ Integer()

Integer::Integer ( const xsInteger  num)
protected

Definition at line 68 of file qinteger.cpp.

Referenced by abs(), fromLexical(), and fromValue().

68  : m_value(num)
69 {
70 }
const xsInteger m_value
Definition: qinteger_p.h:133

Functions

◆ abs()

Numeric::Ptr Integer::abs ( ) const
virtual

Performs the algorithm specified for the function fn:abs on this Numeric, and whose result is returned.

See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 6.4.1 fn:abs

Implements QPatternist::Numeric.

Definition at line 128 of file qinteger.cpp.

129 {
130  /* No reason to allocate an Integer if we're already absolute. */
131  if(m_value < 0)
132  return Numeric::Ptr(new Integer(qAbs(m_value)));
133  else
134  return Numeric::Ptr(const_cast<Integer *>(this));
135 }
Integer(const xsInteger num)
Definition: qinteger.cpp:68
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
const xsInteger m_value
Definition: qinteger_p.h:133
QExplicitlySharedDataPointer< Numeric > Ptr

◆ ceiling()

Numeric::Ptr Integer::ceiling ( ) const
virtual

Performs the algorithm specified for the function fn:ceiling on this Numeric, and whose result is returned.

See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 6.4.2 fn:ceiling

Implements QPatternist::Numeric.

Definition at line 123 of file qinteger.cpp.

124 {
125  return Numeric::Ptr(const_cast<Integer *>(this));
126 }
QExplicitlySharedDataPointer< Numeric > Ptr

◆ evaluateEBV()

bool Integer::evaluateEBV ( const QExplicitlySharedDataPointer< DynamicContext > &  ) const
virtual

Determines the Effective Boolean Value of this number.

Returns
false if the number is 0, otherwise true.

Reimplemented from QPatternist::AtomicValue.

Definition at line 72 of file qinteger.cpp.

73 {
74  return m_value != 0;
75 }
const xsInteger m_value
Definition: qinteger_p.h:133

◆ floor()

Numeric::Ptr Integer::floor ( ) const
virtual

Performs the algorithm specified for the function fn:floor on this Numeric, and whose result is returned.

See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 6.4.3 fn:floor

Implements QPatternist::Numeric.

Definition at line 118 of file qinteger.cpp.

119 {
120  return Numeric::Ptr(const_cast<Integer *>(this));
121 }
QExplicitlySharedDataPointer< Numeric > Ptr

◆ fromLexical()

AtomicValue::Ptr Integer::fromLexical ( const QString strNumeric)
static

Constructs an instance from the lexical representation strNumeric.

Definition at line 57 of file qinteger.cpp.

Referenced by QPatternist::StringToIntegerCaster::castFrom(), and QPatternist::Numeric::fromLexical().

58 {
59  bool conversionOk = false;
60  const xsInteger num = strNumeric.toLongLong(&conversionOk);
61 
62  if(conversionOk)
63  return AtomicValue::Ptr(new Integer(num));
64  else
66 }
QExplicitlySharedDataPointer< AtomicValue > Ptr
Definition: qitem_p.h:127
qlonglong toLongLong(bool *ok=0, int base=10) const
Returns the string converted to a long long using base base, which is 10 by default and must be betwe...
Definition: qstring.cpp:5943
qint64 xsInteger
static AtomicValue::Ptr createError(const QString &description=QString(), const ReportContext::ErrorCode=ReportContext::FORG0001)
Integer(const xsInteger num)
Definition: qinteger.cpp:68

◆ fromValue()

Item Integer::fromValue ( const xsInteger  num)
static

◆ isInf()

bool Integer::isInf ( ) const
virtual
Returns
always false, xs:integer doesn't have infinity in its value space.

Implements QPatternist::Numeric.

Definition at line 142 of file qinteger.cpp.

143 {
144  return false;
145 }

◆ isNaN()

bool Integer::isNaN ( ) const
virtual
Returns
always false, xs:integer doesn't have not-a-number in its value space.

Implements QPatternist::Numeric.

Definition at line 137 of file qinteger.cpp.

138 {
139  return false;
140 }

◆ isSigned()

bool Integer::isSigned ( ) const
virtual

Returns always true.

Implements QPatternist::Numeric.

Definition at line 152 of file qinteger.cpp.

153 {
154  return true;
155 }

◆ round()

Numeric::Ptr Integer::round ( ) const
virtual

Performs the algorithm specified for the function fn:round on this Numeric, and whose result is returned.

See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 6.4.4 fn:round

Implements QPatternist::Numeric.

Definition at line 107 of file qinteger.cpp.

108 {
109  /* xs:integerS never has a mantissa. */
110  return Numeric::Ptr(const_cast<Integer *>(this));
111 }
QExplicitlySharedDataPointer< Numeric > Ptr

◆ roundHalfToEven()

Numeric::Ptr Integer::roundHalfToEven ( const xsInteger  scale) const
virtual

Performs rounding as defined for the fn:round-half-to-even on this Numeric, and whose result is returned.

See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 6.4.5 fn:round-half-to-even

Implements QPatternist::Numeric.

Definition at line 113 of file qinteger.cpp.

114 {
115  return Numeric::Ptr(const_cast<Integer *>(this));
116 }
QExplicitlySharedDataPointer< Numeric > Ptr

◆ stringValue()

QString Integer::stringValue ( ) const
virtual

Implements QPatternist::AtomicValue.

Definition at line 77 of file qinteger.cpp.

78 {
79  return QString::number(m_value);
80 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
const xsInteger m_value
Definition: qinteger_p.h:133

◆ toDecimal()

xsDecimal Integer::toDecimal ( ) const
virtual
Returns
the particular number's value as a native representation of the type xs:decimal. This can be considered that the value is cast to xs:decimal.

Implements QPatternist::Numeric.

Definition at line 102 of file qinteger.cpp.

103 {
104  return static_cast<xsDecimal>(m_value);
105 }
xsDouble xsDecimal
const xsInteger m_value
Definition: qinteger_p.h:133

◆ toDouble()

xsDouble Integer::toDouble ( ) const
virtual
Returns
the particular number's value as a native representation of the type xs:double. This can be considered that the value is cast to xs:double.

Implements QPatternist::Numeric.

Definition at line 87 of file qinteger.cpp.

88 {
89  return static_cast<xsDouble>(m_value);
90 }
const xsInteger m_value
Definition: qinteger_p.h:133

◆ toFloat()

xsFloat Integer::toFloat ( ) const
virtual
Returns
the particular number's value as a native representation of the type xs:float. This can be considered that the value is cast to xs:float.

Implements QPatternist::Numeric.

Definition at line 97 of file qinteger.cpp.

98 {
99  return static_cast<xsFloat>(m_value);
100 }
const xsInteger m_value
Definition: qinteger_p.h:133
xsDouble xsFloat

◆ toInteger()

xsInteger Integer::toInteger ( ) const
virtual
Returns
the particular number's value as a native representation of the type xs:integer. This can be considered that the value is cast to xs:integer.

Implements QPatternist::Numeric.

Definition at line 92 of file qinteger.cpp.

93 {
94  return m_value;
95 }
const xsInteger m_value
Definition: qinteger_p.h:133

◆ toNegated()

Item Integer::toNegated ( ) const
virtual

Unary minus.

Implements QPatternist::Numeric.

Definition at line 147 of file qinteger.cpp.

148 {
149  return fromValue(-m_value);
150 }
static Item fromValue(const xsInteger num)
Definition: qinteger.cpp:52
const xsInteger m_value
Definition: qinteger_p.h:133

◆ toUnsignedInteger()

qulonglong Integer::toUnsignedInteger ( ) const
virtual
Returns
the number as an unsigned integer. If the value is not unsigned, the code asserts and behavior is undefined.

Implements QPatternist::Numeric.

Definition at line 157 of file qinteger.cpp.

158 {
159  Q_ASSERT_X(false, Q_FUNC_INFO,
160  "It makes no sense to call this function, see Numeric::toUnsignedInteger().");
161  return 0;
162 }
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ type()

ItemType::Ptr Integer::type ( ) const
virtual
Returns
always BuiltinTypes::xsInteger

Implements QPatternist::AtomicValue.

Definition at line 82 of file qinteger.cpp.

83 {
85 }
static const AtomicType::Ptr xsInteger

Properties

◆ m_value

const xsInteger QPatternist::Integer::m_value
private

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