XML Serialization with C++ Boost: how to refer to the base class?

When XML serializing a class with the Boost libraries, there is a point where we likely need to do it for a derived class. In this case, the manual 1 instructs to include a reference to the base class:

BOOST_SERIALIZATION_BASE_OBJECT_NVP(my_base_class)

However, if this class is inside a namespace, are we supposed to include the name of the class with, OR without the namespace?

For example, the base class is Awesome::Foo and a derived class from it is Awesome::Bar .

The question is, we should use, inside the implementation of the serialization of Bar, which of the following statements?

  • BOOST_SERIALIZATION_BASE_OBJECT_NVP(Foo)
  • BOOST_SERIALIZATION_BASE_OBJECT_NVP(Awesome::Foo)

  • I would conclude from the Boost documentation that Case 1 is correct.

    According to the documentation linked to on Boost serialization

    they state with respect to BOOST_SERIALIZATION_BASE_OBJECT_NVP(my_base_class) :

    "Note that these macros must be used in the namespace of the class, and without qualifying the namespace in the argument. "

    They also give a code example using this macro at this example link.

    链接地址: http://www.djcxy.com/p/60652.html

    上一篇: 类的包装指针的Boost序列化

    下一篇: 用C ++ Boost实现XML序列化:如何引用基类?