pupene  0.2.0
Public Member Functions | List of all members
pupene::Pupper< Derived > Class Template Reference

Base class for working with puppable types. More...

#include <pupper.h>

Public Member Functions

template<typename T >
PupPolicy begin_impl (T &value, const Meta &meta)
 
void end_impl (const Meta &meta)
 
template<typename T , typename = enable_if_puppable<T>>
void pup_impl (T &value, const Meta &meta)
 
 Pupper ()=default
 
virtual ~Pupper ()=default
 

Detailed Description

template<typename Derived>
class pupene::Pupper< Derived >

Base class for working with puppable types.

Puppers can conceptually be divided into serialization and utility-based.

Serialization puppers

pupene does not internally distinguish between serialization/deserialization; each target format is therefore implemented as a reader/writer pair:

Utility puppers

Custom and utility-related puppers are usually singular:

Creating puppers: Minimal exemplar

class MinimalPupper : public Pupper<MinimalPupper> {
public:
template<typename T>
PupPolicy begin(T& value, const Meta& meta) {
}
template<typename T>
void pup(T& value, const Meta& meta) {
// T is integer, floating point or std::string
}
void end(const Meta& meta) {}
};

When a pupper is better equipped to deal with an object as-is, without pupping its component parts, begin() can return PupPolicy::consume_object, e.g. by using a template specialization:

template <>
inline void MinimalPupper::begin(Color& value, const Meta& meta) {
set_background(value);
return PupPolicy::consume_object; // pup not invoked for members
}
Template Parameters
Derived

Definition at line 83 of file pupper.h.

Constructor & Destructor Documentation

◆ Pupper()

template<typename Derived>
pupene::Pupper< Derived >::Pupper ( )
explicitdefault

◆ ~Pupper()

template<typename Derived>
virtual pupene::Pupper< Derived >::~Pupper ( )
virtualdefault

Member Function Documentation

◆ begin_impl()

template<typename Derived>
template<typename T >
PupPolicy pupene::Pupper< Derived >::begin_impl ( T &  value,
const Meta meta 
)
inline

Definition at line 91 of file pupper.h.

◆ end_impl()

template<typename Derived>
void pupene::Pupper< Derived >::end_impl ( const Meta meta)
inline

Definition at line 100 of file pupper.h.

◆ pup_impl()

template<typename Derived>
template<typename T , typename = enable_if_puppable<T>>
void pupene::Pupper< Derived >::pup_impl ( T &  value,
const Meta meta 
)
inline

Definition at line 96 of file pupper.h.


The documentation for this class was generated from the following file: