YATiSh
Yet Another TIme SHeet
Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
yatishDB Class Reference

Provides a few basic methods and (static) members to interact with yatish tables. More...

#include <yatishDB.h>

Static Public Attributes

static const char * tableName []
 Must be defined in the same order as enum tableID. More...
 

Protected Member Functions

wxDatabase * GetDatabase (const wxString &)
 Sets up a (configuration) flux using its argument then calls wxDatabase::GetDatabase(). More...
 
bool TablesOk (wxDatabase *)
 Returns false if any of the yatish table is missings. More...
 

Static Protected Attributes

static wxDatabase * masterDB = nullptr
 

Detailed Description

Provides a few basic methods and (static) members to interact with yatish tables.

yatishDB and its daugters potentially raise wxDatabaseExceptions. The list of yatish error codes is centralized here for reference:

Error code Raised by Error message
-1 yatishDB::GetDatabase Authentication file not found
-2 yatishDB::GetDatabase Authentication file cannot be opened
-3 yatishDB::GetDatabase Error while reading the authentication file
-4 yatishDBsqlite::yatishDBsqlite Master DB must be SQLite
-4 yatishDBmysql::yatishDBmysql Slave DB must be MySQL
-5 yatishDBsqlite::yatishDBsqlite Yatish tables not found
-5 yatishDBmysql::yatishDBmysql Yatish tables not created

(error codes from the wxDatabase library itself are positive...).

Definition at line 42 of file yatishDB.h.

Member Function Documentation

◆ GetDatabase()

wxDatabase * yatishDB::GetDatabase ( const wxString &  configString)
protected

Sets up a (configuration) flux using its argument then calls wxDatabase::GetDatabase().

Parameters
configString
  • if empty (""), the database credentials are read from the file yatish.auth
  • otherwise they are read from the string itself
Returns
pointer to a wxDatabase, or nullptr if something went wrong

If configString = "", the function uses the last valid credentials found in yatish.auth; for instance:

[SQLite]
database=yatish.sqlite
;[MySQL]
;server=<domain name or IP address>
;database=<yatish database>
;user=<MySQL/MariaDB user>
;password=********

is equivalent to calling the function with the non-empty argument "[SQLite]\ndatabase=yatish.sqlite" because the MySQL account is commented out.

Definition at line 48 of file yatishDB.cpp.

◆ TablesOk()

bool yatishDB::TablesOk ( wxDatabase *  pDatabase)
protected

Returns false if any of the yatish table is missings.

Definition at line 83 of file yatishDB.cpp.

Member Data Documentation

◆ masterDB

wxDatabase * yatishDB::masterDB = nullptr
staticprotected

Definition at line 46 of file yatishDB.h.

◆ tableName

const char * yatishDB::tableName
static
Initial value:
= {
"client",
"task",
"tool",
"project",
"activity",
"timeslot"
}

Must be defined in the same order as enum tableID.

Furthermore this order is consistent with the yatish foreign key constraints for SQL CREATE (DROP on the contrary, should be performed in reverse order).

Definition at line 44 of file yatishDB.h.


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