BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
getSetupList.C
Go to the documentation of this file.
1#include <fstream>
2#include <iostream>
3#include <map>
4#include <sstream>
5#include <stdlib.h>
6#include <string>
7
8// #define SQLITE_OPEN_URI 0x00000040
9// #define SQLITE_VERSION_NUMBER 3005000
10int getSetupList(const char* dbPath = NULL)
11{
12 /* TClass* cl = TClass::GetClass("FairCave");
13 std::cout<<"TClass:"<<cl<<std::endl;
14 FairModule* f_cl = (FairModule*) cl->New();
15 f_cl->SetName("Cave");
16 std::cout<<"FairCave:"<<f_cl->GetName()<<std::endl;
17 */
18 std::ostringstream stringStream;
19 if (dbPath != NULL)
20 stringStream << "sqlite://" << dbPath;
21 else
22 stringStream << "sqlite://" << getenv("DBL_FILE_PATH");
23 std::cout << stringStream.str().c_str() << std::endl;
24
25 TSQLiteServer db(stringStream.str().c_str()); // TSQLiteServer db("sqlite://test.db");
26 stringStream.str("");
27 stringStream << "select setup_tag,creation_date,author,desc from setup";
28 TSQLResult* resQ = db.Query(stringStream.str().c_str());
29 if (resQ == 0 || resQ->GetRowCount() == 0) {
30 std::cerr << "No setups in selected DB" << std::endl;
31 return -1;
32 }
33
34 std::cout << "Setup list:" << std::endl;
35 std::cout << "--------------------------------------------------------------------" << std::endl;
36 std::cout << "Tag Date Author Description" << std::endl;
37 TSQLRow* row;
38 while ((row = resQ->Next()) != 0) {
39 const char* tag = row->GetField(0);
40 std::cout << tag;
41 int i = 0;
42 for (i = strlen(tag); i < 22; i++)
43 std::cout << " ";
44 const char* date = row->GetField(1);
45 std::cout << date;
46 for (i = strlen(date); i < 15; i++)
47 std::cout << " ";
48 const char* author = row->GetField(2);
49 std::cout << author;
50 for (i = strlen(author); i < 20; i++)
51 std::cout << " ";
52 // if(row->IsValid(3)){
53 try {
54 const char* desc = row->GetField(3);
55 if (desc != 0)
56 std::cout << desc;
57 } catch (...) {}
58 std::cout << std::endl;
59 }
60
61 std::cout << "-----------------------------------------------------------------------------------" << std::endl;
62 db.Close();
63 return 0;
64}
int i
Definition P4_F32vec4.h:22
virtual Int_t GetRowCount() const
virtual TSQLRow * Next()=0
virtual const char * GetField(Int_t field)=0
TSQLResult * Query(const char *sql) final
void Close(Option_t *opt="") final
int getSetupList(const char *dbPath=NULL)