Patch level : 12.0 no-patch
Files correlati : include Commento : Refactor nomi funzioni in TXvt_recordset
This commit is contained in:
parent
d6f2602bff
commit
8b1b58337e
@ -12,6 +12,12 @@ const TDate SSimple_query::sq_get_date(const char * field)
|
||||
return app;
|
||||
}
|
||||
|
||||
const real SSimple_query::sq_get_real(const char * field)
|
||||
{
|
||||
const real app(_rec.get(field));
|
||||
return app;
|
||||
}
|
||||
|
||||
TString SSimple_query::sq_get(const char* field, bool rtrim)
|
||||
{
|
||||
TString fld = _rec.get(field);
|
||||
@ -21,7 +27,7 @@ TString SSimple_query::sq_get(const char* field, bool rtrim)
|
||||
return fld;
|
||||
}
|
||||
|
||||
TString SSimple_query::sq_get(string field, bool rtrim)
|
||||
TString SSimple_query::sq_get(const string& field, const bool rtrim)
|
||||
{
|
||||
return sq_get(field.c_str(), rtrim);
|
||||
}
|
||||
|
@ -74,48 +74,48 @@ public:
|
||||
/**< Costruttore, non inizializza nulla, da caricare successivamente */
|
||||
SSimple_query() = default;
|
||||
/**< Costruttore, Accetta in ingresso dei parametri per la connessione, volendo è anche possibile impostare una query ed eseguirla. Attenzione! Non risponde se la query ha avuto un esito positivo o negativo! */
|
||||
SSimple_query(const char* db, const char* user, const char* pass, TT_driver tipoDb, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipoDb, query, ex, freezed) {}
|
||||
SSimple_query(const char* db, const char* user, const char* pass, const TT_driver tipo_db, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipo_db, query, ex, freezed) {}
|
||||
//SSimpleQuery(const TString& db, const TString& user, const TString& pass, TT_driver tipoDb, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipoDb, query, ex, freezed) {}
|
||||
/**< Distruttore */
|
||||
virtual ~SSimple_query() = default;
|
||||
|
||||
// Connection functions
|
||||
/**< Eseguo la connessione */
|
||||
int sq_connect(const char* db, const char* user, const char* pass, TT_driver tipoDb) { return _rec.connect(db, user, pass, tipoDb); }
|
||||
int sq_connect(const char* db, const char* user, const char* pass, const TT_driver tipo_db) { return _rec.connect(db, user, pass, tipo_db); }
|
||||
/* Mi scollego */
|
||||
void sq_disconnect() { _rec.disconnect(); }
|
||||
/**< Esegue la commit, di default in caso di errore viene chiamato il metodo rollback() */
|
||||
const bool sq_commit(bool autoRoll = true) { return _rec.commit(); }
|
||||
const bool sq_commit(const bool auto_roll = true) { return _rec.commit(auto_roll); }
|
||||
/**< Esegue il rollback all'ultimo commit */
|
||||
const bool sq_rollback() { return _rec.rollback(); }
|
||||
/**< Imposto il tipo di client che utilizzo */
|
||||
void sq_set_client(int client) { _rec.setClient((TT_driver)client); }
|
||||
void sq_set_client(TT_driver client) { _rec.setClient(client); }
|
||||
void sq_set_client(int client) { _rec.set_client(static_cast<TT_driver>(client)); }
|
||||
void sq_set_client(const TT_driver client) { _rec.set_client(client); }
|
||||
// Imposto una opzione generica dellla connessione
|
||||
void sq_set_con_option(const char* opt) { _rec.setConOption(opt); }
|
||||
void sq_set_con_option(const char* opt) { _rec.set_con_option(opt); }
|
||||
/**< Abilito/Disabilito l'autocommit, (disabilitato di default) */
|
||||
void sq_set_autocommit(bool ac) { _rec.setAutocommit(ac); }
|
||||
void sq_set_autocommit(const bool ac) { _rec.set_autocommit(ac); }
|
||||
/** Imposta la visibilità delle transazioni (vedi Funzione) */
|
||||
void sq_set_visibility(isoLvl vis = committed) { _rec.setVisibility(vis); }
|
||||
void sq_set_visibility(const iso_lvl vis = committed) { _rec.set_visibility(vis); }
|
||||
// Getters
|
||||
/** Ritorna se la conessione è connessa */
|
||||
const bool sq_is_connect() const { return _rec.isConnect(); }
|
||||
const bool sq_is_connect() const { return _rec.is_connect(); }
|
||||
/**< Ritorna se la connessione è attiva */
|
||||
const bool sq_is_alive() const { return _rec.isAlive(); }
|
||||
const bool sq_is_alive() const { return _rec.is_alive(); }
|
||||
/** Ritorna la visibilità impostata */
|
||||
const int sq_get_visibility() { return _rec.getVisibility(); }
|
||||
const int sq_get_visibility() { return _rec.get_visibility(); }
|
||||
/**< Ritorna se è attivo l'autocommit, true -> attivo, false -> disattivo o sconosciuto */
|
||||
const bool sq_get_autocommit() { return _rec.getAutocommit(); }
|
||||
const bool sq_get_autocommit() { return _rec.get_autocommit(); }
|
||||
/**< Ritorna il valore dell'opzione specificata */
|
||||
const char* sq_get_option(const char* opt) { return _rec.getOption(opt); }
|
||||
const char* sq_get_option(const char* opt) { return _rec.get_option(opt); }
|
||||
/**< Ritorno la versione del Client che sto utilizzando */
|
||||
const long sq_get_client_v() { return _rec.getClientV(); }
|
||||
const long sq_get_client_v() { return _rec.get_client_v(); }
|
||||
/**< Ritorno la versione del Server che sto utilizzando */
|
||||
const char* sq_get_server_v() { return _rec.getServerV(); }
|
||||
/**< Ritorno la versione del Server che sto utilizzando in formato numerico */
|
||||
const long sq_get_server_vn() { return _rec.getServerVN(); }
|
||||
const long sq_get_server_vn() { return _rec.get_server_vn(); }
|
||||
/**< Ritorno se il recordset è carico */
|
||||
const bool sq_is_loaded() const { return _rec.isLoaded(); }
|
||||
const bool sq_is_loaded() const { return _rec.is_loaded(); }
|
||||
/** Ritorno il numero di elementi nella query */
|
||||
const long sq_items() { return _rec.items(); }
|
||||
|
||||
@ -123,17 +123,17 @@ public:
|
||||
/**< Imposta la query ricevuta come (const char *) nel recordset */
|
||||
const bool sq_set(const char* query) { return _rec.set(query); }
|
||||
/**< Imposta la query ricevuta come (string) nel recordset */
|
||||
const bool sq_set(string query) { return _rec.set(query.c_str()); }
|
||||
const bool sq_set(const string& query) { return _rec.set(query.c_str()); }
|
||||
/**< Imposta la query ricevuta come (TString) nel recordset */
|
||||
const bool sq_set(TString& query) { return _rec.set(static_cast<const char *>(query)); }
|
||||
/**< Esegue la query impostata nel recordset, se viene passato autoF == true esegue anche un comando sqNext() */
|
||||
const bool sq_exec(bool autoF = true) { return _rec.exec(autoF); }
|
||||
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (const char *) */
|
||||
const bool sq_set_exec(const char* query, bool autoF = true) { _rec.set(query); return _rec.exec(autoF); }
|
||||
const bool sq_set_exec(const char* query, const bool auto_f = true) { _rec.set(query); return _rec.exec(auto_f); }
|
||||
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (string) */
|
||||
const bool sq_set_exec(string query, bool autoF = true) { _rec.set(query.c_str()); return _rec.exec(autoF); }
|
||||
const bool sq_set_exec(const string& query, const bool auto_f = true) { _rec.set(query.c_str()); return _rec.exec(auto_f); }
|
||||
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (TString) */
|
||||
const bool sq_set_exec(TString& query, bool autoF = true) { return sq_set_exec(static_cast<const char*>(query), autoF); }
|
||||
const bool sq_set_exec(TString& query, const bool auto_f = true) { return sq_set_exec(static_cast<const char*>(query), auto_f); }
|
||||
/**< Si sposta avanti di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
const bool sq_next() { return _rec.next(); }
|
||||
/**< Si sposta indietro di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
@ -143,9 +143,9 @@ public:
|
||||
/**< Si sposta al primo record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
const bool sq_last() { return _rec.last(); }
|
||||
/**< Si sposta alla posizione n, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
const bool sq_go(int newPos) { return _rec.go(newPos); }
|
||||
const bool sq_go(const int new_pos) { return _rec.go(new_pos); }
|
||||
/**< Ritorna il numero di righe affette dall'ultima query */
|
||||
const int sq_rows_affected() { return _rec.rowsAffected(); }
|
||||
const int sq_rows_affected() const { return _rec.rows_affected(); }
|
||||
|
||||
|
||||
// Getters
|
||||
@ -168,7 +168,7 @@ public:
|
||||
/**< Ritorna il valore nel campo (field) passato come (const char *) in formato (const char *) */
|
||||
TString sq_get(const char* field, bool rtrim = true);
|
||||
/**< Ritorna il valore nel campo (field) passato come (string) in formato (const char *) */
|
||||
TString sq_get(string field, bool rtrim = true);
|
||||
TString sq_get(const string& field, bool rtrim = true);
|
||||
/**< Ritorna il valore nel campo (field) passato come (TString) in formato (const char *) */
|
||||
TString sq_get(TString& field, bool rtrim = true);
|
||||
/**< Ritorna il valore nel campo (field) in formato (char) */
|
||||
@ -178,11 +178,11 @@ public:
|
||||
|
||||
// Error Getters
|
||||
/**< Ritorno l'ultimo codice errore segnalato in formato /int) */
|
||||
const long sq_get_code_error(bool erase = true) { return _rec.get_code_error(erase); }
|
||||
const long sq_get_code_error(const bool erase = true) { return _rec.get_code_error(erase); }
|
||||
/**< Ritorno l'ultima stringa di errore segnalato in formato (const char *) */
|
||||
const char* sq_get_string_error(bool erase = true) { return _rec.get_string_error(erase); }
|
||||
const char* sq_get_string_error(const bool erase = true) { return _rec.get_string_error(erase); }
|
||||
/**< Ritorno l'ultima stringa di errore segnalato in formato (const char *) */
|
||||
const char* sq_get_text_error(bool erase = true) { return _rec.get_text_error(erase); }
|
||||
const char* sq_get_text_error(const bool erase = true) { return _rec.get_text_error(erase); }
|
||||
};
|
||||
|
||||
#endif
|
@ -9,6 +9,7 @@
|
||||
#define _CPY_STR(from,to) (to = strdup(from));
|
||||
#define _GET_ERROR(from,to) _CPY_STR(from,to)
|
||||
|
||||
#define CHECK_FREEZED if (is_freezed()) { return set_error_freezed(); }
|
||||
|
||||
/******************************************************************************
|
||||
* TXvt_recordset *
|
||||
@ -84,7 +85,7 @@ const bool TXvt_recordset::checkPermission()
|
||||
{
|
||||
bool err = is_freezed();
|
||||
if (err)
|
||||
setErrorFreezed();
|
||||
set_error_freezed();
|
||||
return !err;
|
||||
}
|
||||
|
||||
@ -94,7 +95,7 @@ const bool TXvt_recordset::checkPermission()
|
||||
* Gestione Connection *
|
||||
**************************************************************************************************/
|
||||
|
||||
int TXvt_recordset::connect(const char* db, const char* user, const char* pass, TT_driver tipoDb)
|
||||
int TXvt_recordset::connect(const char* db, const char* user, const char* pass, TT_driver tipo_db)
|
||||
{
|
||||
if (_con != NULL)
|
||||
{
|
||||
@ -105,7 +106,7 @@ int TXvt_recordset::connect(const char* db, const char* user, const char* pass,
|
||||
SAString dbAddress = db;
|
||||
SAString usr = user;
|
||||
SAString psw = pass;
|
||||
SAClient_t dbDriver = (SAClient_t)tipoDb;
|
||||
SAClient_t dbDriver = (SAClient_t)tipo_db;
|
||||
if (dbAddress.IsEmpty() || usr.IsEmpty())
|
||||
{
|
||||
_code_error = NOT_INITIALIZED;
|
||||
@ -189,22 +190,22 @@ bool TXvt_recordset::rollback()
|
||||
return true;
|
||||
}
|
||||
|
||||
void TXvt_recordset::setClient(TT_driver client)
|
||||
void TXvt_recordset::set_client(TT_driver client)
|
||||
{
|
||||
_CON(_con)->setClient((SAClient_t) client);
|
||||
}
|
||||
|
||||
void TXvt_recordset::setConOption(const char* opt)
|
||||
void TXvt_recordset::set_con_option(const char* opt)
|
||||
{
|
||||
_CON(_con)->setOption(opt);
|
||||
}
|
||||
|
||||
void TXvt_recordset::setAutocommit(bool ac)
|
||||
void TXvt_recordset::set_autocommit(bool ac)
|
||||
{
|
||||
_CON(_con)->setAutoCommit(ac ? SA_AutoCommitOn : SA_AutoCommitOff);
|
||||
}
|
||||
|
||||
void TXvt_recordset::setVisibility(isoLvl vis)
|
||||
void TXvt_recordset::set_visibility(iso_lvl vis)
|
||||
{
|
||||
/* La libreria attuale supporta diversi tipi di visibilità, per mantenere una compatibilità massima
|
||||
* (evitando inutili seghe mentali) consiglio di usare i primi due, di default la classe imposta "Read committed"
|
||||
@ -217,27 +218,27 @@ void TXvt_recordset::setVisibility(isoLvl vis)
|
||||
_CON(_con)->setIsolationLevel((SAIsolationLevel_t)vis);
|
||||
}
|
||||
|
||||
const bool TXvt_recordset::isConnect() const
|
||||
const bool TXvt_recordset::is_connect() const
|
||||
{
|
||||
return _CON(_con)->isConnected();
|
||||
}
|
||||
const bool TXvt_recordset::isAlive() const
|
||||
const bool TXvt_recordset::is_alive() const
|
||||
{
|
||||
return _CON(_con)->isAlive();
|
||||
}
|
||||
int TXvt_recordset::getVisibility()
|
||||
int TXvt_recordset::get_visibility()
|
||||
{
|
||||
return (isoLvl)_CON(_con)->IsolationLevel();
|
||||
return (iso_lvl)_CON(_con)->IsolationLevel();
|
||||
}
|
||||
bool TXvt_recordset::getAutocommit()
|
||||
bool TXvt_recordset::get_autocommit()
|
||||
{
|
||||
return _CON(_con)->AutoCommit() == SA_AutoCommitOn;
|
||||
}
|
||||
const char* TXvt_recordset::getOption(const char* opt)
|
||||
const char* TXvt_recordset::get_option(const char* opt)
|
||||
{
|
||||
return _CON(_con)->Option(opt);
|
||||
}
|
||||
long TXvt_recordset::getClientV()
|
||||
long TXvt_recordset::get_client_v()
|
||||
{
|
||||
return _CON(_con)->ClientVersion();
|
||||
}
|
||||
@ -245,12 +246,12 @@ const char* TXvt_recordset::getServerV()
|
||||
{
|
||||
return _CON(_con)->ServerVersionString();
|
||||
}
|
||||
long TXvt_recordset::getServerVN()
|
||||
long TXvt_recordset::get_server_vn()
|
||||
{
|
||||
return _CON(_con)->ServerVersion();
|
||||
}
|
||||
|
||||
bool TXvt_recordset::isLoaded() const
|
||||
bool TXvt_recordset::is_loaded() const
|
||||
{
|
||||
return _loaded;
|
||||
}
|
||||
@ -331,10 +332,10 @@ bool TXvt_recordset::exec(bool autoF)
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TXvt_recordset::setExec(const char* query, bool autoF)
|
||||
bool TXvt_recordset::set_exec(const char* query, bool auto_f)
|
||||
{
|
||||
set(query);
|
||||
return exec(autoF);
|
||||
return exec(auto_f);
|
||||
}
|
||||
|
||||
bool TXvt_recordset::next()
|
||||
@ -426,18 +427,18 @@ bool TXvt_recordset::last()
|
||||
return fetched;
|
||||
}
|
||||
|
||||
bool TXvt_recordset::go(int newPos)
|
||||
bool TXvt_recordset::go(int new_pos)
|
||||
{
|
||||
// Controllo che la nuova posizione non sia fuori dal limite inferiore (Non so quanto è grande il recordset)
|
||||
bool result = newPos >= 0 ? true : false;
|
||||
bool result = new_pos >= 0 ? true : false;
|
||||
|
||||
// Se la posizione è minore mi sposto indietro
|
||||
while (newPos < _recno && result)
|
||||
while (new_pos < _recno && result)
|
||||
{
|
||||
result = prev();
|
||||
}
|
||||
// Se la posizione è maggiore mi sposto in avanti
|
||||
while (newPos > _recno && result)
|
||||
while (new_pos > _recno && result)
|
||||
{
|
||||
result = next();
|
||||
}
|
||||
@ -451,7 +452,7 @@ bool TXvt_recordset::go(int newPos)
|
||||
return result;
|
||||
}
|
||||
|
||||
const int TXvt_recordset::rowsAffected()
|
||||
const int TXvt_recordset::rows_affected() const
|
||||
{
|
||||
return _RCS(_recset)->RowsAffected();
|
||||
}
|
||||
@ -624,7 +625,7 @@ const char* TXvt_recordset::get_text_error(bool erase)
|
||||
return app;
|
||||
}
|
||||
|
||||
const bool TXvt_recordset::setErrorFreezed()
|
||||
const bool TXvt_recordset::set_error_freezed()
|
||||
{
|
||||
_code_error = ERROR_FREEZED;
|
||||
_string_error = _string_error_full_text = ERROR_FREEZEDS;
|
||||
|
@ -13,8 +13,6 @@
|
||||
|
||||
#define SQLAPIV "SQLAPI++ 4.1.5" // Da tenere aggiornato
|
||||
|
||||
#define CHECK_FREEZED if (is_freezed()) { return setErrorFreezed(); }
|
||||
|
||||
enum TT_driver
|
||||
{
|
||||
//! DBMS client is not specified
|
||||
@ -45,7 +43,7 @@ enum TT_driver
|
||||
TSDB_SQLAnywhere
|
||||
};
|
||||
|
||||
enum isoLvl { unknown = -1, uncommitted, committed, rr, serializable };
|
||||
enum iso_lvl { unknown = -1, uncommitted, committed, rr, serializable };
|
||||
|
||||
#define P_CONN_VOID void *
|
||||
#define P_COMM_VOID void *
|
||||
@ -113,7 +111,7 @@ public:
|
||||
* pass = Angela
|
||||
* driver = TSDB_MSSQL
|
||||
*/
|
||||
int connect(const char* db, const char* user, const char* pass, TT_driver tipoDb);
|
||||
int connect(const char* db, const char* user, const char* pass, TT_driver tipo_db);
|
||||
/* Mi scollego */
|
||||
void disconnect();
|
||||
/**< Esegue la commit, di default in caso di errore viene chiamato il metodo rollback() */
|
||||
@ -124,35 +122,35 @@ public:
|
||||
// Setters
|
||||
|
||||
/**< Imposto il tipo di client che utilizzo */
|
||||
void setClient(TT_driver client);
|
||||
void set_client(TT_driver client);
|
||||
// Imposto una opzione generica dellla connessione
|
||||
void setConOption(const char* opt);
|
||||
void set_con_option(const char* opt);
|
||||
/**< Abilito/Disabilito l'autocommit, (disabilitato di default) */
|
||||
void setAutocommit(bool ac);
|
||||
/** Imposta la visibilità delle transazioni (vedi Funzione) */
|
||||
void setVisibility(isoLvl vis = committed);
|
||||
void set_autocommit(bool ac);
|
||||
/**< Imposta la visibilità delle transazioni (vedi Funzione) */
|
||||
void set_visibility(iso_lvl vis = committed);
|
||||
|
||||
|
||||
// Getters
|
||||
/** Ritorna se la conessione è connessa */
|
||||
const bool isConnect() const;
|
||||
/**< Ritorna se la conessione è connessa */
|
||||
const bool is_connect() const;
|
||||
/**< Ritorna se la connessione è attiva */
|
||||
const bool isAlive() const;
|
||||
/** Ritorna la visibilità impostata */
|
||||
int getVisibility();
|
||||
const bool is_alive() const;
|
||||
/**< Ritorna la visibilità impostata */
|
||||
int get_visibility();
|
||||
/**< Ritorna se è attivo l'autocommit, true -> attivo, false -> disattivo o sconosciuto */
|
||||
bool getAutocommit();
|
||||
bool get_autocommit();
|
||||
/**< Ritorna il valore dell'opzione specificata */
|
||||
const char* getOption(const char* opt);
|
||||
const char* get_option(const char* opt);
|
||||
/**< Ritorno la versione del Client che sto utilizzando */
|
||||
long getClientV();
|
||||
long get_client_v();
|
||||
/**< Ritorno la versione del Server che sto utilizzando */
|
||||
const char* getServerV();
|
||||
/**< Ritorno la versione del Server che sto utilizzando in formato numerico */
|
||||
long getServerVN();
|
||||
long get_server_vn();
|
||||
/**< Ritorno se il recordset è carico */
|
||||
bool isLoaded() const;
|
||||
/** Ritorno il numero di elementi nella query */
|
||||
bool is_loaded() const;
|
||||
/**< Ritorno il numero di elementi nella query */
|
||||
long items();
|
||||
|
||||
/**************************************************************************************************
|
||||
@ -165,7 +163,7 @@ public:
|
||||
/**< Esegue la query impostata nel recordset, se viene passato autoF == true esegue anche un comando Next() */
|
||||
bool exec(bool autoF = true);
|
||||
/**< Unisce le funzioni Set e Exec, riceve la query */
|
||||
bool setExec(const char* query, bool autoF = true);
|
||||
bool set_exec(const char* query, bool auto_f = true);
|
||||
/**< Si sposta avanti di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
bool next();
|
||||
/**< Si sposta indietro di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
@ -175,9 +173,9 @@ public:
|
||||
/**< Si sposta al primo record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
bool last();
|
||||
/**< Si sposta alla posizione n, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
bool go(int newPos);
|
||||
bool go(int new_pos);
|
||||
/**< Ritorna il numero di righe affette dall'ultima query */
|
||||
const int rowsAffected();
|
||||
const int rows_affected() const;
|
||||
|
||||
// Getters
|
||||
/**< Ritorna il valore nel campo (field) in formato (int) */
|
||||
@ -223,7 +221,7 @@ public:
|
||||
bool frozen() const { return is_freezed(); }
|
||||
bool not_frozen() const { return !is_freezed(); }
|
||||
/**< Imposta l'errore di record congelato */
|
||||
const bool setErrorFreezed();
|
||||
const bool set_error_freezed();
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user