specificatorCall() method from fcf::TypeInfo class
Class:
Package: fcfBasis
File: bits/PartType/TypeInfoDefinition.hpp
Available from version: 1.0.1
Retrieves a call specificator as a pointer to a specialized function for the given specificator.
If no specificator handler function is defined for the specified specificator, calling the
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
- Type of specificator
Arguments
- 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
- A specialized pointer to a specifier handler function.
Example:
#include <iostream>
#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 specificator using the method specificatorCall
fcf::ResolveSpecificator::CallType call = ti->specificatorCall <fcf::ResolveSpecificator >();
// 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
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.