fcf::ResolveSpecifier class
Type:
class fcf::ResolveSpecifier
Package: fcfBasis
File: bits/PartSpecifier/ResolveSpecifierDefinition.hpp
Available from version: 1.0.1
This specifier retrieves information about the stored object of the specified type. For example, the data type contained in the specified
Typedef
Example:
#include <iostream>
// Define an implementation macro to include the implementation section in header files
#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_TYPE_REGISTRATION (MyData, "MyData", 0);
// Implement the ResolveSpecifier for MyData
namespace fcf {
template<>
struct Type <MyData, ResolveSpecifier > : public TypeImpl <MyData, ResolveSpecifier > {
enum { invariantValue = false };
// Specifier handler.
// This method must have the signature fcf::ResolveSpecifier::HandleType
inline void operator()(MyData * a_object, void** a_dstData, unsigned int* a_dstTypeIndex) {
*a_dstData = &a_object->value;
*a_dstTypeIndex = fcf::Type <int>().index ();
}
};
}
// Link the specifier to the type
FCF_SPECIFIER_REGISTRATION (MyData, fcf::ResolveSpecifier );
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::ResolveSpecifier >().call(&data);
std::cout << "Resolved Value: " << *static_cast<int *>(resolved.data ) << 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: 0x5
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.