LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TKeyVFSOpenPolicy.cc
Go to the documentation of this file.
4 #include "cetlib/sqlite/helpers.h"
5 
6 art::TKeyVFSOpenPolicy::TKeyVFSOpenPolicy(TFile* const tfile, int const flags)
7  : tfile_{tfile}, flags_{flags | SQLITE_OPEN_URI}
8 {}
9 
10 sqlite3*
11 art::TKeyVFSOpenPolicy::open(std::string const& key)
12 {
13  if (!key.size()) {
15  << "Failed to open TKEYVFS DB due to empty key spec.\n";
16  }
17 
18  auto const uriKey = cet::sqlite::assembleNoLockURI(key);
19  sqlite3* db{nullptr};
20  int const rc{tkeyvfs_open_v2(uriKey.c_str(), &db, flags_, tfile_)};
21  if (rc != SQLITE_OK) {
23  << "Failed to open requested DB, \"" << key << "\" of type, \""
24  << "tkeyvfs"
25  << "\" -- " << sqlite3_errmsg(db) << '\n';
26  }
27  return db;
28 }
sqlite3 * open(std::string const &key)
int tkeyvfs_open_v2(const char *filename, sqlite3 **ppDb, int flags, TFile *rootFile )
Definition: tkeyvfs.cc:1837
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
TKeyVFSOpenPolicy(TFile *const tfile, int const flags=SQLITE_OPEN_READONLY)