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

fcf::ResolveSpecificator class

Type:
class fcf::ResolveSpecificator

Package: fcfBasis

File: bits/PartSpecificator/ResolveSpecificatorDefinition.hpp

Available from version: 1.0.1

This specificator retrieves information about the stored object of the specified type. For example, the data type contained in the specified fcf::Variant object.

Typedef
typedef CallType - Function type for the fcf::ResolveSpecificator handler.

Example:

#include <iostream> #define FCF_BASIS_IMPLEMENTATION #include <fcfBasis/basis.hpp> // A custom structure for demonstration struct MyData { int value; }; // Register the type in the fcf system FCF_TYPEID_REGISTRY(MyData, "MyData", 0); // Implement the ResolveSpecificator for MyData namespace fcf { struct Type<MyData, ResolveSpecificator> : public TypeImpl<MyData, ResolveSpecificator> { // Specificator handler. // This method must have the signature fcf::ResolveSpecificator::CallType ResolveData call(MyData* a_object) { // Return the pointer to the data and its type index return ResolveData{ a_object, fcf::Type<MyData>().index(), false }; } }; } // Link the specifier to the type FCF_SPECIFICATOR_REGISTRY(MyData, fcf::ResolveSpecificator); int main() { // Create an instance of our registered type MyData data = { 42 }; // Execute the resolution: it returns a ResolveData structure fcf::ResolveData resolved = fcf::Type<MyData, fcf::ResolveSpecificator>().call(&data); std::cout << "Resolved Value: " << static_cast<MyData*>(resolved.data)->value << std::endl; std::cout << "Resolved Type Index: 0x" << std::hex << resolved.typeIndex << std::dec << std::endl; return 0; }

Output:

Resolved Value: 42 Resolved Type Index: 0x1000015