libpqxx  v4.0-1
C++ library for PostgreSQL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pqxx::items< T, CONT > Class Template Reference

Container of items with easy contents initialization and string rendering. More...

#include <util.hxx>

Inheritance diagram for pqxx::items< T, CONT >:
Collaboration diagram for pqxx::items< T, CONT >:

Public Member Functions

 items ()
 Create empty items list. More...
 
 items (const T &t)
 Create items list with one element. More...
 
 items (const T &t1, const T &t2)
 
 items (const T &t1, const T &t2, const T &t3)
 
 items (const T &t1, const T &t2, const T &t3, const T &t4)
 
 items (const T &t1, const T &t2, const T &t3, const T &t4, const T &t5)
 
 items (const CONT &c)
 Copy container. More...
 
itemsoperator() (const T &t)
 Add element to items list. More...
 

Detailed Description

template<typename T = PGSTD::string, typename CONT = PGSTD::vector<T>>
class pqxx::items< T, CONT >

Container of items with easy contents initialization and string rendering.

Designed as a wrapper around an arbitrary container type, this class lets you easily create a container object and provide its contents in the same line. Regular addition methods such as push_back() will also still work, but you can now write things like

items<int> numbers; numbers(1)(2)(3)(4);

Up to five elements may be specified directly as constructor arguments, e.g.

items<int> numbers(1,2,3,4);

One thing that cannot be done with this simple class is create const objects with nontrivial contents. This is because the function invocation operator (which is being used to add items) modifies the container rather than creating a new one. This was done to keep performance within reasonable bounds.

Warning
This class may see substantial change in its interface before it stabilizes. Do not count on it remaining the way it is.

Constructor & Destructor Documentation

template<typename T = PGSTD::string, typename CONT = PGSTD::vector<T>>
pqxx::items< T, CONT >::items ( )
inline

Create empty items list.

template<typename T = PGSTD::string, typename CONT = PGSTD::vector<T>>
pqxx::items< T, CONT >::items ( const T &  t)
inlineexplicit

Create items list with one element.

template<typename T = PGSTD::string, typename CONT = PGSTD::vector<T>>
pqxx::items< T, CONT >::items ( const T &  t1,
const T &  t2 
)
inline
template<typename T = PGSTD::string, typename CONT = PGSTD::vector<T>>
pqxx::items< T, CONT >::items ( const T &  t1,
const T &  t2,
const T &  t3 
)
inline
template<typename T = PGSTD::string, typename CONT = PGSTD::vector<T>>
pqxx::items< T, CONT >::items ( const T &  t1,
const T &  t2,
const T &  t3,
const T &  t4 
)
inline
template<typename T = PGSTD::string, typename CONT = PGSTD::vector<T>>
pqxx::items< T, CONT >::items ( const T &  t1,
const T &  t2,
const T &  t3,
const T &  t4,
const T &  t5 
)
inline
template<typename T = PGSTD::string, typename CONT = PGSTD::vector<T>>
pqxx::items< T, CONT >::items ( const CONT c)
inline

Copy container.

Member Function Documentation

template<typename T = PGSTD::string, typename CONT = PGSTD::vector<T>>
items& pqxx::items< T, CONT >::operator() ( const T &  t)
inline

Add element to items list.


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