tablereader.hxx
#ifndef PQXX_H_TABLEREADER
#define PQXX_H_TABLEREADER
#include "pqxx/compiler-public.hxx"
#include "pqxx/compiler-internal-pre.hxx"
#include "pqxx/result.hxx"
#include "pqxx/tablestream.hxx"
namespace pqxx
{
class PQXX_LIBEXPORT tablereader : public tablestream
{
public:
PQXX_DEPRECATED tablereader(
transaction_base &,
const std::string &Name,
const std::string &Null=std::string{});
template<typename ITER>
PQXX_DEPRECATED tablereader(
transaction_base &,
const std::string &Name,
ITER begincolumns,
ITER endcolumns);
template<typename ITER>
PQXX_DEPRECATED tablereader(
transaction_base &,
const std::string &Name,
ITER begincolumns,
ITER endcolumns,
const std::string &Null);
~tablereader() noexcept;
template<typename TUPLE> tablereader &operator>>(TUPLE &);
operator bool() const noexcept { return not m_done; }
bool operator!() const noexcept { return m_done; }
bool get_raw_line(std::string &Line);
template<typename TUPLE>
void tokenize(std::string, TUPLE &) const;
virtual void complete() override;
private:
void set_up(
transaction_base &T,
const std::string &RName,
const std::string &Columns=std::string{});
PQXX_PRIVATE void reader_close();
std::string extract_field(
const std::string &,
std::string::size_type &) const;
bool m_done;
};
template<typename ITER> inline
tablereader::tablereader(
transaction_base &T,
const std::string &Name,
ITER begincolumns,
ITER endcolumns) :
namedclass{Name, "tablereader"},
tablestream{T, std::string{}},
m_done{true}
{
set_up(T, Name, columnlist(begincolumns, endcolumns));
}
template<typename ITER> inline
tablereader::tablereader(
transaction_base &T,
const std::string &Name,
ITER begincolumns,
ITER endcolumns,
const std::string &Null) :
namedclass{Name, "tablereader"},
tablestream{T, Null},
m_done{true}
{
set_up(T, Name, columnlist(begincolumns, endcolumns));
}
template<typename TUPLE>
inline void tablereader::tokenize(std::string Line, TUPLE &T) const
{
std::back_insert_iterator<TUPLE> ins = std::back_inserter(T);
std::string::size_type here = 0;
while (here < Line.size()) *ins++ = extract_field(Line, here);
}
template<typename TUPLE>
inline tablereader &pqxx::tablereader::operator>>(TUPLE &T)
{
std::string Line;
if (get_raw_line(Line)) tokenize(Line, T);
return *this;
}
} // namespace pqxx
#include "pqxx/compiler-internal-post.hxx"
#endif
pqxx::tablereader::get_raw_line
bool get_raw_line(std::string &Line)
Definition: tablereader.cxx:55
pqxx::tablereader::tokenize
void tokenize(std::string, TUPLE &) const
Definition: tablereader.hxx:100
pqxx::internal
Private namespace for libpqxx's internal use; do not access.
Definition: connection_base.hxx:43
pqxx::tablereader::tablereader
tablereader(transaction_base &, const std::string &Name, const std::string &Null=std::string{})
Definition: tablereader.cxx:21
pqxx::tablestream
Base class for obsolete tablereader/tablewriter classes.
Definition: tablestream.hxx:26
pqxx::tablereader::complete
virtual void complete() override
Definition: tablereader.cxx:70
pqxx::tablereader::operator>>
tablereader & operator>>(TUPLE &)
Definition: tablereader.hxx:109
pqxx::internal::namedclass
Helper base class: object descriptions for error messages and such.
Definition: util.hxx:233
pqxx::tablereader::~tablereader
~tablereader() noexcept
Definition: tablereader.cxx:42
pqxx::tablereader::operator!
bool operator!() const noexcept
Definition: tablereader.hxx:52
pqxx::internal::digit_to_number
constexpr int digit_to_number(char c) noexcept
Compute numeric value of given textual digit (assuming that it is a digit)
Definition: strconv.hxx:323
pqxx::tablereader
Definition: tablereader.hxx:29
pqxx::transaction_base
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:136
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25