Patch level : 12.0 nopatch

Files correlati     :

Commento        :
Aggiunta get_custom_query ai recordset per modifiche Straccia
Aggiunta in_module a dongle per modifiche Straccia
This commit is contained in:
Alessandro Bonazzi 2021-05-17 21:20:57 +02:00
parent 77ef393951
commit c1637d9147
4 changed files with 104 additions and 29 deletions

View File

@ -509,6 +509,21 @@ const TString& TDongle::module_name2desc(const char* mod) const
}
return module_code2desc(cod);
}
const char * TDongle::in_module(const char * object)
{
const TString_array& modinfo = info();
TString4 mod(object);
mod.left(2);
for (int i = modinfo.last(); i >= 0; i--)
{
const TString& autstr = modinfo.row(i);
if (autstr.starts_with(mod, true))
break;
}
return "";
}
bool TDongle::shown(word code) const
{

View File

@ -17,7 +17,7 @@
#include <strings.h>
#endif
enum TDongleHardware { _dongle_unknown=0, _dongle_network=3, _dongle_ssa=4, _dongle_ssanet=5 };
enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron, _dongle_network, _dongle_ssa, _dongle_ssanet,_dongle_software };
enum TDongleType { _no_dongle, _user_dongle, _developer_dongle };
class TDongle : public TObject
@ -88,6 +88,7 @@ public:
const TString& module_code2name(word module) const; // ... e viceversa
const TString& module_code2desc(word module) const; // Descrizione estesa del modulo
const TString& module_name2desc(const char* mod) const; // Converte un nome di due lettere in descrizione
const char * in_module(const char * object);
bool shown(word module) const; // Stabilisce se un modulo e' visibile in installazione
bool hidden(word module) const { return !shown(module); } // Modulo invisibile

View File

