libpqxx  3.1.1
pqxx::tablewriter Class Reference

Efficiently write data directly to a database table. More...

#include <tablewriter.hxx>

Inheritance diagram for pqxx::tablewriter:
pqxx::tablestream pqxx::internal::transactionfocus pqxx::internal::namedclass

Public Types

typedef unsigned size_type

Public Member Functions

 tablewriter (transaction_base &, const std::string &WName, const std::string &Null=std::string())
template<typename ITER >
 tablewriter (transaction_base &, const std::string &WName, ITER begincolumns, ITER endcolumns)
 Write only the given sequence of columns.
template<typename ITER >
 tablewriter (transaction_base &T, const std::string &WName, ITER begincolumns, ITER endcolumns, const std::string &Null)
 Write only the given sequence of columns, with customized "null" string.
 ~tablewriter () throw ()
template<typename IT >
void insert (IT Begin, IT End)
template<typename TUPLE >
void insert (const TUPLE &)
template<typename IT >
void push_back (IT Begin, IT End)
template<typename TUPLE >
void push_back (const TUPLE &)
void reserve (size_type)
template<typename TUPLE >
tablewriteroperator<< (const TUPLE &)
tablewriteroperator<< (tablereader &)
 Copy table from one database to another.
template<typename IT >
std::string generate (IT Begin, IT End) const
 Translate tuple of data to a string in DBMS-specific format.
template<typename TUPLE >
std::string generate (const TUPLE &) const
virtual void complete ()
 Finish stream action, check for errors, and detach from transaction.
void write_raw_line (const std::string &)
 Write line of raw data (e.g. obtained from tablereader.get_raw_line).
- Public Member Functions inherited from pqxx::tablestream
 tablestream (transaction_base &Trans, const std::string &Null=std::string())
virtual ~tablestream ()=0 throw ()
- Public Member Functions inherited from pqxx::internal::transactionfocus
 transactionfocus (transaction_base &t)
- Public Member Functions inherited from pqxx::internal::namedclass
 namedclass (const std::string &Classname, const std::string &Name="")
const std::string & name () const throw ()
const std::string & classname () const throw ()
std::string description () const

Additional Inherited Members

- Protected Member Functions inherited from pqxx::tablestream
const std::string & NullStr () const
bool is_finished () const throw ()
void base_close ()
- Static Protected Member Functions inherited from pqxx::tablestream
template<typename ITER >
static std::string columnlist (ITER colbegin, ITER colend)
 Construct a comma-separated column list from given sequence.
- Protected Attributes inherited from pqxx::internal::transactionfocus
transaction_basem_Trans

Detailed Description

Efficiently write data directly to a database table.

A tablewriter provides a Spartan but efficient way of writing data tuples into a table. It provides a plethora of STL-like insertion methods: it has insert() methods, push_back(), as well as an overloaded insertion operator (<<), and it supports inserters created by std::back_inserter(). All of these are templatized so you can use any container type or iterator range to feed tuples into the table.

Note that in each case, a container or range represents the fields of a single tuple–not a collection of tuples.

Member Typedef Documentation

typedef unsigned pqxx::tablewriter::size_type

Constructor & Destructor Documentation

pqxx::tablewriter::tablewriter ( transaction_base T,
const std::string &  WName,
const std::string &  Null = std::string() 
)
template<typename ITER >
pqxx::tablewriter::tablewriter ( transaction_base T,
const std::string &  WName,
ITER  begincolumns,
ITER  endcolumns 
)

Write only the given sequence of columns.

Since
PostgreSQL backend 7.3.

This constructor takes a sequence of names of columns to write to. Only those columns will be written, and they will be taken from your input data in that order.

References pqxx::tablestream::columnlist().

template<typename ITER >
pqxx::tablewriter::tablewriter ( transaction_base T,
const std::string &  WName,
ITER  begincolumns,
ITER  endcolumns,
const std::string &  Null 
)

Write only the given sequence of columns, with customized "null" string.

Since
PostgreSQL backend 7.3.

This constructor takes a sequence of names of columns to write to. Only those columns will be written, and they will be taken from your input data in that order.

Parameters
TThe transaction that this tablewriter will operate on.
WNameA name for this table writer, to help with debugging.
begincolumnsBeginning of a sequence of names of columns to write.
endcolumnsEnd of a sequence of names of columns to write.
NullThe string that is used in your input data to denote null.

References pqxx::tablestream::columnlist().

pqxx::tablewriter::~tablewriter ( ) throw ()

Member Function Documentation

void pqxx::tablewriter::complete ( )
virtual

Finish stream action, check for errors, and detach from transaction.

It is recommended that you call this function before the tablestream's destructor is run. This function will check any final errors which may not become apparent until the transaction is committed otherwise.

As an added benefit, this will free up the transaction while the tablestream object itself still exists.

Implements pqxx::tablestream.

template<typename IT >
std::string pqxx::tablewriter::generate ( IT  Begin,
IT  End 
) const

Translate tuple of data to a string in DBMS-specific format.

Warning
This is definitely not portable between databases.

References pqxx::tablestream::NullStr(), and pqxx::separated_list().

Referenced by generate(), and insert().

template<typename TUPLE >
std::string pqxx::tablewriter::generate ( const TUPLE &  T) const

References generate().

template<typename IT >
void pqxx::tablewriter::insert ( IT  Begin,
IT  End 
)

References generate(), and write_raw_line().

Referenced by insert(), operator<<(), and push_back().

template<typename TUPLE >
void pqxx::tablewriter::insert ( const TUPLE &  T)

References insert().

template<typename TUPLE >
tablewriter & pqxx::tablewriter::operator<< ( const TUPLE &  T)

References insert().

pqxx::tablewriter & pqxx::tablewriter::operator<< ( pqxx::tablereader R)

Copy table from one database to another.

References pqxx::tablereader::get_raw_line().

template<typename IT >
void pqxx::tablewriter::push_back ( IT  Begin,
IT  End 
)

References insert().

template<typename TUPLE >
void pqxx::tablewriter::push_back ( const TUPLE &  T)

References insert().

void pqxx::tablewriter::reserve ( size_type  )
void pqxx::tablewriter::write_raw_line ( const std::string &  Line)

Write line of raw data (e.g. obtained from tablereader.get_raw_line).

Referenced by insert().


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