mirror of
https://github.com/boostorg/core.git
synced 2025-07-30 04:47:24 +02:00
Remove save and load helpers and update documentation for NVP
This commit is contained in:
27
doc/nvp.qbk
27
doc/nvp.qbk
@ -40,6 +40,7 @@ namespace boost {
|
|||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class nvp {
|
class nvp {
|
||||||
|
public:
|
||||||
nvp(const char* name, T& value) noexcept;
|
nvp(const char* name, T& value) noexcept;
|
||||||
|
|
||||||
const char* name() const noexcept;
|
const char* name() const noexcept;
|
||||||
@ -49,13 +50,7 @@ class nvp {
|
|||||||
const T& const_value() const noexcept;
|
const T& const_value() const noexcept;
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
void save(A& archive, unsigned) const;
|
void serialize(A& archive, unsigned version);
|
||||||
|
|
||||||
template<class A>
|
|
||||||
void load(A& archive, unsigned);
|
|
||||||
|
|
||||||
template<class A>
|
|
||||||
void serialize(A& archive, unsigned);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -80,26 +75,22 @@ const nvp<T> make_nvp(const char* name, T& value) noexcept;
|
|||||||
|
|
||||||
[variablelist
|
[variablelist
|
||||||
[[`const char* name() const noexcept;`]
|
[[`const char* name() const noexcept;`]
|
||||||
[Returns the stored name pointer.]]
|
[Returns a pointer to the name.]]
|
||||||
[[`T& value() const noexcept;`]
|
[[`T& value() const noexcept;`]
|
||||||
[Returns the stored value pointer.]]
|
[Returns a reference to the value.]]
|
||||||
[[`const T& const_value() const noexcept;`]
|
[[`const T& const_value() const noexcept;`]
|
||||||
[Returns the stored value pointer.]]
|
[Returns a reference to the value.]]
|
||||||
[[`template<class A> void save(A& archive, unsigned) const;`]
|
|
||||||
[Calls `archive.operator<<(const_value())`.]]
|
|
||||||
[[`template<class A> void load(A& archive, unsigned);`]
|
|
||||||
[Calls `archive.operator>>(value())`.]]
|
|
||||||
[[`template<class A> void serialize(A& archive,
|
[[`template<class A> void serialize(A& archive,
|
||||||
unsigned version);`]
|
unsigned version);`]
|
||||||
[Calls `save(archive, version)` if `A::is_saving` is a true type,
|
[Calls `archive.operator<<(const_value())` if `A::is_saving` is a true type,
|
||||||
otherwise `load(archive, version)`.]]]
|
otherwise `archive.operator>>(value())`.]]]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[section Traits]
|
[section Traits]
|
||||||
|
|
||||||
[variablelist
|
[variablelist
|
||||||
[[`template<class T> class is_nvp;`]
|
[[`template<class T> struct is_nvp;`]
|
||||||
[Provides static constant `value` equal to true if `T` is an NVP type,
|
[Provides static constant `value` equal to true if `T` is an NVP type,
|
||||||
otherwise false.]]]
|
otherwise false.]]]
|
||||||
|
|
||||||
@ -118,7 +109,7 @@ noexcept;`]
|
|||||||
|
|
||||||
[section Acknowledgments]
|
[section Acknowledgments]
|
||||||
|
|
||||||
Robert Ramey originally implemented nvp in the Serialization library. Glen
|
Robert Ramey originally implemented NVP in the Serialization library. Glen
|
||||||
Fernandes implemented this new (but compatible) version in the Core library.
|
Fernandes implemented this new (but compatible) version in the Core library.
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
@ -51,16 +51,6 @@ public:
|
|||||||
return *v_;
|
return *v_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class A>
|
|
||||||
void save(A& a, unsigned) const {
|
|
||||||
a.operator<<(*v_);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A>
|
|
||||||
void load(A& a, unsigned) {
|
|
||||||
a.operator>>(*v_);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A>
|
template<class A>
|
||||||
void serialize(A& a, unsigned) {
|
void serialize(A& a, unsigned) {
|
||||||
archive(a, detail::nvp_bool<A::is_saving::value>());
|
archive(a, detail::nvp_bool<A::is_saving::value>());
|
||||||
|
@ -56,24 +56,6 @@ void test()
|
|||||||
BOOST_TEST_EQ(&p.value(), &v);
|
BOOST_TEST_EQ(&p.value(), &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_save()
|
|
||||||
{
|
|
||||||
int v = 1;
|
|
||||||
boost::nvp<int> p("name", v);
|
|
||||||
saver s(0);
|
|
||||||
p.save(s, unsigned());
|
|
||||||
BOOST_TEST_EQ(s.get(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_load()
|
|
||||||
{
|
|
||||||
int v = 1;
|
|
||||||
boost::nvp<int> p("name", v);
|
|
||||||
loader l(5);
|
|
||||||
p.load(l, unsigned());
|
|
||||||
BOOST_TEST_EQ(p.value(), 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_serialize()
|
void test_serialize()
|
||||||
{
|
{
|
||||||
int v = 1;
|
int v = 1;
|
||||||
@ -117,8 +99,6 @@ void test_factory()
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test();
|
test();
|
||||||
test_save();
|
|
||||||
test_load();
|
|
||||||
test_serialize();
|
test_serialize();
|
||||||
test_deserialize();
|
test_deserialize();
|
||||||
test_trait();
|
test_trait();
|
||||||
|
Reference in New Issue
Block a user