// -*- C++ -*-
//
// This file was generated by ODB, object-relational mapping (ORM)
// compiler for C++.
//

#ifndef BPKG_PACKAGE_COMMON_ODB_HXX
#define BPKG_PACKAGE_COMMON_ODB_HXX

// Begin prologue.
//
#include <bpkg/wrapper-traits.hxx>
#include <bpkg/value-traits.hxx>
//
// End prologue.

#include <odb/version.hxx>

#if ODB_VERSION != 20500UL
#error ODB runtime version mismatch
#endif

#include <odb/pre.hxx>

#include <bpkg/package-common.hxx>

#include <memory>
#include <cstddef>
#include <utility>

#include <odb/core.hxx>
#include <odb/traits.hxx>
#include <odb/callback.hxx>
#include <odb/wrapper-traits.hxx>
#include <odb/pointer-traits.hxx>
#include <odb/container-traits.hxx>
#include <odb/no-op-cache-traits.hxx>

#include <odb/details/unused.hxx>

namespace odb
{
}

#include <odb/details/buffer.hxx>

#include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx>
#include <odb/sqlite/binding.hxx>
#include <odb/sqlite/sqlite-types.hxx>

namespace odb
{
  // _version
  //
  template <>
  class access::composite_value_traits< ::bpkg::_version, id_sqlite >
  {
    public:
    typedef ::bpkg::_version value_type;

    struct image_type
    {
      // epoch
      //
      long long epoch_value;
      bool epoch_null;

      // canonical_upstream
      //
      details::buffer canonical_upstream_value;
      std::size_t canonical_upstream_size;
      bool canonical_upstream_null;

      // canonical_release
      //
      details::buffer canonical_release_value;
      std::size_t canonical_release_size;
      bool canonical_release_null;

      // revision
      //
      long long revision_value;
      bool revision_null;

      // iteration
      //
      long long iteration_value;
      bool iteration_null;

      // upstream
      //
      details::buffer upstream_value;
      std::size_t upstream_size;
      bool upstream_null;

      // release
      //
      details::buffer release_value;
      std::size_t release_size;
      bool release_null;
    };

    static bool
    grow (image_type&,
          bool*);

    static void
    bind (sqlite::bind*,
          image_type&,
          sqlite::statement_kind);

    static bool
    init (image_type&,
          const value_type&,
          sqlite::statement_kind);

    static void
    init (value_type&,
          const image_type&,
          database*);

    static bool
    get_null (const image_type&);

    static void
    set_null (image_type&,
              sqlite::statement_kind);

    static const std::size_t column_count = 7UL;
  };

  // canonical_version
  //
  template <>
  class access::composite_value_traits< ::bpkg::canonical_version, id_sqlite >
  {
    public:
    typedef ::bpkg::canonical_version value_type;

    struct image_type
    {
      // epoch
      //
      long long epoch_value;
      bool epoch_null;

      // canonical_upstream
      //
      details::buffer canonical_upstream_value;
      std::size_t canonical_upstream_size;
      bool canonical_upstream_null;

      // canonical_release
      //
      details::buffer canonical_release_value;
      std::size_t canonical_release_size;
      bool canonical_release_null;

      // revision
      //
      long long revision_value;
      bool revision_null;

      // iteration
      //
      long long iteration_value;
      bool iteration_null;
    };

    static bool
    grow (image_type&,
          bool*);

    static void
    bind (sqlite::bind*,
          image_type&,
          sqlite::statement_kind);

    static bool
    init (image_type&,
          const value_type&,
          sqlite::statement_kind);

    static void
    init (value_type&,
          const image_type&,
          database*);

    static bool
    get_null (const image_type&);

    static void
    set_null (image_type&,
              sqlite::statement_kind);

    static const std::size_t column_count = 5UL;
  };

  // original_version
  //
  template <>
  class access::composite_value_traits< ::bpkg::original_version, id_sqlite >
  {
    public:
    typedef ::bpkg::original_version value_type;

    struct image_type
    {
      // upstream_
      //
      details::buffer upstream_value;
      std::size_t upstream_size;
      bool upstream_null;

      // release_
      //
      details::buffer release_value;
      std::size_t release_size;
      bool release_null;
    };

    static bool
    grow (image_type&,
          bool*);

    static void
    bind (sqlite::bind*,
          image_type&,
          sqlite::statement_kind);

    static bool
    init (image_type&,
          const value_type&,
          sqlite::statement_kind);

    static void
    init (value_type&,
          const image_type&,
          database*);

    static bool
    get_null (const image_type&);

    static void
    set_null (image_type&,
              sqlite::statement_kind);

    static const std::size_t column_count = 2UL;
  };

  // package_id
  //
  template <>
  class access::composite_value_traits< ::bpkg::package_id, id_sqlite >
  {
    public:
    typedef ::bpkg::package_id value_type;

    struct image_type
    {
      // name
      //
      details::buffer name_value;
      std::size_t name_size;
      bool name_null;

      // version
      //
      composite_value_traits< ::bpkg::canonical_version, id_sqlite >::image_type version_value;
    };

    static bool
    grow (image_type&,
          bool*);

    static void
    bind (sqlite::bind*,
          image_type&,
          sqlite::statement_kind);

    static bool
    init (image_type&,
          const value_type&,
          sqlite::statement_kind);

    static void
    init (value_type&,
          const image_type&,
          database*);

    static bool
    get_null (const image_type&);

    static void
    set_null (image_type&,
              sqlite::statement_kind);

    static const std::size_t column_count = 6UL;
  };
}

#include <bpkg/package-common-odb.ixx>

#include <odb/post.hxx>

#endif // BPKG_PACKAGE_COMMON_ODB_HXX
