libpqxx  7.5.0
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-2021, 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 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/internal/compiler-internal-pre.hxx"
18 
19 #include "pqxx/connection.hxx"
20 #include "pqxx/result.hxx"
21 #include "pqxx/transaction.hxx"
22 
23 namespace pqxx
24 {
25 using namespace std::literals;
26 
28 
54 class PQXX_LIBEXPORT nontransaction final : public transaction_base
55 {
56 public:
58 
63  nontransaction(connection &c, std::string_view tname = ""sv) :
64  transaction_base{c, tname, std::shared_ptr<std::string>{}}
65  {
66  register_transaction();
67  }
68 
69  virtual ~nontransaction() override { close(); }
70 
71 private:
72  virtual void do_commit() override {}
73 };
74 } // namespace pqxx
75 
76 #include "pqxx/internal/compiler-internal-post.hxx"
77 #endif
Simple "transaction" class offering no transactional integrity.
Definition: nontransaction.hxx:54
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
virtual ~nontransaction() override
Definition: nontransaction.hxx:69
nontransaction(connection &c, std::string_view tname=""sv)
Constructor.
Definition: nontransaction.hxx:63
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:74
Connection to a database.
Definition: connection.hxx:183