/usr/include/odb/vector-traits.txx is in libodb-dev 2.4.0-1.
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 92 93 94 95 96 97 98 99 100 101 | // file : odb/vector-traits.txx
// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
namespace odb
{
template <typename V, typename A LIBODB_VECTOR_ARG_DECL>
bool access::container_traits<vector<V, A LIBODB_VECTOR_ARG_USE> >::
changed (const container_type& c)
{
// Because modifications can cancel each other (e.g., push and pop),
// it is tricky to keep track of whether there are any changes in
// the container. Instead, we are just going to examine each element
// just like update().
//
// We should either be tracking or summarily changed.
//
if (c._tracking ())
{
const vector_impl& impl (c._impl ());
for (std::size_t i (0), n (impl.size ()); i < n; ++i)
{
if (impl.state (i) != vector_impl::state_unchanged)
return true;
}
}
else
return true;
return false;
}
template <typename V, typename A LIBODB_VECTOR_ARG_DECL>
void access::container_traits<vector<V, A LIBODB_VECTOR_ARG_USE> >::
update (const container_type& c, const functions& f)
{
bool u (false); // Updated flag.
if (c._tracking ())
{
const vector_impl& impl (c._impl ());
for (std::size_t i (0), n (impl.size ()); i < n; ++i)
{
vector_impl::element_state_type s (impl.state (i));
switch (s)
{
case vector_impl::state_unchanged:
{
break;
}
case vector_impl::state_inserted:
{
f.insert (i, c[static_cast<index_type> (i)]);
u = u || true;
break;
}
case vector_impl::state_updated:
{
f.update (i, c[static_cast<index_type> (i)]);
u = u || true;
break;
}
case vector_impl::state_erased:
{
f.delete_ (i); // Delete from i onwards.
u = u || true;
break;
}
}
// We delete all trailing elements in one go.
//
if (s == vector_impl::state_erased)
break;
}
}
else
{
// Fall back to delete all/insert all.
//
f.delete_ (0);
for (index_type i (0), n (c.size ()); i < n; ++i)
f.insert (i, c[i]);
u = true;
}
// Arm the rollback callback and (re)start change tracking.
//
if (u)
{
c._arm (transaction::current ());
c._start ();
}
}
}
|