Patch level :10.0 nuovo cd

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :corretti errori da riporto 3.2 e fatto funzionare il join con campi virtuali (prima parte)


git-svn-id: svn://10.65.10.50/trunk@17632 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2008-11-14 11:13:08 +00:00
parent baa1e34d5c
commit b90804fa24
3 changed files with 43 additions and 43 deletions

View File

@ -4132,23 +4132,15 @@ bool TRectype::set_creation_info()
// TRecfield (campo/sottocampo di un record) // TRecfield (campo/sottocampo di un record)
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
void TRecfield::set(int from, int to) void TRecfield::set_range(int from, int to)
{ {
const RecDes* rd = _rec->rec_des(); const RecDes* rd = _rec->rec_des();
_subfield = strchr(_name.get_buffer(), ':');
if (_subfield != NULL)
{
*_subfield = '\0';
_subfield++;
strcat(_subfield, "=");
}
const int nf = findfld(rd, _name); const int nf = findfld(rd, _name);
if (nf == FIELDERR) if (nf == FIELDERR)
{ {
_subfield = _name; _sub_field = _name;
_p = _rec->string(); _p = _rec->string();
_len = 0; _len = 0;
_dec = 0; _dec = 0;
@ -4164,7 +4156,7 @@ void TRecfield::set(int from, int to)
_p = _rec->string() + rd->Fd[nf].RecOff; _p = _rec->string() + rd->Fd[nf].RecOff;
_dec = rd->Fd[nf].Dec; _dec = rd->Fd[nf].Dec;
_type = (TFieldtypes)rd->Fd[nf].TypeF; _type = (TFieldtypes)rd->Fd[nf].TypeF;
if (_subfield == NULL) if (_sub_field.empty())
{ {
_p += from; _p += from;
if (to >= 0) if (to >= 0)
@ -4190,21 +4182,31 @@ void TRecfield::set(int from, int to)
TRecfield::TRecfield(TRectype& rec, const char* name, int from, int to) TRecfield::TRecfield(TRectype& rec, const char* name, int from, int to)
{ {
_name = name; const TFixed_string fname(name);
const int colon = fname.find(':');
if (colon > 0)
{
_name.strncpy(name, colon);
_sub_field = name+colon+1;
_sub_field << '='; // ???????????????
}
else
_name = name;
_rec = &rec; _rec = &rec;
set(from, to); set_range(from, to);
} }
void TRecfield::put_subfield(const char* s) void TRecfield::put_subfield(const char* s)
{ {
if (_name == _subfield) if (_name == _sub_field)
return; return;
const TString& str = _rec->get(_name); const TString& str = _rec->get(_name);
int p = str.find(_subfield); int p = str.find(_sub_field);
if (p == 0 || (p > 0 && str[p - 1] < ' ')) if (p == 0 || (p > 0 && str[p - 1] < ' '))
{ {
p += strlen(_subfield); p += _sub_field.len();
int e = str.find('\n', p); int e = str.find('\n', p);
@ -4230,7 +4232,7 @@ void TRecfield::put_subfield(const char* s)
int TRecfield::operator =(int i) int TRecfield::operator =(int i)
{ {
TString16 buff; buff << i; TString16 buff; buff << i;
if (_subfield == NULL) if (_sub_field.empty())
__putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num())); __putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num()));
else else
put_subfield(buff); put_subfield(buff);
@ -4242,7 +4244,7 @@ int TRecfield::operator =(int i)
long TRecfield::operator =(long l) long TRecfield::operator =(long l)
{ {
TString16 buff; buff << l; TString16 buff; buff << l;
if (_subfield == NULL) if (_sub_field.empty())
__putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num())); __putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num()));
else else
put_subfield(buff); put_subfield(buff);
@ -4253,7 +4255,7 @@ long TRecfield::operator =(long l)
const real& TRecfield::operator =(const real& r) const real& TRecfield::operator =(const real& r)
{ {
const char* buff = r.string(); const char* buff = r.string();
if (_subfield == NULL) if (_sub_field.empty())
__putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num())); __putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num()));
else else
put_subfield(buff); put_subfield(buff);
@ -4264,7 +4266,7 @@ const real& TRecfield::operator =(const real& r)
const TDate& TRecfield::operator =(const TDate& d) const TDate& TRecfield::operator =(const TDate& d)
{ {
const TString16 buff = d.stringa(); const TString16 buff = d.stringa();
if (_subfield == NULL) if (_sub_field.empty())
__putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num())); __putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num()));
else else
put_subfield(buff); put_subfield(buff);
@ -4274,7 +4276,7 @@ const TDate& TRecfield::operator =(const TDate& d)
const char* TRecfield::operator =(const char* s) const char* TRecfield::operator =(const char* s)
{ {
if (_subfield == NULL) if (_sub_field.empty())
{ {
if (_type == _memofld) if (_type == _memofld)
_rec->put(_name, s); _rec->put(_name, s);
@ -4308,15 +4310,15 @@ void TRecfield::get_subfield(TString& s) const
{ {
const TString& str = _rec->get(_name); const TString& str = _rec->get(_name);
if (_name == _subfield) if (_name == _sub_field)
s = str; s = str;
else else
{ {
int p = str.find(_subfield); int p = str.find(_sub_field);
if (p == 0 || (p > 0 && str[p - 1] < ' ')) if (p == 0 || (p > 0 && str[p - 1] < ' '))
{ {
p += strlen(_subfield); p += _sub_field.len();
int e = str.find('\n', p); int e = str.find('\n', p);
@ -4336,7 +4338,7 @@ void TRecfield::get_subfield(TString& s) const
TRecfield::operator int() const TRecfield::operator int() const
{ {
TString16 tmp; TString16 tmp;
if (_subfield == NULL) if (_sub_field.empty())
{ {
if (_type == _intfld || _type == _intzerofld || _type == _longfld || _type == _longzerofld) if (_type == _intfld || _type == _intzerofld || _type == _longfld || _type == _longzerofld)
{ {
@ -4356,7 +4358,7 @@ TRecfield::operator long() const
{ {
TString16 tmp; TString16 tmp;
if (_subfield == NULL) if (_sub_field.empty())
{ {
if (_type == _longfld || _type == _longzerofld || _type == _intfld || _type == _intzerofld) if (_type == _longfld || _type == _longzerofld || _type == _intfld || _type == _intzerofld)
{ {
@ -4377,7 +4379,7 @@ TRecfield::operator const real() const
{ {
TString80 tmp; TString80 tmp;
if (_subfield == NULL) if (_sub_field.empty())
{ {
if (_type == _realfld) if (_type == _realfld)
{ {
@ -4390,8 +4392,7 @@ TRecfield::operator const real() const
else else
get_subfield(tmp); get_subfield(tmp);
real r(tmp); return real(tmp);
return r;
} }
@ -4399,7 +4400,7 @@ TRecfield::operator TDate() const
{ {
TString16 tmp; TString16 tmp;
if (_subfield == NULL) if (_sub_field.empty())
{ {
if (_type == _datefld) if (_type == _datefld)
{ {
@ -4420,7 +4421,7 @@ TRecfield::operator const char*() const
{ {
TString& tmp = get_tmp_string(max(_len, 50)); TString& tmp = get_tmp_string(max(_len, 50));
if (_subfield == NULL) if (_sub_field.empty())
{ {
if (_type == _memofld) if (_type == _memofld)
return _rec->get(_name); return _rec->get(_name);

View File

@ -780,8 +780,8 @@ class TRecfield : public TObject
// @access:(INTERNAL) Private Member // @access:(INTERNAL) Private Member
{ {
// @cmember:(INTERNAL) Nome del campo // @cmember:(INTERNAL) Nome del campo e sottocampo (Es. G1:TOTDOC)
TString80 _name; TString16 _name, _sub_field;
// @cmember:(INTERNAL) Puntatore a inizio record // @cmember:(INTERNAL) Puntatore a inizio record
TRectype* _rec; TRectype* _rec;
// @cmember:(INTERNAL) Puntatore a inizio campo // @cmember:(INTERNAL) Puntatore a inizio campo
@ -792,15 +792,13 @@ class TRecfield : public TObject
byte _dec; byte _dec;
// @cmember:(INTERNAL) Tipo del campo // @cmember:(INTERNAL) Tipo del campo
TFieldtypes _type; TFieldtypes _type;
// @cmember:(INTERNAL) Sottocampo (Es. G1:TOTDOC)
char* _subfield;
// @cmember:(INTERNAL) Da per i sottocampi (Es. G1:TOTDOC[2,3]) // @cmember:(INTERNAL) Da per i sottocampi (Es. G1:TOTDOC[2,3])
byte _from; byte _from;
// @cmember:(INTERNAL) A per i sottocampi (Es. G1:TOTDOC[2,3]) // @cmember:(INTERNAL) A per i sottocampi (Es. G1:TOTDOC[2,3])
byte _to; byte _to;
// @cmember:(INTERNAL) Setta il campo <p to>-esimo con i valori di <p from>-esimo // @cmember:(INTERNAL) Setta il campo <p to>-esimo con i valori di <p from>-esimo
void set(int from, int to); void set_range(int from, int to);
void get_subfield(TString& s) const; void get_subfield(TString& s) const;
void put_subfield(const char * s); void put_subfield(const char * s);

View File

@ -243,11 +243,10 @@ void TRelationdef::print_on(TToken_string& out) const
const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to) const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to)
{ {
TExpression& expr = (TExpression&)_exprs[j]; TExpression& expr = (TExpression&)_exprs[j];
TString16 name;
for (int k = 0; k < expr.numvar(); k++) for (int k = 0; k < expr.numvar(); k++)
{ {
name = expr.varname(k); name.upper(); const TFieldref fr(expr.varname(k), to.num());
expr.setvar(k, to.get(name)); expr.setvar(k, fr.read(to.curr()));
} }
const char* val = (const char* )expr.as_string(); const char* val = (const char* )expr.as_string();
@ -257,8 +256,8 @@ const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to)
TExpression& altexpr = (TExpression&)_altexprs[j]; TExpression& altexpr = (TExpression&)_altexprs[j];
for (int k = 0; k < expr.numvar(); k++) for (int k = 0; k < expr.numvar(); k++)
{ {
name = altexpr.varname(k); name.upper(); const TFieldref fr(altexpr.varname(k), to.num());
altexpr.setvar(k, to.get(name)); altexpr.setvar(k, fr.read(to.curr()));
} }
val = (const char*)altexpr.as_string(); val = (const char*)altexpr.as_string();
} }
@ -2369,14 +2368,16 @@ const char* TFieldref::read(const TRectype& rec) const
} }
else else
{ {
buffer = _name; buffer.upper(); /*buffer = _name; buffer.upper();
buffer = rec.get(buffer); buffer = rec.get(buffer);
if (_from > 0 || _to > 0) if (_from > 0 || _to > 0)
{ {
const int l = buffer.len(); const int l = buffer.len();
if (_to < l && _to > 0) buffer.cut(_to); if (_to < l && _to > 0) buffer.cut(_to);
if (_from > 0) buffer.ltrim(_from); if (_from > 0) buffer.ltrim(_from);
} } */
const TRecfield rf((TRectype&)rec, _name, _from, _to);
buffer = rf;
} }
return buffer; return buffer;
} }