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

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

#include <qboolean_p.h>

Inheritance diagram for QPatternist::Boolean:
QPatternist::AtomicValue QSharedData QPatternist::CppCastingHelper< AtomicValue >

Public Types

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

Public Functions

virtual bool evaluateEBV (const QExplicitlySharedDataPointer< DynamicContext > &) const
 
virtual QString stringValue () const
 
virtual ItemType::Ptr type () const
 
bool value () 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 bool evaluateEBV (const Item::Iterator::Ptr &e, const QExplicitlySharedDataPointer< DynamicContext > &)
 
static bool evaluateEBV (const Item &first, const Item::Iterator::Ptr &e, const QExplicitlySharedDataPointer< DynamicContext > &)
 
static bool evaluateEBV (const Item &item, const QExplicitlySharedDataPointer< DynamicContext > &context)
 
static AtomicValue::Ptr fromLexical (const QString &val)
 
static Boolean::Ptr fromValue (const bool value)
 
- 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

 Boolean (const bool value)
 
- Protected Functions inherited from QPatternist::AtomicValue
 AtomicValue ()
 
- Protected Functions inherited from QPatternist::CppCastingHelper< AtomicValue >
 CppCastingHelper ()
 

Properties

const bool m_value
 

Friends

class CommonValues
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Implements the value instance of the xs:boolean type.

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

Definition at line 69 of file qboolean_p.h.

Typedefs

◆ Ptr

Definition at line 72 of file qboolean_p.h.

Constructors and Destructors

◆ Boolean()

Boolean::Boolean ( const bool  value)
protected

Definition at line 99 of file qboolean.cpp.

99  : m_value(value)
100 {
101 }
bool value() const
Definition: qboolean_p.h:109
const bool m_value
Definition: qboolean_p.h:119

Functions

◆ evaluateEBV() [1/4]

bool Boolean::evaluateEBV ( const Item::Iterator::Ptr e,
const QExplicitlySharedDataPointer< DynamicContext > &  context 
)
static
Returns
the boolean value this Boolean represents

Definition at line 55 of file qboolean.cpp.

Referenced by evaluateEBV(), QPatternist::RangeVariableReference::evaluateEBV(), QPatternist::Literal::evaluateEBV(), QPatternist::ExternalVariableLoader::evaluateEBV(), QPatternist::Expression::evaluateEBV(), and QPatternist::GenericPredicate::mapToItem().

57 {
58  return evaluateEBV(it->next(), it, context);
59 }
#define it(className, varName)
static bool evaluateEBV(const Item::Iterator::Ptr &e, const QExplicitlySharedDataPointer< DynamicContext > &)
Definition: qboolean.cpp:55

◆ evaluateEBV() [2/4]

bool Boolean::evaluateEBV ( const Item first,
const Item::Iterator::Ptr e,
const QExplicitlySharedDataPointer< DynamicContext > &  context 
)
static

Definition at line 61 of file qboolean.cpp.

64 {
65  Q_ASSERT(it);
66  Q_ASSERT(context);
67 
68  if(!first)
69  return false;
70  else if(first.isNode())
71  return true;
72 
73  const Item second(it->next());
74 
75  if(second)
76  {
77  Q_ASSERT(context);
78  context->error(QtXmlPatterns::tr("Effective Boolean Value cannot be calculated for a sequence "
79  "containing two or more atomic values."),
81  QSourceLocation());
82  return false;
83  }
84  else
85  return first.as<AtomicValue>()->evaluateEBV(context);
86 }
#define it(className, varName)
static bool evaluateEBV(const Item::Iterator::Ptr &e, const QExplicitlySharedDataPointer< DynamicContext > &)
Definition: qboolean.cpp:55
bool isNode() const
Determines whether this item is an atomic value, or a node.
Definition: qitem_p.h:349
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void error(const QString &message, const ReportContext::ErrorCode errorCode, const QSourceLocation &sourceLocation)
Base class for all classes representing atomic values.
Definition: qitem_p.h:118
The QSourceLocation class identifies a location in a resource by URI, line, and column.
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
TCastTarget * as() const
Definition: qitem_p.h:278

◆ evaluateEBV() [3/4]

