FCF 2.0 development in progress...
> > > > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

specifierUniversalCall() method from fcf::TypeInfo class

template <typename TSpecifier>
fcf::UniversalCall specifierUniversalCall()
template <typename TSpecifier>
fcf::UniversalCall specifierUniversalCall(fcf::Exception* a_dstError)

Class: fcf::TypeInfo

Package: fcfBasis

File: bits/PartType/TypeInfoDefinition.hpp

Available from version: 1.0.1

Retrieves a universal call function pointer for the given specifier.

The method returns a fcf::UniversalCall function pointer, which can be used to invoke the specifier operation on a fcf::Variant or other objects via the framework's universal calling mechanism.

If no specifier handler function is defined for the specified specifier, calling the fcf::TypeInfo::specifierUniversalCall method without parameters will throw a fcf::SpecifierNotFoundException exception.

If the function is called with the a_dstError parameter accepting a pointer to an error object, no exception will be thrown and the function will return 0 if there is no handler specifier.

Template arguments
TSpecifier - Type of specifier
Arguments

fcf::Exception* a_dstError
- The argument is a pointer to the object of fcf::Exception, whose fields will be filled in case of error. This argument may be zero.
Result
fcf::UniversalCall
- A universal function pointer for a specifier. If called with the a_dstError argument, the function returns 0 on error.
Thrown exceptions
fcf::SpecifierNotFoundException - An exception is thrown if the specified specifier is not defined for the given data type.

Example: Getting the universal call function

#include <iostream> // Define an implementation macro to include the implementation section in header files #define FCF_BASIS_IMPLEMENTATION #include <fcfBasis/basis.hpp> int main() { // Variant object that stores the std::string in itself fcf::Variant variantStr1 = "string 1"; fcf::Variant variantStr2 = "string 2"; // We get information about the type const fcf::TypeInfo* ti = fcf::Type< fcf::Variant >().typeInfo(); // We get the universal call function of the processor of the specifier using the method specifierUniversalCall fcf::UniversalCall call = ti->specifierUniversalCall<fcf::LessSpecifier>(0); if (call) { // Using the universal call to compare the variant with itself (as an example of usage) std::cout << "Universal call pointer obtained successfully." << std::endl; fcf::Variant result = call(&variantStr1, &variantStr2, 1); std::cout << "Compare ('" << variantStr1 << "' < '" << variantStr2 << "') : " << result << std::endl; } else { std::cout << "Specifier not found." << std::endl; } return 0; }

Output:

Universal call pointer obtained successfully. Compare ('string 1' < 'string 2') : true