/usr/include/soci/ref-counted-statement.h is in libsoci-dev 3.2.3-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | //
// Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef SOCI_REF_COUNTED_STATEMENT_H_INCLUDED
#define SOCI_REF_COUNTED_STATEMENT_H_INCLUDED
#include "statement.h"
#include "into-type.h"
#include "use-type.h"
// std
#include <sstream>
namespace soci
{
namespace details
{
// this class is a base for both "once" and "prepare" statements
class SOCI_DECL ref_counted_statement_base
{
public:
ref_counted_statement_base(session& s);
virtual ~ref_counted_statement_base() {}
virtual void final_action() = 0;
void inc_ref() { ++refCount_; }
void dec_ref()
{
if (--refCount_ == 0)
{
try
{
final_action();
}
catch (...)
{
delete this;
throw;
}
delete this;
}
}
template <typename T>
void accumulate(T const & t) { get_query_stream() << t; }
protected:
// this function allows to break the circular dependenc
// between session and this class
std::ostringstream & get_query_stream();
int refCount_;
session & session_;
private:
// noncopyable
ref_counted_statement_base(ref_counted_statement_base const&);
ref_counted_statement_base& operator=(ref_counted_statement_base const&);
};
// this class is supposed to be a vehicle for the "once" statements
// it executes the whole statement in its destructor
class ref_counted_statement : public ref_counted_statement_base
{
public:
ref_counted_statement(session & s)
: ref_counted_statement_base(s), st_(s) {}
virtual void final_action();
template <typename T>
void exchange(T &t) { st_.exchange(t); }
private:
statement st_;
};
} // namespace details
} // namespace soci
#endif
|