creaImageIO_lib
CppSQLite3Table Class Reference

#include <CppSQLite3.h>

Public Member Functions

 CppSQLite3Table ()
 
 CppSQLite3Table (const CppSQLite3Table &rTable)
 
 CppSQLite3Table (char **paszResults, int nRows, int nCols)
 
virtual ~CppSQLite3Table ()
 
CppSQLite3Tableoperator= (const CppSQLite3Table &rTable)
 
int numFields ()
 
int numRows ()
 
const char * fieldName (int nCol)
 
const char * fieldValue (int nField)
 
const char * fieldValue (const char *szField)
 
int getIntField (int nField, int nNullValue=0)
 
int getIntField (const char *szField, int nNullValue=0)
 
double getFloatField (int nField, double fNullValue=0.0)
 
double getFloatField (const char *szField, double fNullValue=0.0)
 
const char * getStringField (int nField, const char *szNullValue="")
 
const char * getStringField (const char *szField, const char *szNullValue="")
 
bool fieldIsNull (int nField)
 
bool fieldIsNull (const char *szField)
 
void setRow (int nRow)
 
void finalize ()
 

Private Member Functions

void checkResults ()
 

Private Attributes

int mnCols
 
int mnRows
 
int mnCurrentRow
 
char ** mpaszResults
 

Detailed Description

Definition at line 351 of file CppSQLite3.h.

Constructor & Destructor Documentation

CppSQLite3Table::CppSQLite3Table ( )

Definition at line 1243 of file CppSQLite3.cpp.

References mnCols, mnCurrentRow, mnRows, and mpaszResults.

1245 {
1246 
1247  mpaszResults = 0;
1248 
1249  mnRows = 0;
1250 
1251  mnCols = 0;
1252 
1253  mnCurrentRow = 0;
1254 
1255 }
CppSQLite3Table::CppSQLite3Table ( const CppSQLite3Table rTable)

Definition at line 1261 of file CppSQLite3.cpp.

References mnCols, mnCurrentRow, mnRows, and mpaszResults.

1263 {
1264 
1265  mpaszResults = rTable.mpaszResults;
1266 
1267  // Only one object can own the results
1268 
1269  const_cast<CppSQLite3Table&>(rTable).mpaszResults = 0;
1270 
1271  mnRows = rTable.mnRows;
1272 
1273  mnCols = rTable.mnCols;
1274 
1275  mnCurrentRow = rTable.mnCurrentRow;
1276 
1277 }
CppSQLite3Table::CppSQLite3Table ( char **  paszResults,
int  nRows,
int  nCols 
)

Definition at line 1283 of file CppSQLite3.cpp.

References mnCols, mnCurrentRow, mnRows, and mpaszResults.

1285 {
1286 
1287  mpaszResults = paszResults;
1288 
1289  mnRows = nRows;
1290 
1291  mnCols = nCols;
1292 
1293  mnCurrentRow = 0;
1294 
1295 }
CppSQLite3Table::~CppSQLite3Table ( )
virtual

Definition at line 1301 of file CppSQLite3.cpp.

References finalize().

1303 {
1304 
1305  try
1306 
1307  {
1308 
1309  finalize();
1310 
1311  }
1312 
1313  catch (...)
1314 
1315  {
1316 
1317  }
1318 
1319 }

Here is the call graph for this function:

Member Function Documentation

void CppSQLite3Table::checkResults ( )
private

Definition at line 1731 of file CppSQLite3.cpp.

References CPPSQLITE_ERROR, DONT_DELETE_MSG, and mpaszResults.

Referenced by fieldIsNull(), fieldName(), fieldValue(), numFields(), numRows(), and setRow().

1733 {
1734 
1735  if (mpaszResults == 0)
1736 
1737  {
1738 
1740 
1741  "Null Results pointer",
1742 
1743  DONT_DELETE_MSG);
1744 
1745  }
1746 
1747 }

Here is the caller graph for this function:

bool CppSQLite3Table::fieldIsNull ( int  nField)

Definition at line 1643 of file CppSQLite3.cpp.

References checkResults(), and fieldValue().

Referenced by getFloatField(), getIntField(), and getStringField().

