Qt 4.8
Functions
qxsdtypechecker.cpp File Reference
#include "qxsdtypechecker_p.h"
#include "qabstractdatetime_p.h"
#include "qbase64binary_p.h"
#include "qboolean_p.h"
#include "qdecimal_p.h"
#include "qderivedinteger_p.h"
#include "qduration_p.h"
#include "qgenericstaticcontext_p.h"
#include "qhexbinary_p.h"
#include "qnamespaceresolver_p.h"
#include "qpatternplatform_p.h"
#include "qqnamevalue_p.h"
#include "qvaluefactory_p.h"
#include "qxmlnamepool.h"
#include "qxsdschemahelper_p.h"
#include "qxsdschemamerger_p.h"
#include "qxsdstatemachine_p.h"
#include "qabstractfloat_p.h"
#include "qxsdschemadebugger_p.h"

Go to the source code of this file.

Functions

static AnySimpleType::Ptr comparableType (const AnySimpleType::Ptr &type)
 
static int fractionDigitsForDecimal (const QString &lexicalValue)
 
static int totalDigitsForDecimal (const QString &lexicalValue)
 
static int totalDigitsForSignedLongLong (long long value)
 
static int totalDigitsForUnsignedLongLong (unsigned long long value)
 

Function Documentation

◆ comparableType()

static AnySimpleType::Ptr comparableType ( const AnySimpleType::Ptr type)
static

Definition at line 84 of file qxsdtypechecker.cpp.

Referenced by QPatternist::XsdTypeChecker::checkConstrainingFacetsList(), QPatternist::XsdTypeChecker::checkConstrainingFacetsUnion(), and QPatternist::XsdTypeChecker::valuesAreEqual().

85 {
86  if (!type->isDefinedBySchema()) {
87  return type;
88  } else {
89  const XsdSimpleType::Ptr simpleType(type);
90  if (type->category() == SchemaType::SimpleTypeAtomic) {
91  return simpleType->primitiveType();
92  } else if (type->category() == SchemaType::SimpleTypeList) {
93  return simpleType->itemType();
94  } else if (type->category() == SchemaType::SimpleTypeUnion) {
95  return simpleType->memberTypes().first();
96  }
97  }
98 
99  Q_ASSERT(false);
100  return AnySimpleType::Ptr();
101 }
int type
Definition: qmetatype.cpp:239
virtual TypeCategory category() const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual bool isDefinedBySchema() const
Definition: qschematype.cpp:75

◆ fractionDigitsForDecimal()

static int fractionDigitsForDecimal ( const QString lexicalValue)
static

Definition at line 152 of file qxsdtypechecker.cpp.

Referenced by QPatternist::XsdTypeChecker::checkConstrainingFacetsDecimal().

153 {
154  // we use the lexical value here, as the conversion to double might strip
155  // away decimal positions
156 
157  QString trimmedValue(lexicalValue.trimmed());
158  const int pos = trimmedValue.indexOf(QLatin1Char('.'));
159  if (pos == -1) // no '.' -> 0 fraction digits
160  return 0;
161  else
162  return (trimmedValue.length() - pos - 1);
163 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ totalDigitsForDecimal()

static int totalDigitsForDecimal ( const QString lexicalValue)
static

Definition at line 118 of file qxsdtypechecker.cpp.

Referenced by QPatternist::XsdTypeChecker::checkConstrainingFacetsDecimal().

119 {
120  const QLatin1Char zeroChar('0');
121  const int length = lexicalValue.length() - 1;
122 
123  // strip leading zeros
124  int pos = 0;
125  while (lexicalValue.at(pos) == zeroChar && (pos != length))
126  pos++;
127 
128  QString value = lexicalValue.mid(pos);
129 
130  // if contains '.' strip trailing zeros
131  if (value.contains(QLatin1Char('.'))) {
132  pos = value.length() - 1;
133  while (value.at(pos) == zeroChar) {
134  pos--;
135  }
136 
137  value = value.left(pos + 1);
138  }
139 
140  // check number of digits of remaining string
141  int totalDigits = 0;
142  for (int i = 0; i < value.count(); ++i)
143  if (value.at(i).isDigit())
144  ++totalDigits;
145 
146  if (totalDigits == 0)
147  totalDigits = 1;
148 
149  return totalDigits;
150 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
int count() const
Definition: qstring.h:103
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
bool isDigit() const
Returns true if the character is a decimal digit (Number_DecimalDigit); otherwise returns false...
Definition: qchar.cpp:699

◆ totalDigitsForSignedLongLong()

static int totalDigitsForSignedLongLong ( long long  value)
static

Definition at line 103 of file qxsdtypechecker.cpp.

Referenced by QPatternist::XsdTypeChecker::checkConstrainingFacetsSignedInteger().

104 {
105  QString number = QString::number(value);
106  if (number.startsWith(QLatin1Char('-')))
107  number = number.mid(1);
108 
109  return number.length();
110 }
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
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ totalDigitsForUnsignedLongLong()

static int totalDigitsForUnsignedLongLong ( unsigned long long  value)
static

Definition at line 112 of file qxsdtypechecker.cpp.

Referenced by QPatternist::XsdTypeChecker::checkConstrainingFacetsUnsignedInteger().

113 {
114  const QString number = QString::number(value);
115  return number.length();
116 }
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
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83