bool Boolean::evaluateEBV ( const Item item,
const QExplicitlySharedDataPointer< DynamicContext > &  context 
)
static

Definition at line 88 of file qboolean.cpp.

90 {
91  if(!item)
92  return false;
93  else if(item.isNode())
94  return true;
95  else
96  return item.as<AtomicValue>()->evaluateEBV(context);
97 }
static bool evaluateEBV(const Item::Iterator::Ptr &e, const QExplicitlySharedDataPointer< DynamicContext > &)
Definition: qboolean.cpp:55
bool isNode() const
Determines whether this item is an atomic value, or a node.
Definition: qitem_p.h:349
Base class for all classes representing atomic values.
Definition: qitem_p.h:118
TCastTarget * as() const
Definition: qitem_p.h:278

◆ evaluateEBV() [4/4]

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

Get the Effective Boolean Value of this boolean value. For xs:boolean, this is simply the value.

Reimplemented from QPatternist::AtomicValue.

Definition at line 110 of file qboolean.cpp.

111 {
112  return m_value;
113 }
const bool m_value
Definition: qboolean_p.h:119

◆ fromLexical()

AtomicValue::Ptr Boolean::fromLexical ( const QString val)
static

Creates a boolean value from a lexical representation. "true" and "1" becomes true, while "false" and "0" becomes false.

Definition at line 120 of file qboolean.cpp.

Referenced by QPatternist::StringToBooleanCaster::castFrom(), QPatternist::XsdSchemaParser::parseComplexContent(), QPatternist::XsdSchemaParser::parseDefaultOpenContent(), QPatternist::XsdSchemaParser::parseFractionDigitsFacet(), QPatternist::XsdSchemaParser::parseGlobalComplexType(), QPatternist::XsdSchemaParser::parseGlobalElement(), QPatternist::XsdSchemaParser::parseLengthFacet(), QPatternist::XsdSchemaParser::parseLocalComplexType(), QPatternist::XsdSchemaParser::parseLocalElement(), QPatternist::XsdSchemaParser::parseMaxExclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxInclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxLengthFacet(), QPatternist::XsdSchemaParser::parseMinExclusiveFacet(), QPatternist::XsdSchemaParser::parseMinInclusiveFacet(), QPatternist::XsdSchemaParser::parseMinLengthFacet(), QPatternist::XsdSchemaParser::parseTotalDigitsFacet(), QPatternist::XsdSchemaParser::parseWhiteSpaceFacet(), and QPatternist::XsdValidatingInstanceReader::validateElement().

121 {
122  const QString val(lexical.trimmed()); /* Apply the whitespace facet. */
123 
124  if(val == QLatin1String("true") || val == QChar(QLatin1Char('1')))
126  else if(val == QLatin1String("false") || val == QChar(QLatin1Char('0')))
128  else
130 }
static const AtomicValue::Ptr BooleanTrue
static AtomicValue::Ptr createError(const QString &description=QString(), const ReportContext::ErrorCode=ReportContext::FORG0001)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static const AtomicValue::Ptr BooleanFalse
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ fromValue()

Boolean::Ptr Boolean::fromValue ( const bool  value)
static

◆ stringValue()

QString Boolean::stringValue ( ) const
virtual

Implements QPatternist::AtomicValue.

Definition at line 103 of file qboolean.cpp.

104 {
105  return m_value
108 }
static const AtomicValue::Ptr FalseString
virtual QString stringValue() const =0
static const AtomicValue::Ptr TrueString
const bool m_value
Definition: qboolean_p.h:119

◆ type()

ItemType::Ptr Boolean::type ( ) const
virtual

Implements QPatternist::AtomicValue.

Definition at line 132 of file qboolean.cpp.

133 {
135 }
static const AtomicType::Ptr xsBoolean

◆ value()

bool QPatternist::Boolean::value ( ) const
inline

Friends and Related Functions

◆ CommonValues

friend class CommonValues
friend

Definition at line 115 of file qboolean_p.h.

Properties

◆ m_value

const bool QPatternist::Boolean::m_value
private

Definition at line 119 of file qboolean_p.h.

Referenced by evaluateEBV(), and stringValue().


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