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

specificatorUniversalCall() method from fcf::TypeInfo class

template <typename TSpecificator>
fcf::UniversalCall specificatorUniversalCall()
template <typename TSpecificator>
fcf::UniversalCall specificatorUniversalCall(fcf::Exception* a_error)

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 specificator.

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

If no specificator handler function is defined for the specified specificator, calling the fcf::TypeInfo::specificatorUniversalCall method without parameters will throw a fcf::SpecificatorNotFoundException exception.

If the function instance is called with the parameter that takes a pointer to an error object, then the exception will not be thrown if there is no handler.

Template arguments
TSpecificator
- Type of specificator

Arguments

fcf::Exception* a_error
- The argument is a pointer to the object of fcf::Exception, whose fields will be filled in case of error. If the argument is passed as zero, then in case of error, the function will return zero.
Result
fcf::UniversalCall
- A universal function pointer for the specificator.

Example: Getting the universal call function

#include <iostream> #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 specificator using the method specificatorUniversalCall fcf::UniversalCall call = ti->specificatorUniversalCall<fcf::LessSpecificator>(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 << "Specificator not found." << std::endl; } return 0; }

Output:

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