1645 {
1646 
1647  checkResults();
1648 
1649  return (fieldValue(nField) == 0);
1650 
1651 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool CppSQLite3Table::fieldIsNull ( const char *  szField)

Definition at line 1657 of file CppSQLite3.cpp.

References checkResults(), and fieldValue().

1659 {
1660 
1661  checkResults();
1662 
1663  return (fieldValue(szField) == 0);
1664 
1665 }

Here is the call graph for this function:

const char * CppSQLite3Table::fieldName ( int  nCol)

Definition at line 1671 of file CppSQLite3.cpp.

References checkResults(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, and mpaszResults.

1673 {
1674 
1675  checkResults();
1676 
1677 
1678 
1679  if (nCol < 0 || nCol > mnCols-1)
1680 
1681  {
1682 
1684 
1685  "Invalid field index requested",
1686 
1687  DONT_DELETE_MSG);
1688 
1689  }
1690 
1691 
1692 
1693  return mpaszResults[nCol];
1694 
1695 }

Here is the call graph for this function:

const char * CppSQLite3Table::fieldValue ( int  nField)

Definition at line 1411 of file CppSQLite3.cpp.

References checkResults(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, mnCurrentRow, and mpaszResults.

Referenced by fieldIsNull(), getFloatField(), getIntField(), and getStringField().

1413 {
1414 
1415  checkResults();
1416 
1417 
1418 
1419  if (nField < 0 || nField > mnCols-1)
1420 
1421  {
1422 
1424 
1425  "Invalid field index requested",
1426 
1427  DONT_DELETE_MSG);
1428 
1429  }
1430 
1431 
1432 
1433  int nIndex = (mnCurrentRow*mnCols) + mnCols + nField;
1434 
1435  return mpaszResults[nIndex];
1436 
1437 }

Here is the call graph for this function:

Here is the caller graph for this function:

const char * CppSQLite3Table::fieldValue ( const char *  szField)

Definition at line 1443 of file CppSQLite3.cpp.

References checkResults(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, mnCurrentRow, and mpaszResults.

1445 {
1446 
1447  checkResults();
1448 
1449 
1450 
1451  if (szField)
1452 
1453  {
1454 
1455  for (int nField = 0; nField < mnCols; nField++)
1456 
1457  {
1458 
1459  if (strcmp(szField, mpaszResults[nField]) == 0)
1460 
1461  {
1462 
1463  int nIndex = (mnCurrentRow*mnCols) + mnCols + nField;
1464 
1465  return mpaszResults[nIndex];
1466 
1467  }
1468 
1469  }
1470 
1471  }
1472 
1473 
1474 
1476 
1477  "Invalid field name requested",
1478 
1479  DONT_DELETE_MSG);
1480 
1481 }

Here is the call graph for this function:

void CppSQLite3Table::finalize ( )

Definition at line 1363 of file CppSQLite3.cpp.

References mpaszResults.

Referenced by operator=(), and ~CppSQLite3Table().

1365 {
1366 
1367  if (mpaszResults)
1368 
1369  {
1370 
1371  sqlite3_free_table(mpaszResults);
1372 
1373  mpaszResults = 0;
1374 
1375  }
1376 
1377 }

Here is the caller graph for this function:

double CppSQLite3Table::getFloatField ( int  nField,
double  fNullValue = 0.0 
)

Definition at line 1539 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

1541 {
1542 
1543  if (fieldIsNull(nField))
1544 
1545  {
1546 
1547  return fNullValue;
1548 
1549  }
1550 
1551  else
1552 
1553  {
1554 
1555  return atof(fieldValue(nField));
1556 
1557  }
1558 
1559 }

Here is the call graph for this function:

double CppSQLite3Table::getFloatField ( const char *  szField,
double  fNullValue = 0.0 
)

Definition at line 1565 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

1567 {
1568 
1569  if (fieldIsNull(szField))
1570 
1571  {
1572 
1573  return fNullValue;
1574 
1575  }
1576 
1577  else
1578 
1579  {
1580 
1581  return atof(fieldValue(szField));
1582 
1583  }
1584 
1585 }

Here is the call graph for this function:

int CppSQLite3Table::getIntField ( int  nField,
int  nNullValue = 0 
)

Definition at line 1487 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

1489 {
1490 
1491  if (fieldIsNull(nField))
1492 
1493  {
1494 
1495  return nNullValue;
1496 
1497  }
1498 
1499  else
1500 
1501  {
1502 
1503  return atoi(fieldValue(nField));
1504 
1505  }
1506 
1507 }

Here is the call graph for this function:

int CppSQLite3Table::getIntField ( const char *  szField,
int  nNullValue = 0 
)

Definition at line 1513 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

1515 {
1516 
1517  if (fieldIsNull(szField))
1518 
1519  {
1520 
1521  return nNullValue;
1522 
1523  }
1524 
1525  else
1526 
1527  {
1528 
1529  return atoi(fieldValue(szField));
1530 
1531  }
1532 
1533 }

Here is the call graph for this function:

const char * CppSQLite3Table::getStringField ( int  nField,
const char *  szNullValue = "" 
)

Definition at line 1591 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

1593 {
1594 
1595  if (fieldIsNull(nField))
1596 
1597  {
1598 
1599  return szNullValue;
1600 
1601  }
1602 
1603  else
1604 
1605  {
1606 
1607  return fieldValue(nField);
1608 
1609  }
1610 
1611 }

Here is the call graph for this function:

const char * CppSQLite3Table::getStringField ( const char *  szField,
const char *  szNullValue = "" 
)

Definition at line 1617 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

1619 {
1620 
1621  if (fieldIsNull(szField))
1622 
1623  {
1624 
1625  return szNullValue;
1626 
1627  }
1628 
1629  else
1630 
1631  {
1632 
1633  return fieldValue(szField);
1634 
1635  }
1636 
1637 }

Here is the call graph for this function:

int CppSQLite3Table::numFields ( )

Definition at line 1383 of file CppSQLite3.cpp.

References checkResults(), and mnCols.

1385 {
1386 
1387  checkResults();
1388 
1389  return mnCols;
1390 
1391 }

Here is the call graph for this function:

int CppSQLite3Table::numRows ( )

Definition at line 1397 of file CppSQLite3.cpp.

References checkResults(), and mnRows.

1399 {
1400 
1401  checkResults();
1402 
1403  return mnRows;
1404 
1405 }

Here is the call graph for this function:

CppSQLite3Table & CppSQLite3Table::operator= ( const CppSQLite3Table rTable)

Definition at line 1325 of file CppSQLite3.cpp.

References finalize(), mnCols, mnCurrentRow, mnRows, and mpaszResults.

1327 {
1328 
1329  try
1330 
1331  {
1332 
1333  finalize();
1334 
1335  }
1336 
1337  catch (...)
1338 
1339  {
1340 
1341  }
1342 
1343  mpaszResults = rTable.mpaszResults;
1344 
1345  // Only one object can own the results
1346 
1347  const_cast<CppSQLite3Table&>(rTable).mpaszResults = 0;
1348 
1349  mnRows = rTable.mnRows;
1350 
1351  mnCols = rTable.mnCols;
1352 
1353  mnCurrentRow = rTable.mnCurrentRow;
1354 
1355  return *this;
1356 
1357 }

Here is the call graph for this function:

void CppSQLite3Table::setRow ( int  nRow)

Definition at line 1701 of file CppSQLite3.cpp.

References checkResults(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCurrentRow, and mnRows.

1703 {
1704 
1705  checkResults();
1706 
1707 
1708 
1709  if (nRow < 0 || nRow > mnRows-1)
1710 
1711  {
1712 
1714 
1715  "Invalid row index requested",
1716 
1717  DONT_DELETE_MSG);
1718 
1719  }
1720 
1721 
1722 
1723  mnCurrentRow = nRow;
1724 
1725 }

Here is the call graph for this function:

Member Data Documentation

int CppSQLite3Table::mnCols
private

Definition at line 437 of file CppSQLite3.h.

Referenced by CppSQLite3Table(), fieldName(), fieldValue(), numFields(), and operator=().

int CppSQLite3Table::mnCurrentRow
private

Definition at line 441 of file CppSQLite3.h.

Referenced by CppSQLite3Table(), fieldValue(), operator=(), and setRow().

int CppSQLite3Table::mnRows
private

Definition at line 439 of file CppSQLite3.h.

Referenced by CppSQLite3Table(), numRows(), operator=(), and setRow().

char** CppSQLite3Table::mpaszResults
private

Definition at line 443 of file CppSQLite3.h.

Referenced by checkResults(), CppSQLite3Table(), fieldName(), fieldValue(), finalize(), and operator=().


The documentation for this class was generated from the following files: