11#define NULLINT -INT_MAX
12#define NULLFLOAT -FLT_MAX
13#define NULLDOUBLE -DBL_MAX
16#define NULLLONG -__LONG_LONG_MAX__
18#define NULLLONG -LONG_LONG_MAX
20#define atoi64(x) atoll(x)
35 for (i=0;i<n_columns; i++)
68 for (i=0;i<n_columns; i++)
113 std::vector<std::string> names;
114 unsigned int ncolumn = 0;
117 ncolumn = std::count_if(names.begin(),names.end(), [](
const auto & s){return s !=
"Id";} );
120 if (ncolumn == names.size())
125 for (
unsigned int i = 0; i < dcolumn->
column.size(); i++) {
126 if (dcolumn->
column[i] == pID) {
185 vector<long int> tmp;
275 vector<long int> tmp;
369 tmpColumn->
column.push_back(-1);
415 tmpColumn->
column.push_back(
"NULL");
461 tmpColumn->
column.push_back({-1});
484 tmp.push_back(
"NULL");
485 tmpColumn->
column.push_back({
"NULL"});
809 CondDBColumnArrayFloat *tmpColumn =
static_cast<CondDBColumnArrayFloat*
>(
m_conddbtable[n_column]);
821 CondDBColumnArrayDouble *tmpColumn =
static_cast<CondDBColumnArrayDouble*
>(
m_conddbtable[n_column]);
935 __setCell(n_column, n_row, atol(ndata.c_str()),
kInt, tmpColumn);
950 __setCell(n_column, n_row, atoi(ndata.c_str()),
kBool, tmpColumn);
978 __setCell(n_column,n_row, strtod(ndata.c_str(), (
char **)NULL),
kFloat, tmpColumn);
992 __setCell(n_column,n_row,strtod(ndata.c_str(), (
char **)NULL),
kDouble, tmpColumn);
1033 CondDBColumnArrayFloat *tmpColumn =
static_cast<CondDBColumnArrayFloat*
>(
m_conddbtable[n_column]);
1065 vector<long int> tmp;
1066 for (
unsigned i=0; i<ndata.size(); i++)
1068 if (ndata[i]==
"NULL")
1072 tmp.push_back(null);
1075 tmp.push_back(atol(ndata[i].c_str()));
1083 vector<short int> tmp;
1084 for (
unsigned i=0; i<ndata.size(); i++)
1086 if (ndata[i]==
"NULL")
1091 tmp.push_back(atoi(ndata[i].c_str()));
1100 for (
unsigned i=0; i<ndata.size(); i++)
1102 if (ndata[i]==
"NULL")
1106 tmp.push_back(null);
1110 tmp.push_back(
atoi64(ndata[i].c_str()));
1119 for (
unsigned i=0; i<ndata.size(); i++)
1121 if (ndata[i]==
"NULL")
1125 tmp.push_back(null);
1128 tmp.push_back(atof(ndata[i].c_str()));
1137 for (
unsigned i=0; i<ndata.size(); i++)
1139 if (ndata[i]==
"NULL")
1143 tmp.push_back(null);
1146 tmp.push_back(strtod(ndata[i].c_str(), (
char**)NULL));
1192 CondDBColumnFloat *tmpColumn =
static_cast<CondDBColumnFloat*
>(
m_conddbtable[n_column]);
1223 vector<long int> tmp;
1224 for (
unsigned i=0; i<
data.size(); i++)
1226 if (
data[i]==
"NULL")
1230 tmp.push_back(null);
1233 tmp.push_back(atol(
data[i].c_str()));
1240 vector<short int> tmp;
1241 for (
unsigned i=0; i<
data.size(); i++)
1243 if (
data[i]==
"NULL")
1245 short int null = -1;
1246 tmp.push_back(null);
1249 tmp.push_back(atoi(
data[i].c_str()));
1257 for (
unsigned i=0; i<
data.size(); i++)
1259 if (
data[i]==
"NULL")
1263 tmp.push_back(null);
1274 for (
unsigned i=0; i<
data.size(); i++)
1276 if (
data[i]==
"NULL")
1280 tmp.push_back(null);
1283 tmp.push_back(atof(
data[i].c_str()));
1291 for (
unsigned i=0; i<
data.size(); i++)
1293 if (
data[i]==
"NULL")
1297 tmp.push_back(null);
1300 tmp.push_back(strtod(
data[i].c_str(), (
char**)NULL));
1308 vector<long int> tmp;
1309 for (
unsigned i=0; i<
data.size(); i++)
1311 if (
data[i]==
"NULL")
1315 tmp.push_back(null);
1318 tmp.push_back(atol(
data[i].c_str()));
1325 vector<short int> tmp;
1326 for (
unsigned i=0; i<
data.size(); i++)
1328 if (
data[i]==
"NULL")
1331 short int null = -1;
1332 tmp.push_back(null);
1335 tmp.push_back(atoi(
data[i].c_str()));
1343 for (
unsigned i=0; i<
data.size(); i++)
1345 if (
data[i]==
"NULL")
1349 tmp.push_back(null);
1360 for (
unsigned i=0; i<
data.size(); i++)
1362 if (
data[i]==
"NULL")
1366 tmp.push_back(null);
1369 tmp.push_back(atof(
data[i].c_str()));
1377 for (
unsigned i=0; i<
data.size(); i++)
1379 if (
data[i]==
"NULL")
1383 tmp.push_back(null);
1386 tmp.push_back(strtod(
data[i].c_str(), (
char**)NULL));
1404 CondDBColumnDouble *tmpColumn =
static_cast<CondDBColumnDouble*
>(
m_conddbtable[n_column]);
1428 CondDBColumnArrayFloat *tmpColumn =
static_cast<CondDBColumnArrayFloat*
>(
m_conddbtable[n_column]);
1464 vector<vector<long int> >
aux;
1465 for (
unsigned j=0; j<
data.size(); j++)
1467 vector<long int> tmp;
1468 for (
unsigned i=0; i<
data[j].size(); i++)
1470 if (
data[j][i]==
"NULL")
1474 tmp.push_back(null);
1477 tmp.push_back(atol(
data[j][i].c_str()));
1479 aux.push_back(std::move(tmp));
1486 vector<vector<int64> >
aux;
1487 for (
unsigned j=0; j<
data.size(); j++)
1490 for (
unsigned i=0; i<
data[j].size(); i++)
1492 if (
data[j][i]==
"NULL")
1496 tmp.push_back(null);
1501 aux.push_back(std::move(tmp));
1508 vector<vector<short int> >
aux;
1509 for (
unsigned j=0; j<
data.size(); j++)
1511 vector<short int> tmp;
1512 for (
unsigned i=0; i<
data[j].size(); i++)
1514 if (
data[j][i]==
"NULL")
1519 tmp.push_back(atoi(
data[j][i].c_str()));
1521 aux.push_back(std::move(tmp));
1528 vector<vector<float> >
aux;
1529 for (
unsigned j=0; j<
data.size(); j++)
1532 for (
unsigned i=0; i<
data[j].size(); i++)
1534 if (
data[j][i]==
"NULL")
1538 tmp.push_back(null);
1541 tmp.push_back(atof(
data[j][i].c_str()));
1543 aux.push_back(std::move(tmp));
1550 vector<vector<double> >
aux;
1551 for (
unsigned j=0; j<
data.size(); j++)
1554 for (
unsigned i=0; i<
data[j].size(); i++)
1556 if (
data[j][i]==
"NULL")
1560 tmp.push_back(null);
1563 tmp.push_back(strtod(
data[j][i].c_str(), (
char**)NULL));
1565 aux.push_back(std::move(tmp));
1652 vector<long int> tmp;
1654 int size = tmp.size();
1666 vector<short int> tmp;
1668 int size = tmp.size();
1682 int size = tmp.size();
1696 int size = tmp.size();
1710 int size = tmp.size();
1714 values.push_back(tmp[size-1]);
1723 int size = tmp.size();
1761template <
typename T,
typename COLUMN>
1772 if (tmpColumn->column.size() <= n_row)
1773 ndata = tmpColumn->column.back();
1775 ndata = tmpColumn->column[n_row+1];
1787template <
typename T,
typename COLUMN>
1798 if (tmpColumn->column.size() == (n_row+1))
1799 tmpColumn->column.push_back(ndata);
1801 if (tmpColumn->column.size() < (n_row+1))
1803 T tmp = tmpColumn->column.back();
1805 while((n_row)-tmpColumn->column.size())
1807 tmpColumn->column.push_back(tmp);
1809 tmpColumn->column.push_back(ndata);
1813 tmpColumn->column[n_row+1] = ndata;
1824template <
typename T,
typename COLUMN>
1837 tmpColumn->column.push_back(
data[
index]);
1850template <
typename T>
char data[hepevt_bytes_allocation_ATLAS]
static const std::vector< std::string > types
void Initialize(unsigned n_columns, int n_rows=0)
This method initializes a table created by the default constructor If the table had the number of col...
int setNull(unsigned n_column, const float &null)
Set Null value for column.
void verifyInitialization()
Verifies if all columns are initialized.
int __setCell(unsigned n_column, unsigned n_row, const T &ndata, dataTypes type, COLUMN *tmpColumn)
Templated method that set's the data in a specified cell This is the method that does the real work.
int getTypes(std::vector< dataTypes > &types) const
This method gets a vector containing the data types of all columns in the table.
int setName(unsigned n_column, const std::string &name)
This method defines the name for a specified column.
int getNames(std::vector< std::string > &names) const
This method gets a vector containing the names of all columns in the table.
int __getNull(T &data, COLUMN *tmpColumn) const
Templated method for handling the null values.
int __setColumnData(unsigned n_column, T &data, dataTypes type, COLUMN *tmpColumn)
Templated method that set's portions of data in a specified column This method is deprecated and henc...
std::string ToString(const TYPE &t) const
Auxiliary function to convert any value to string.
int setType(unsigned n_column, dataTypes type)
This method defines the data type for a specified column.
int getRow(unsigned rowNumber, std::vector< std::string > &values) const
This method returns a vector of strings with allelements in a row In case the cell has an array the f...
int getCell(unsigned n_column, unsigned n_row, short int &ndata) const
This method gets a value from a cell in a column of long ints (int in MySQL)
int setColumndata(unsigned n_column, const std::vector< short int > &data)
The following methods allow to insert in the columns a group of values.
GenericDbTable()
Default constructor.
int __getCellByName(const std::string &colName, unsigned int n_row, T &data) const
Templated method that get's column data using the column name This method get's the desired column nu...
int setCell(unsigned n_column, unsigned n_row, const short int ndata)
set data methods
int getNull(unsigned n_column, float &null) const
Get Null value for column.
int __getCell(unsigned n_column, unsigned n_row, T &ndata, dataTypes type, COLUMN *tmpColumn) const
Templated method that get's the data from a specified cell This is the method that does the real work...
~GenericDbTable()
Object destructor.
int getRowID(std::string &pID) const
This method returns, for a given ID, the row number.
std::vector< CondDBColumn * > m_conddbtable
void resize(int num_rows)
Reserves more rows on the table.
std::vector< std::vector< short int > > column
std::vector< std::vector< double > > column
std::vector< std::vector< float > > column
std::vector< std::vector< long int > > column
std::vector< std::vector< int64 > > column
std::vector< std::vector< std::string > > column
std::vector< short int > column
std::vector< double > column
std::vector< float > column
std::vector< long int > column
std::vector< int64 > column
std::vector< std::string > column
Definition of the columns.