@ -18,7 +18,7 @@
static bool is_numeric(const char* str)
{
if (str == NULL || *str == '\0' || (*str == '0' && isdigit(str[1])))
if (str == nullptr || *str == '\0' || (*str == '0' && isdigit(str[1])))
return false; // Se comincia per zero va preservato!
if (*str == '-')
{
@ -28,7 +28,7 @@ static bool is_numeric(const char* str)
}
while (*str)
{
if (strchr("0123456789.,", *str) == NULL)
if (strchr("0123456789.,", *str) == nullptr)
return false;
str++;
}
@ -358,7 +358,7 @@ bool TRecordset::save_as_dbf(const char* table, int mode)
char dirname[_MAX_PATH];
char name[_MAX_FNAME];
char ext[_MAX_EXT];
xvt_fsys_parse_pathname(table, volume, dirname, name, ext, NULL);
xvt_fsys_parse_pathname(table, volume, dirname, name, ext, nullptr);
const int logicnum = table2logic(name);
@ -383,7 +383,7 @@ bool TRecordset::save_as_dbf(const char* table, int mode)
mode = 0x1;
}
TBaseisamfile* pisam = NULL;
TBaseisamfile* pisam = nullptr;
if (logicnum >= LF_USER)
{
if (*dirname)
@ -391,7 +391,7 @@ bool TRecordset::save_as_dbf(const char* table, int mode)
else
pisam = new TFast_isamfile(logicnum);
}
if (pisam == NULL)
if (pisam == nullptr)
return error_box("Impossibile creare il file %s", table);
TBaseisamfile& isam = *pisam;
@ -457,7 +457,7 @@ bool TRecordset::save_as(const char* path, TRecordsetExportFormat fmt, int mode)
if (fmt == fmt_unknown)
{
TString ext;
xvt_fsys_parse_pathname(path, NULL, NULL, NULL, ext.get_buffer(), NULL);
xvt_fsys_parse_pathname(path, nullptr, nullptr, nullptr, ext.get_buffer(), nullptr);
ext.lower();
if (ext == "htm" || ext == "html" || ext == "xml" || ext == "xls")
fmt = fmt_html;
@ -482,6 +482,48 @@ bool TRecordset::save_as(const char* path, TRecordsetExportFormat fmt, int mode)
return ok;
}
class TDummy_recordset : public TRecordset
{
virtual TRecnotype items() const { return 0L; }
virtual bool move_to(TRecnotype pos) { return false; }
virtual TRecnotype current_row() const { return 0L; }
virtual const TString& query_text() const { return EMPTY_STRING; }
virtual void requery() {}
virtual unsigned int columns() const { return 0; }
virtual const TRecordset_column_info& column_info(unsigned int column) const { return *((TRecordset_column_info*) nullptr); }
virtual const TVariant& get(unsigned int column) const { return TVariant(); }
public:
TDummy_recordset() {}
virtual ~TDummy_recordset() { }
};
const TString & get_custom_query(const char * module, const char * query_var, TString & query)
{
TDummy_recordset d;
return d.get_custom_query(module, query_var, query);
}
const TString & TRecordset::get_custom_query(const char * module, const char * query_var, TString & query)
{
TString mod(module);
TString var("Q");
if (mod.blank())
mod = dongle().in_module(query_var);
else
mod = mod.sleft(2);
var << module << query_var;
const TString custom_query = ini_get_string(CONFIG_DITTA, mod, var);
if (custom_query.full())
query = custom_query;
return query;
}
int TRecordset::find_column(const char* column_name) const
{
int i;
@ -519,7 +561,7 @@ const TVariant& TRecordset::get(const char* column_name) const
return get_var(column_name);
char* colon = (char*)strchr(column_name, ':'); //antica porcata
if (colon != NULL)
if (colon != nullptr)
{
*colon = '\0';
const int i = find_column(column_name);
@ -567,11 +609,11 @@ const TVariant& TRecordset::get_var(const char* name) const
const TVariant* var = (const TVariant*)_var.objptr(name);
// Non so che variabile sia: provo con quelle di sistema
if (var == NULL && *name == '#')
if (var == nullptr && *name == '#')
{
const TFixed_string n(name);
// Se mi accorgo che posso e voglio accedere ad un campo del recordset padre
if (_parentset != NULL && n.starts_with("#PARENT."))
if (_parentset != nullptr && n.starts_with("#PARENT."))
var = &_parentset->get(name+8); // Attenzione! E' giusto usare get() e non get_var()
else
{
@ -588,7 +630,7 @@ const TVariant& TRecordset::get_var(const char* name) const
}
}
}
return var != NULL ? *var : NULL_VARIANT;
return var != nullptr ? *var : NULL_VARIANT;
}
bool TRecordset::set_var(const char* name, const TVariant& var, bool create)
@ -628,7 +670,7 @@ bool is_var_separator(char c)
{
if (isspace(c))
return true;
return strchr("<=>+-*/(,.", c) != NULL;
return strchr("<=>+-*/(,.", c) != nullptr;
}
// Cerca le variabili nel testo SQL:
@ -647,7 +689,7 @@ void TRecordset::find_and_reset_vars()
{
int i = diesis+1;
for ( ; sql[i] && (isalnum(sql[i]) || strchr("@_.#", sql[i]) != NULL); i++);
for ( ; sql[i] && (isalnum(sql[i]) || strchr("@_.#", sql[i]) != nullptr); i++);
if (i > diesis+1)
{
const TString& name = sql.sub(diesis, i);
@ -759,7 +801,7 @@ bool TRecordset::ask_variables(bool all)
const TString& TRecordset::driver_version() const
{ return EMPTY_STRING; }
TRecordset::TRecordset() : _parentset(NULL), _text_separator('\t'), _disable_variables(false)
TRecordset::TRecordset() : _parentset(nullptr), _text_separator('\t'), _disable_variables(false)
{ }
///////////////////////////////////////////////////////////
@ -1298,7 +1340,7 @@ void TCursor_parser::parse_sortedjoin()
}
TCursor_parser::TCursor_parser(istream& instr, TArray& col)
: _instr(instr), _column(col), _relation(NULL), _cursor(NULL)
: _instr(instr), _column(col), _relation(nullptr), _cursor(nullptr)
{
_column.destroy();
const TString& tok = pop();
@ -1380,7 +1422,7 @@ TCursor_parser::TCursor_parser(istream& instr, TArray& col)
push();
if (_cursor == NULL)
if (_cursor == nullptr)
_cursor = new TCursor(_relation, "", key);
_relation->lfile().zero(); // Azzera correttamente tabelle normali e di modulo!
@ -1526,7 +1568,7 @@ const TVariant& TISAM_recordset::get_field(int logic, const char* fldname) const
const TVariant& TISAM_recordset::get(size_t c) const
{
const TRecordset_column_info* info = (const TRecordset_column_info*)_column.objptr(c);
if (info != NULL)
if (info != nullptr)
{
int logic = 0;
const char* field = info->_name;
@ -1574,7 +1616,7 @@ const TRecordset_column_info& TISAM_recordset::column_info(size_t i) const
TCursor* TISAM_recordset::cursor() const
{
if (_cursor == NULL && _use.full())
if (_cursor == nullptr && _use.full())
{
TString use; parsed_text(use);
TParagraph_string msg(use, 64);
@ -1587,7 +1629,7 @@ TCursor* TISAM_recordset::cursor() const
my->_relation = parser.get_relation();
my->_cursor = parser.get_cursor();
if (_cursor != NULL)
if (_cursor != nullptr)
{
set_custom_filter(*_cursor);
const TRecnotype items = _cursor->items();
@ -1609,13 +1651,13 @@ TRelation* TISAM_recordset::relation() const
TRecnotype TISAM_recordset::current_row() const
{
TCursor* c = cursor();
return c != NULL ? c->pos() : -1;
return c != nullptr ? c->pos() : -1;
}
TRecnotype TISAM_recordset::items() const
{
TCursor* c = cursor();
return c != NULL ? c->items() : 0;
return c != nullptr ? c->items() : 0;
}
unsigned int TISAM_recordset::columns() const
@ -1628,7 +1670,7 @@ unsigned int TISAM_recordset::columns() const
bool TISAM_recordset::move_to(TRecnotype pos)
{
TCursor* c = cursor();
bool ok = c != NULL && pos >= 0 && pos < c->items();
bool ok = c != nullptr && pos >= 0 && pos < c->items();
if (ok)
{
*c = pos;
@ -1650,8 +1692,11 @@ void TISAM_recordset::reset()
void TISAM_recordset::requery()
{
SAFE_DELETE(_cursor);
SAFE_DELETE(_relation);
if (_use.full())
{
safe_delete(_cursor);
safe_delete(_relation);
}
}
void TISAM_recordset::set(const char* use)
@ -1698,15 +1743,23 @@ TString& TISAM_recordset::add_between_filter(const TString& field, const TString
return ret;
}
TISAM_recordset::TISAM_recordset(const char* use)
: _relation(nullptr), _cursor(nullptr)
{
set(use);
TISAM_recordset::TISAM_recordset(const char* use)
: _relation(nullptr), _cursor(nullptr)
{
set(use);
}
TISAM_recordset::TISAM_recordset(TCursor & c)
: _relation(nullptr)
{
_cursor = new TCursor(c);
_relation = new TRelation(*_cursor->relation());
}
TISAM_recordset::~TISAM_recordset()
{
requery();
safe_delete(_cursor);
safe_delete(_relation);
}
///////////////////////////////////////////////////////////

View File

@ -59,6 +59,8 @@ public:
enum TRecordsetExportFormat { fmt_unknown, fmt_html, fmt_text, fmt_campo, fmt_dbf, fmt_as400, fmt_csv };
const TString & get_custom_query(const char * module, const char * query_var, TString & query);
class TRecordset : public TObject
{
TAssoc_array _var;
@ -138,6 +140,9 @@ public: // Absolutely needed methods
void set_parent(const TRecordset* rs) { _parentset = rs; }
const TString & get_custom_query(const char * module, const char * query_var, TString & query);
TRecordset();
virtual ~TRecordset() { }
};
@ -190,6 +195,7 @@ public:
static TString& add_between_filter(const TString& field, const TString& from_val, const TString& to_val, TString from_fld = "", TString to_fld = "");
TISAM_recordset(const char* use);
TISAM_recordset(TCursor & c);
virtual ~TISAM_recordset();
};