typeInfo() method from fcf::Type class
Class:
Package: fcfBasis
File: bits/PartType/TypeDefinition.hpp
Available from version: 1.0.1
Retrieves a pointer to the metadata descriptor of the type.
The method returns a constant pointer to a
Result
- A constant pointer to the fcf::TypeInfo structure containing the type's metadata.
Example: Basic metadata retrieval
#include <iostream>
#include <string>
// Define an implementation macro to include the implementation section in header files
#define FCF_BASIS_IMPLEMENTATION
#include <fcfBasis/basis.hpp>
// 1. Define a custom structure for demonstration
struct MyCustomStruct {
int id;
std::string name;
};
// 2. Register the type in the fcf system
FCF_TYPE_REGISTRATION (MyCustomStruct, "MyCustomStruct", 0);
int main() {
// 3. Access metadata for the custom type
// We use fcf::Type to get a descriptor for MyCustomStruct
fcf::Type <MyCustomStruct> typeDescriptor;
// 4. Retrieve the metadata using the typeInfo() method
// The method returns a pointer to the TypeInfo object containing the type's properties
const fcf::TypeInfo * ti = typeDescriptor.typeInfo ();
// 5. Print the retrieved information
std::cout << "=== Type Metadata ===" << std::endl;
std::cout << "Type Name: " << ti->name << std::endl;
std::cout << "Type Index: 0x" << std::hex << ti->index << std::dec << std::endl;
std::cout << "Type Size: " << ti->size << " bytes" << std::endl;
return 0;
}
Output:
Type Name: MyCustomStruct
Type Index: 0x1000015
Type Size: 40 bytes
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.