Qt 4.8
|
Provides convenience methods for performing static casts between C++ classes. More...
#include <qcppcastinghelper_p.h>
Public Functions | |
template<typename TCastTarget > | |
const TCastTarget * | as () const |
template<typename TCastTarget > | |
TCastTarget * | as () |
Protected Functions | |
CppCastingHelper () | |
Provides convenience methods for performing static casts between C++ classes.
In Patternist, it is very common to do up-casts from Expression or Item, which typically involves writing messy code. Such an old-way cast looks like this:
CppCastingHelper provides the convenience method as() for this, which is functionally equivalent to the above code, but simpler:
The as() function performs a static cast.
By using CppCastingHelper, this is achieved:
dynamic_cast
to verify that the static casts are properly done, such that sensible error messages are given when the casts are invalid. It also traps invalid casts which nevertheless happen to work on a particular platform/compiler/hardware architecture.CppCastingHelper is a template class where the TSubClass parameter must be the class inheriting CppCastingHelper. See Item or Expression for demonstration.
Definition at line 97 of file qcppcastinghelper_p.h.
|
inlineprotected |
This constructor is protected because this class must be sub-classed.
Definition at line 153 of file qcppcastinghelper_p.h.
|
inline |
Casts this instance to:
and returns the result.
When compiled in debug mode, this function perform a dynamic_cast
, in order to check the correctness of the cast.
Definition at line 114 of file qcppcastinghelper_p.h.
Referenced by QPatternist::CastAs::castToQName(), QPatternist::XsdTypeChecker::checkConstrainingFacets(), QPatternist::XsdSchemaChecker::checkConstrainingFacets(), QPatternist::XsdTypeChecker::checkConstrainingFacetsBinary(), QPatternist::XsdTypeChecker::checkConstrainingFacetsBoolean(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDateTime(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDecimal(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDouble(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDuration(), QPatternist::XsdTypeChecker::checkConstrainingFacetsList(), QPatternist::XsdTypeChecker::checkConstrainingFacetsNotation(), QPatternist::XsdTypeChecker::checkConstrainingFacetsQName(), QPatternist::XsdTypeChecker::checkConstrainingFacetsSignedInteger(), QPatternist::XsdTypeChecker::checkConstrainingFacetsString(), QPatternist::XsdTypeChecker::checkConstrainingFacetsUnion(), QPatternist::XsdTypeChecker::checkConstrainingFacetsUnsignedInteger(), QPatternist::SubsequenceFN::compress(), QPatternist::GenericPredicate::create(), QPatternist::DeepEqualFN::evaluateEBV(), QPatternist::ComparisonIdentifier::matches(), QPatternist::IntegerIdentifier::matches(), 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::parseMinMaxConstraint(), QPatternist::XsdSchemaParser::parseTotalDigitsFacet(), QPatternist::XsdSchemaParser::parseWhiteSpaceFacet(), QPatternist::XsdSchemaResolver::resolveEnumerationFacetValues(), QPatternist::XSLT20CoreFunctions::retrieveExpression(), QPatternist::XPath10CoreFunctions::retrieveExpression(), QPatternist::XPath20CoreFunctions::retrieveExpression(), QPatternist::RangeExpression::staticType(), QPatternist::SubsequenceFN::staticType(), QPatternist::AtomicValue::toQt(), QPatternist::ElementConstructor::typeCheck(), QPatternist::XsdValidatingInstanceReader::validateElement(), and QPatternist::yyparse().
|
inline |
Casts this instance to:
and returns the result.
When compiled in debug mode, a dynamic_cast
is attempted, in order to check the correctness of the cast.
Definition at line 138 of file qcppcastinghelper_p.h.