Qt 4.8
|
Represents a cardinality, a possible , often represented by occurrence indicators. More...
#include <qcardinality_p.h>
Public Types | |
typedef qint32 | Count |
enum | CustomizeDisplayName { IncludeExplanation = 1, ExcludeExplanation } |
Public Functions | |
bool | allowsEmpty () const |
bool | allowsMany () const |
bool | canMatch (const Cardinality &other) const |
Cardinality (const Cardinality &other) | |
Cardinality () | |
QString | displayName (const CustomizeDisplayName explanation) const |
bool | isEmpty () const |
bool | isExact () const |
bool | isExactlyOne () const |
bool | isMatch (const Cardinality &other) const |
bool | isOneOrMore () const |
bool | isZeroOrOne () const |
Count | maximum () const |
Count | minimum () const |
Cardinality | operator & (const Cardinality &other) const |
bool | operator!= (const Cardinality &other) const |
Cardinality | operator* (const Cardinality &other) const |
Cardinality | operator+ (const Cardinality &other) const |
Cardinality & | operator+= (const Cardinality &other) |
Cardinality & | operator= (const Cardinality &other) |
bool | operator== (const Cardinality &other) const |
Cardinality | operator| (const Cardinality &other) const |
Cardinality & | operator|= (const Cardinality &other) |
Cardinality | toWithoutMany () const |
Static Public Functions | |
static Cardinality | empty () |
static Cardinality | exactlyOne () |
static Cardinality | fromCount (const Count count) |
static Cardinality | fromExact (const Count count) |
static Cardinality | fromRange (const Count minimum, const Count maximum) |
static Cardinality | oneOrMore () |
static Cardinality | twoOrMore () |
static Cardinality | zeroOrMore () |
static Cardinality | zeroOrOne () |
Private Functions | |
Cardinality (const Count min, const Count max) | |
Properties | |
Count | m_max |
Count | m_min |
Represents a cardinality, a possible , often represented by occurrence indicators.
As opposed to the cardinality concept in the XQuery/XPath specifications, which only allows cardinalities to be expressed with kleene operators, this representation allows ranges. For example, the cardinality 10-11, describes a sequence containing ten or eleven items, inclusive.
Definition at line 80 of file qcardinality_p.h.
This integer type, is what Cardinality uses for representing its ranges.
Definition at line 86 of file qcardinality_p.h.
Used with displayName(), and specifies how a display name for a Cardinality should be.
Enumerator | |
---|---|
IncludeExplanation | Includes a describing string in the return value of displayName(). |
ExcludeExplanation | Excludes a describing string in the return value of displayName(). |
Definition at line 92 of file qcardinality_p.h.
|
inline |
A traditional copy constructor. This Cardinality becomes identical to other
.
Definition at line 109 of file qcardinality_p.h.
|
inline |
This default constructor constructs an invalid Cardinality. Using its operators and members yields undefined results. A value must first be assigned to it by creating a Cardinality with fromRange(), fromCount(), or one of the predefined cardinalities such as empty() or oneOrMore().
Definition at line 120 of file qcardinality_p.h.
Referenced by empty(), exactlyOne(), fromCount(), fromExact(), fromRange(), oneOrMore(), operator &(), operator*(), operator+(), operator|(), toWithoutMany(), twoOrMore(), zeroOrMore(), and zeroOrOne().
Definition at line 528 of file qcardinality_p.h.
|
inline |
true
if this Cardinality allows no items. For example, for zeroOrOne() is true
returned, while for oneOrMore() is false
returned. Definition at line 254 of file qcardinality_p.h.
Referenced by QPatternist::InstanceOf::evaluateEBV(), QPatternist::CastableAs::evaluateEBV(), QPatternist::CardinalityVerifier::evaluateSequence(), QPatternist::CardinalityVerifier::evaluateSingleton(), QPatternist::CastAs::evaluateSingleton(), QPatternist::CastAs::expectedOperandTypes(), QPatternist::TextNodeConstructor::staticType(), QPatternist::SimpleContentConstructor::staticType(), QPatternist::ValueComparison::staticType(), QPatternist::NodeComparison::staticType(), QPatternist::CastAs::staticType(), QPatternist::CastableAs::typeCheck(), and QPatternist::CastAs::typeCheck().
|
inline |
true
if this Cardinality allows one or more items. For example, for zeroOrOne() is false
returned, while for zeroOrMore() is true
returned. Definition at line 244 of file qcardinality_p.h.
Referenced by QPatternist::CastableAs::CastableAs(), QPatternist::CastAs::CastAs(), QPatternist::NodeSortExpression::compress(), QPatternist::ForClause::compress(), QPatternist::StringJoinFN::compress(), QPatternist::OrderBy::compress(), QPatternist::InstanceOf::evaluateEBV(), QPatternist::CastableAs::evaluateEBV(), QPatternist::NodeSortExpression::evaluateSequence(), QPatternist::CardinalityVerifier::evaluateSequence(), QPatternist::GeneralComparison::typeCheck(), QPatternist::AddingAggregate::typeCheck(), QPatternist::AvgFN::typeCheck(), QPatternist::DistinctValuesFN::typeCheck(), and QPatternist::ReverseFN::typeCheck().
|
inline |
Determines whether at least one of the possible outcomes represented by other
, can match this Cardinality. For example, if this Cardinality is oneOrMore(), true
will be returned if other
is exactlyOne() or zeroOrOne().
Definition at line 300 of file qcardinality_p.h.
Referenced by QPatternist::Existence< Id >::compress(), and QPatternist::CardinalityVerifier::verifyCardinality().
QString Cardinality::displayName | ( | const CustomizeDisplayName | explanation | ) | const |
Returns a string representation of this Cardinality.
If explain
is ExcludeExplanation the kleene operator is returned. For example, if the Cardinality is zeroOrOne, is "?" returned.
If explain is IncludeExplanation a string more suited for human interpretation is returned, which is appropriately translated. For example, when the locale is English and this Cardinality being zeroOrOne, then is 'zero or one("?")' returned.
Typically, passing ExcludeExplanation is useful when generating function signatures and the like, while passing IncludeExplanation is suitable appropriate when generating error messages.
Definition at line 50 of file qcardinality.cpp.
Referenced by QPatternist::GenericSequenceType::displayName(), QPatternist::formatType(), and isExact().
|
inlinestatic |
The cardinality assigned to the exprssion ()
, formally speaking. The cardinality part of empty-sequence()
.
Definition at line 128 of file qcardinality_p.h.
Referenced by QPatternist::EmptySequenceType::cardinality(), QPatternist::Existence< Id >::compress(), QPatternist::CastAs::evaluateSingleton(), operator &(), and QPatternist::ExpressionSequence::typeCheck().
|
inlinestatic |
The cardinality implicitly specified in for example the sequence type item()
. It has no kleene operator.
Definition at line 137 of file qcardinality_p.h.
Referenced by QPatternist::VariableLoader::announceExternalVariable(), QPatternist::Validate::create(), QPatternist::CastAs::evaluateSingleton(), QPatternist::XPath20CoreFunctions::retrieveExpression(), QPatternist::CurrentFN::staticType(), QPatternist::RangeVariableReference::staticType(), QPatternist::ContextItem::staticType(), QPatternist::ArithmeticExpression::staticType(), QPatternist::Literal::staticType(), QPatternist::EBVExtractor::staticType(), QPatternist::CastAs::staticType(), QPatternist::SumFN::staticType(), QPatternist::RootFN::staticType(), QPatternist::DistinctValuesFN::staticType(), and QPatternist::yyparse().
|
inlinestatic |
Determines the cardinality from the count of a sequence. For example, if count
is 11, a Cardinality is returned that allows at minimum and maximum 11 items.
count
must be positive or zero. If it is not, the result is undefined. When debugging is enabled, a Q_ASSERT() macro ensures this.
Definition at line 186 of file qcardinality_p.h.
Referenced by QPatternist::LiteralSequence::staticType().
|
inlinestatic |
Definition at line 214 of file qcardinality_p.h.
Referenced by QPatternist::RangeExpression::staticType().
|
inlinestatic |
Creates a Cardinality that allows minimum
and maximum
items, inclusive.
If maximum
is -1, it signals infinity.
If you before hand knows that a predefined Cardinality is needed, remember to use one of the factory functions empty(), zeroOrOne(), exactlyOne(), oneOrMore() or zeroOrMore(), since they improves readability, are safer, and slightly faster.
Definition at line 204 of file qcardinality_p.h.
Referenced by QPatternist::RemoveFN::staticType().
|
inline |
true
if this Cardinality is empty, the empty-sequence()
, otherwise false
. Definition at line 320 of file qcardinality_p.h.
Referenced by QPatternist::NodeComparison::compress(), displayName(), QPatternist::CardinalityVerifier::evaluateSequence(), and QPatternist::GenericSequenceType::makeGenericSequenceType().
|
inline |
Determines whether this Cardinality only allows a specific length. For example, empty() and exactlyOne() are exact, but oneOrMore() or zeroOrOne() is not.
Definition at line 360 of file qcardinality_p.h.
Referenced by displayName().
|
inline |
true
if this Cardinality only allows exactly one item, otherwise false
. Definition at line 340 of file qcardinality_p.h.
Referenced by displayName().
|
inline |
Determines whether all the possible outcomes represented by other
, will always match this Cardinality. For example, if this Cardinality is oneOrMore(), true
will be returned if other
is exactlyOne(), but false if other
is zeroOrOne().
Definition at line 279 of file qcardinality_p.h.
Referenced by QPatternist::InstanceOf::compress(), QPatternist::CastableAs::compress(), QPatternist::CardinalityVerifier::compress(), QPatternist::Existence< Id >::compress(), QPatternist::BySequenceTypeIdentifier::matches(), QPatternist::SequenceType::matches(), QPatternist::CastAs::typeCheck(), and QPatternist::CardinalityVerifier::verifyCardinality().
|
inline |
true
if this Cardinality only allows one or more items, otherwise false
. Definition at line 350 of file qcardinality_p.h.
Referenced by displayName().
|
inline |
true
if this Cardinality is zero-or-one, ?
, otherwise false
. Definition at line 330 of file qcardinality_p.h.
Referenced by displayName().
|
inline |
Definition at line 234 of file qcardinality_p.h.
Referenced by displayName().
|
inline |
Definition at line 224 of file qcardinality_p.h.
Referenced by displayName().
|
inlinestatic |
Allows one or more. Represented by the kleene operator +
.
Definition at line 163 of file qcardinality_p.h.
Referenced by QPatternist::Existence< Id >::compress(), QPatternist::XPath20CoreFunctions::retrieveExpression(), QPatternist::FunctionCall::staticType(), QPatternist::DistinctValuesFN::staticType(), and QPatternist::yyparse().
|
inline |
Computes the intersection of this Cardinality and other
, and returns the result. For example, the intersection between zeroOrOne() and oneOrMore() is exactlyOne().
If no intersection exists, such as the case in empty() and exactlyOne(), then is a default constructed Cardinality is returned. That is, an invalid Cardinality.
Definition at line 424 of file qcardinality_p.h.
|
inline |
|
inline |
Multiplies this Cardinality with other
, and returns the result. The minimum and maximum of each Cardinality is multiplied such that the new Cardinality represents the possible range of the two sequences being multiplied, length-wise. For example the Cardinality 4, 5 multiplied with 2, 3 becomes 8, 15.
Definition at line 482 of file qcardinality_p.h.
|
inline |
Adds two cardinalities, as if two sequences represented by them were concatenated. For example, if this Cardinality allows the range 6-8 and other
allows 0-1, the return Cardinality has a range of 6-9.
Definition at line 448 of file qcardinality_p.h.
|
inline |
Behaves as operator+() but assigns the result to this Cardinality.
Definition at line 460 of file qcardinality_p.h.
|
inline |
A traditional assignment operator. Behaves as assignment operators typically do.
Definition at line 496 of file qcardinality_p.h.
|
inline |
Determines whether other
is equal to this Cardinality.
For example, empty() is equal to empty(), but zeroOrOne() is not equal to exactlyOne().
true
if other
is equal to this Cardinality. Definition at line 512 of file qcardinality_p.h.
|
inline |
Computes the Cardinality that comprises this Cardinality as well as other
. For example, if this Cardinality is zeroOrOne() and other
is oneOrMore(), then is zeroOrMore() returned.
Definition at line 389 of file qcardinality_p.h.
|
inline |
Behaves as operator|() but assigns the result to this Cardinality.
Definition at line 401 of file qcardinality_p.h.
|
inline |
Maps directly to Formal Semantics' aggregate_quantifier
function.
Definition at line 267 of file qcardinality_p.h.
Referenced by QPatternist::RootFN::staticType().
|
inlinestatic |
Allows one or more. This cardinality has no kleene operator and is used by the implementation in order to be able to know when a cardinality that at amximum allows one, is exceeded.
Definition at line 173 of file qcardinality_p.h.
Referenced by QPatternist::CardinalityVerifier::evaluateSequence(), and QPatternist::CardinalityVerifier::evaluateSingleton().
|
inlinestatic |
Allows any amount. This is therefore the widest, an unconstrained cardinality. Represented by the kleene operator *
.
Definition at line 155 of file qcardinality_p.h.
Referenced by QPatternist::NoneType::cardinality(), QPatternist::EBVType::cardinality(), QPatternist::CardinalityVerifier::CardinalityVerifier(), QPatternist::quantificationType(), QPatternist::AxisStep::staticType(), QPatternist::CombineNodes::staticType(), and QPatternist::yyparse().
|
inlinestatic |
Allows both no item, as in empty(), and exactlyOne(). Represented by the kleene operator ?
.
Definition at line 146 of file qcardinality_p.h.
Referenced by QPatternist::ConstructorFunctionsFactory::ConstructorFunctionsFactory(), QPatternist::ConstructorFunctionsFactory::retrieveExpression(), QPatternist::XPath20CoreFunctions::retrieveExpression(), QPatternist::AxisStep::staticType(), QPatternist::ArithmeticExpression::staticType(), QPatternist::GenericPredicate::staticType(), QPatternist::SubsequenceFN::staticType(), and QPatternist::yyparse().
|
private |
Definition at line 534 of file qcardinality_p.h.
Referenced by allowsMany(), canMatch(), displayName(), isEmpty(), isExact(), isExactlyOne(), isMatch(), isOneOrMore(), isZeroOrOne(), maximum(), operator &(), operator!=(), operator*(), operator+(), operator+=(), operator=(), operator==(), operator|(), and operator|=().
|
private |
Definition at line 533 of file qcardinality_p.h.
Referenced by allowsEmpty(), allowsMany(), canMatch(), isEmpty(), isExact(), isExactlyOne(), isMatch(), isOneOrMore(), isZeroOrOne(), maximum(), minimum(), operator &(), operator!=(), operator*(), operator+(), operator+=(), operator=(), operator==(), operator|(), operator|=(), and toWithoutMany().