Patch level : 12.0 no-patch
Files correlati : Commento : Aggiunte get_string(const char* field) get_string_zerofilled get_int get_long get_bool get_real get_date(const char* field) ai recordset zerofill alle stringhe
This commit is contained in:
parent
61f8fe1f76
commit
ba2c68bba4
@ -122,7 +122,11 @@ void fraction::build_fraction (const char *s)
|
||||
}
|
||||
}
|
||||
n.strip(",.-+/[]");
|
||||
#ifdef WIN32
|
||||
sscanf_s(n, "%I64d", &_num);
|
||||
#else
|
||||
sscanf_s(n, "%Ld", &_num);
|
||||
#endif
|
||||
if (len_periodo > 0)
|
||||
{
|
||||
_den = 9;
|
||||
|
@ -515,38 +515,51 @@ TVariant& TRecordset::get_tmp_var() const
|
||||
|
||||
const TVariant& TRecordset::get(const char* column_name) const
|
||||
{
|
||||
if (*column_name == '#')
|
||||
return get_var(column_name);
|
||||
if (*column_name == '#')
|
||||
return get_var(column_name);
|
||||
|
||||
char* colon = (char*)strchr(column_name, ':'); //antica porcata
|
||||
if (colon != NULL)
|
||||
{
|
||||
*colon = '\0';
|
||||
const int i = find_column(column_name);
|
||||
*colon = ':';
|
||||
if (i >= 0)
|
||||
{
|
||||
const TString& str = get(i).as_string();
|
||||
TString subfield; subfield << (colon+1) << '=';
|
||||
int s = str.find(subfield);
|
||||
if (s == 0 || (s > 0 && str[s-1] < ' '))
|
||||
{
|
||||
s += subfield.len();
|
||||
const int e = str.find('\n', s);
|
||||
TVariant& var = get_tmp_var();
|
||||
var.set(str.sub(s, e));
|
||||
return var;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const int i = find_column(column_name);
|
||||
if (i >= 0)
|
||||
return get(i);
|
||||
}
|
||||
char* colon = (char*)strchr(column_name, ':'); //antica porcata
|
||||
if (colon != NULL)
|
||||
{
|
||||
*colon = '\0';
|
||||
const int i = find_column(column_name);
|
||||
*colon = ':';
|
||||
if (i >= 0)
|
||||
{
|
||||
const TString& str = get(i).as_string();
|
||||
TString subfield; subfield << (colon + 1) << '=';
|
||||
int s = str.find(subfield);
|
||||
if (s == 0 || (s > 0 && str[s - 1] < ' '))
|
||||
{
|
||||
s += subfield.len();
|
||||
const int e = str.find('\n', s);
|
||||
TVariant& var = get_tmp_var();
|
||||
var.set(str.sub(s, e));
|
||||
return var;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const int i = find_column(column_name);
|
||||
if (i >= 0)
|
||||
return get(i);
|
||||
}
|
||||
|
||||
return NULL_VARIANT;
|
||||
return NULL_VARIANT;
|
||||
}
|
||||
|
||||
const TString& TRecordset::get_string_zerofilled(const char* field, const int zero_filled) const
|
||||
{
|
||||
if (zero_filled > 0)
|
||||
{
|
||||
TString & str = get_tmp_string(1024);
|
||||
|
||||
str = get_string(field);
|
||||
str.zerofill(zero_filled);
|
||||
return str;
|
||||
}
|
||||
return get_string(field);;
|
||||
}
|
||||
|
||||
const TVariant& TRecordset::get_var(const char* name) const
|
||||
|
@ -101,7 +101,15 @@ public: // Absolutely needed methods
|
||||
virtual unsigned int columns() const pure;
|
||||
virtual const TRecordset_column_info& column_info(unsigned int column) const pure;
|
||||
virtual const TRecordset_column_info& add_column_info(const TRecordset_column_info& c) {return c; }
|
||||
virtual const TVariant& get(unsigned int column) const pure;
|
||||
const TString& get_string(const char* field) const { return get(find_column(field)).as_string(); };
|
||||
const TString& get_string_zerofilled(const char* field, const int zero_filled) const;
|
||||
int get_int(const char* field) const { return get(find_column(field)).as_int(); }
|
||||
long get_long(const char* field) const { return get(find_column(field)).as_int(); }
|
||||
bool get_bool(const char* field) const { return get(find_column(field)).as_bool(); }
|
||||
real get_real(const char* field) const { return get(find_column(field)).as_real(); }
|
||||
TDate get_date(const char* field) const { return get(find_column(field)).as_date(); }
|
||||
|
||||
virtual const TVariant& get(unsigned int column) const pure;
|
||||
|
||||
virtual const TString_array& variables() const { return _varnames; }
|
||||
virtual const TVariant& get_var(const char* name) const;
|
||||
|
@ -183,6 +183,8 @@ public:
|
||||
TString& trim();
|
||||
// @cmember Aggiunge spazi a destra fino alla dimensione indicata
|
||||
TString& rpad(const int n,const char c=' ');
|
||||
// @cmember Aggiunge spazi a sinistra fino alla dimensione indicata
|
||||
TString & zerofill(const int n) { return lpad(n, '0'); }
|
||||
// @cmember Aggiunge spazi a sinistra fino alla dimensione indicata
|
||||
TString& lpad(const int n,const char c=' ');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user