一个自动注册类，附带工厂，可根据需求自动反射出对象的实例

#include <iostream>

#include "AutoRegisterCategory.hpp"

using namespace std;


BEGIN_DECLARE_AUTO_REGISTER_CATEGORY(Parser)
public:
    virtual bool parse(char* msg, int size) = 0;
END_DECLARE_AUTO_REGISTER_CATEGORY(Parser)


BEGIN_DECLARE_SUB_AUTO_REGISTER_CATEGORY(TextParser, Parser)
public:
    virtual bool parse(char* msg, int size)
    {
        return msg != NULL && size != 0;
    }
END_DECLARE_SUB_AUTO_REGISTER_CATEGORY(TextParser, "TextParser")

int main()
{
    Parser* parser = Parser::Factory::create("TextParser");
    cout << parser << endl;

    return 0;
}