Loading...
Searching...
No Matches
gpr::readcon_db_abi Namespace Reference

Classes

struct  Stamp

Functions

std::string describe (const Stamp &stamp)
std::string mismatch (const Stamp &header, const Stamp &library, bool library_accepts)
Stamp headerStamp () noexcept
Stamp libraryStamp ()
std::string loadedLibraryMismatch ()
 The mismatch message for the loaded library; empty when compatible.
void requireCompatibleLibrary ()

Function Documentation

◆ describe()

std::string gpr::readcon_db_abi::describe ( const Stamp & stamp)
inlinenodiscard

Definition at line 41 of file ReadconDbAbi.h.

42{
43 std::ostringstream out;
44 out << stamp.major << '.' << stamp.minor << " layout " << stamp.layout;
45 return out.str();
46}
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out

◆ headerStamp()

Stamp gpr::readcon_db_abi::headerStamp ( )
inlinenodiscardnoexcept

Definition at line 66 of file ReadconDbAbi.h.

67{
68 return {RKRDB_ABI_VERSION_MAJOR, RKRDB_ABI_VERSION_MINOR,
69 RKRDB_ABI_LAYOUT_REVISION};
70}

◆ libraryStamp()

Stamp gpr::readcon_db_abi::libraryStamp ( )
inlinenodiscard

Definition at line 72 of file ReadconDbAbi.h.

73{
74 return {rkrdb_abi_version_major(), rkrdb_abi_version_minor(),
75 rkrdb_abi_layout_revision()};
76}

◆ loadedLibraryMismatch()

std::string gpr::readcon_db_abi::loadedLibraryMismatch ( )
inlinenodiscard

The mismatch message for the loaded library; empty when compatible.

Definition at line 79 of file ReadconDbAbi.h.

80{
81 const Stamp header = headerStamp();
82 return mismatch(
83 header, libraryStamp(),
84 rkrdb_abi_compatible(header.major, header.minor, header.layout) != 0);
85}
std::string mismatch(const Stamp &header, const Stamp &library, bool library_accepts)
Stamp headerStamp() noexcept

◆ mismatch()

std::string gpr::readcon_db_abi::mismatch ( const Stamp & header,
const Stamp & library,
bool library_accepts )
inlinenodiscard

Empty when the library accepts the header's stamp and agrees with it on major and layout revision; otherwise a message naming both stamps. library_accepts is the result of rkrdb_abi_compatible on the header's stamp.

Definition at line 52 of file ReadconDbAbi.h.

55{
56 if (library_accepts && header.major == library.major &&
57 header.layout == library.layout)
58 return {};
59 return "readcon-db ABI mismatch: gpridge was built against "
60 "readcon-db.h " +
61 describe(header) + " and the loaded library reports " +
62 describe(library) +
63 (library_accepts ? "" : " and rejects the header's stamp");
64}
std::string describe(const Stamp &stamp)

◆ requireCompatibleLibrary()

void gpr::readcon_db_abi::requireCompatibleLibrary ( )
inline

Checks the loaded library once, before the first readcon-db call. Throws std::runtime_error on a mismatch; there is no fallback.

Definition at line 89 of file ReadconDbAbi.h.

90{
91 static std::once_flag checked;
92 static std::string failure;
93 std::call_once(checked, [] { failure = loadedLibraryMismatch(); });
94 if (!failure.empty()) throw std::runtime_error(failure);
95}
std::string loadedLibraryMismatch()
The mismatch message for the loaded library; empty when compatible.