libpqxx  7.7.4
nontransaction.hxx
1 /* Definition of the pqxx::nontransaction class.
2  *
3  * pqxx::nontransaction provides nontransactional database access
4  *
5  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/nontransaction instead.
6  *
7  * Copyright (c) 2000-2022, Jeroen T. Vermeulen.
8  *
9  * See COPYING for copyright license. If you did not receive a file called
10  * COPYING with this source code, please notify the distributor of this
11  * mistake, or contact the author.
12  */
13 #ifndef PQXX_H_NONTRANSACTION
14 #define PQXX_H_NONTRANSACTION
15 
16 #if !defined(PQXX_HEADER_PRE)
17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
18 #endif
19 
20 #include "pqxx/connection.hxx"
21 #include "pqxx/result.hxx"
22 #include "pqxx/transaction.hxx"
23 
24 namespace pqxx
25 {
26 using namespace std::literals;
27 
29 
55 class PQXX_LIBEXPORT nontransaction final : public transaction_base
56 {
57 public:
59 
64  nontransaction(connection &c, std::string_view tname = ""sv) :
65  transaction_base{c, tname, std::shared_ptr<std::string>{}}
66  {
67  register_transaction();
68  }
69 
70  virtual ~nontransaction() override { close(); }
71 
72 private:
73  virtual void do_commit() override {}
74 };
75 } // namespace pqxx
76 #endif
Simple "transaction" class offering no transactional integrity.
Definition: nontransaction.hxx:55
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:26
Connection to a database.
Definition: connection.hxx:184
nontransaction(connection &c, std::string_view tname=""sv)
Constructor.
Definition: nontransaction.hxx:64
virtual ~nontransaction() override
Definition: nontransaction.hxx:70
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:76