Namespaces | Macros | Functions
uctrstrm.h File Reference

Serialization templates for standard containers. Because containers are templates, a single operator>> is impossible. Making virtual read/write is also impossible because not all containers contain serializable elements. Therefore, use the macros in this file. More...

#include "mistream.h"
#include "sostream.h"
#include "uiosfunc.h"
#include "typeinfo.h"

Namespaces

 ustl
 The ustl namespace contains all ustl classes and algorithms.
 

Macros

#define STD_TEMPLATE_CTR_STREAMABLE(type, template_decl)
 Declares container template type streamable. More...
 
#define STD_TEMPLATE_NR_CTR_STREAMABLE(type, template_decl)
 Declares non-resizable container template type streamable. More...
 

Functions

template<typename Container >
istream & ustl::nr_container_read (istream &is, Container &v)
 Reads fixed size container v from stream is.
 
template<typename Container >
ostream & ustl::nr_container_write (ostream &os, const Container &v)
 Writes fixed size container v into stream os.
 
template<typename Container >
size_t ustl::nr_container_stream_size (const Container &v)
 Computes the stream size of a fixed size standard container.
 
template<typename Container >
istream & ustl::container_read (istream &is, Container &v)
 Reads container v from stream is.
 
template<typename Container >
ostream & ustl::container_write (ostream &os, const Container &v)
 Writes the vector to stream os.
 
template<typename Container >
size_t ustl::container_stream_size (const Container &v)
 Computes the stream size of a standard container.
 
template<typename T >
ostringstream & ustl::container_element_text_write (ostringstream &os, const T &v)
 Writes element v into stream os as text. Specialize to custom print elements.
 
template<typename Container >
ostringstream & ustl::container_text_write (ostringstream &os, const Container &v)
 Writes container v into stream os as text.
 

Detailed Description

Serialization templates for standard containers. Because containers are templates, a single operator>> is impossible. Making virtual read/write is also impossible because not all containers contain serializable elements. Therefore, use the macros in this file.

Macro Definition Documentation

#define STD_TEMPLATE_CTR_STREAMABLE (   type,
  template_decl 
)
Value:
template_decl \
inline istream& operator>> (istream& is, type& v) \
{ return container_read (is, v); } \
template_decl \
inline ostream& operator<< (ostream& os, const type& v) \
{ return container_write (os, v); } \
template_decl \
inline ostringstream& operator<< (ostringstream& os, const type& v) \
{ return container_text_write (os, v); } \
template_decl \
struct object_stream_size<type > { \
inline size_t operator()(const type& v) const \
{ return container_stream_size (v); } \
};
size_t container_stream_size(const Container &v)
Computes the stream size of a standard container.
Definition: uctrstrm.h:143
ostream & container_write(ostream &os, const Container &v)
Writes the vector to stream os.
Definition: uctrstrm.h:128
ostringstream & container_text_write(ostringstream &os, const Container &v)
Writes container v into stream os as text.
Definition: uctrstrm.h:162
istream & container_read(istream &is, Container &v)
Reads container v from stream is.
Definition: uctrstrm.h:109

Declares container template type streamable.

Use TEMPLATE_TYPE and TEMPLATE_DECL macros to pass in templated type with commas and the template declaration.

#define STD_TEMPLATE_NR_CTR_STREAMABLE (   type,
  template_decl 
)
Value:
template_decl \
inline istream& operator>> (istream& is, type& v) \
{ return nr_container_read (is, v); } \
template_decl \
inline ostream& operator<< (ostream& os, const type& v) \
{ return nr_container_write (os, v); } \
template_decl \
inline ostringstream& operator<< (ostringstream& os, const type& v) \
{ return container_text_write (os, v); } \
template_decl \
struct object_stream_size<type > { \
inline size_t operator()(const type& v) const \
{ return nr_container_stream_size (v); } \
};
istream & nr_container_read(istream &is, Container &v)
Reads fixed size container v from stream is.
Definition: uctrstrm.h:69
ostream & nr_container_write(ostream &os, const Container &v)
Writes fixed size container v into stream os.
Definition: uctrstrm.h:78
size_t nr_container_stream_size(const Container &v)
Computes the stream size of a fixed size standard container.
Definition: uctrstrm.h:87
ostringstream & container_text_write(ostringstream &os, const Container &v)
Writes container v into stream os as text.
Definition: uctrstrm.h:162

Declares non-resizable container template type streamable.


Generated on Mon Sep 28 2015 17:58:50 for uSTL by Doxygen 1.8.10