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

specifierCall() method from fcf::TypeInfo class

template <typename TSpecifier>
TSpecifier::CallType specifierCall()
template <typename TSpecifier>
TSpecifier::CallType specifierCall(fcf::Exception* a_dstError)

Class: fcf::TypeInfo

Package: fcfBasis

File: bits/PartType/TypeInfoDefinition.hpp

Available from version: 1.0.1

Retrieves a specifier call as a pointer to a specialized function for the given specifier.

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

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

Note that fcf::SpecifierInfo::call (fcf::TypeInfo::specifierCall) is only filled if the specified specifier has a declared type of TSpecifier::CallType.

Template arguments
TSpecifier - Type of specifier
Arguments

fcf::Exception* a_dstError
- The argument is a pointer to an fcf::Exception object whose fields will be filled in the event of an error. This argument may be zero.
Result
TSpecifier::CallType
- A specialized pointer to a specifier handler function. 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:

#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 variant = "some string"; // We get information about the type const fcf::TypeInfo* ti = fcf::Type< fcf::Variant >().typeInfo(); // We get the function of the processor of the specifier using the method specifierCall fcf::ResolveSpecifier::CallType call = ti->specifierCall<fcf::ResolveSpecifier>(); // We get information about the stored object in the variant object fcf::ResolveData resolveData =call(&variant); // The index of the stored type std::cout << "Type index: " << resolveData.typeIndex << std::endl; // The name of the stored type std::cout << "Type name: " << fcf::getTypeInfo(resolveData.typeIndex)->name << std::endl; // Indicating that the given container may contain a random type of data std::cout << "Invariant state: " << resolveData.invariant << std::endl; // The pointer for the stored data std::cout << "Data: " << *(std::string*)resolveData.data << std::endl; return 0; }

Output:

Type index: 30 Type name: std::string Invariant state: 1 Data: some string