LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
SQLErrMsg.h
Go to the documentation of this file.
1 #ifndef art_Framework_IO_Root_RootDB_SQLErrMsg_h
2 #define art_Framework_IO_Root_RootDB_SQLErrMsg_h
3 
4 // Little class to handle the management of an SQLite3 error message.
5 
6 // Pass an instance of this class to an SQLite3 function expecting a
7 // char** into which to place an error message.
8 
9 #include <string>
10 
11 namespace art {
12  class SQLErrMsg;
13 }
14 
16 public:
17  SQLErrMsg() : errMsg_(nullptr) {}
18  ~SQLErrMsg();
19 
20  // Return the stored message.
21  std::string
22  msg() const
23  {
24  return errMsg_;
25  }
26 
27  // Throw a suitable message if an error occurred.
28  void throwIfError();
29 
30  // Reset and release memory. This will be done automatically in the
31  // destructor anyway.
32  void reset();
33 
34  // Enable an object of this class to be passed to functions expecting
35  // char **.
36  operator char**()
37  {
38  reset();
39  return &errMsg_;
40  }
41 
42 private:
43  char* errMsg_;
44 };
45 
46 #endif /* art_Framework_IO_Root_RootDB_SQLErrMsg_h */
47 
48 // Local Variables:
49 // mode: c++
50 // End:
void reset()
Definition: SQLErrMsg.cc:21
char * errMsg_
Definition: SQLErrMsg.h:43
std::string msg() const
Definition: SQLErrMsg.h:22
HLT enums.
void throwIfError()
Definition: SQLErrMsg.cc:10