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:
parent
baa1e34d5c
commit
b90804fa24
@ -4132,23 +4132,15 @@ bool TRectype::set_creation_info()
|
||||
// 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();
|
||||
|
||||
_subfield = strchr(_name.get_buffer(), ':');
|
||||
if (_subfield != NULL)
|
||||
{
|
||||
*_subfield = '\0';
|
||||
_subfield++;
|
||||
strcat(_subfield, "=");
|
||||
}
|
||||
|
||||
const int nf = findfld(rd, _name);
|
||||
|
||||
if (nf == FIELDERR)
|
||||
{
|
||||
_subfield = _name;
|
||||
_sub_field = _name;
|
||||
_p = _rec->string();
|
||||
_len = 0;
|
||||
_dec = 0;
|
||||
@ -4164,7 +4156,7 @@ void TRecfield::set(int from, int to)
|
||||
_p = _rec->string() + rd->Fd[nf].RecOff;
|
||||
_dec = rd->Fd[nf].Dec;
|
||||
_type = (TFieldtypes)rd->Fd[nf].TypeF;
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
{
|
||||
_p += from;
|
||||
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)
|
||||
{
|
||||
_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;
|
||||
set(from, to);
|
||||
set_range(from, to);
|
||||
}
|
||||
|
||||
void TRecfield::put_subfield(const char* s)
|
||||
{
|
||||
if (_name == _subfield)
|
||||
if (_name == _sub_field)
|
||||
return;
|
||||
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] < ' '))
|
||||
{
|
||||
p += strlen(_subfield);
|
||||
p += _sub_field.len();
|
||||
|
||||
int e = str.find('\n', p);
|
||||
|
||||
@ -4230,7 +4232,7 @@ void TRecfield::put_subfield(const char* s)
|
||||
int TRecfield::operator =(int i)
|
||||
{
|
||||
TString16 buff; buff << i;
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num()));
|
||||
else
|
||||
put_subfield(buff);
|
||||
@ -4242,7 +4244,7 @@ int TRecfield::operator =(int i)
|
||||
long TRecfield::operator =(long l)
|
||||
{
|
||||
TString16 buff; buff << l;
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num()));
|
||||
else
|
||||
put_subfield(buff);
|
||||
@ -4253,7 +4255,7 @@ long TRecfield::operator =(long l)
|
||||
const real& TRecfield::operator =(const real& r)
|
||||
{
|
||||
const char* buff = r.string();
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num()));
|
||||
else
|
||||
put_subfield(buff);
|
||||
@ -4264,7 +4266,7 @@ const real& TRecfield::operator =(const real& r)
|
||||
const TDate& TRecfield::operator =(const TDate& d)
|
||||
{
|
||||
const TString16 buff = d.stringa();
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p, __file_is_crypted(_rec->num()));
|
||||
else
|
||||
put_subfield(buff);
|
||||
@ -4274,7 +4276,7 @@ const TDate& TRecfield::operator =(const TDate& d)
|
||||
|
||||
const char* TRecfield::operator =(const char* s)
|
||||
{
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
{
|
||||
if (_type == _memofld)
|
||||
_rec->put(_name, s);
|
||||
@ -4308,15 +4310,15 @@ void TRecfield::get_subfield(TString& s) const
|
||||
{
|
||||
const TString& str = _rec->get(_name);
|
||||
|
||||
if (_name == _subfield)
|
||||
if (_name == _sub_field)
|
||||
s = str;
|
||||
else
|
||||
{
|
||||
int p = str.find(_subfield);
|
||||
int p = str.find(_sub_field);
|
||||
|
||||
if (p == 0 || (p > 0 && str[p - 1] < ' '))
|
||||
{
|
||||
p += strlen(_subfield);
|
||||
p += _sub_field.len();
|
||||
|
||||
int e = str.find('\n', p);
|
||||
|
||||
@ -4336,7 +4338,7 @@ void TRecfield::get_subfield(TString& s) const
|
||||
TRecfield::operator int() const
|
||||
{
|
||||
TString16 tmp;
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
{
|
||||
if (_type == _intfld || _type == _intzerofld || _type == _longfld || _type == _longzerofld)
|
||||
{
|
||||
@ -4356,7 +4358,7 @@ TRecfield::operator long() const
|
||||
{
|
||||
TString16 tmp;
|
||||
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
{
|
||||
if (_type == _longfld || _type == _longzerofld || _type == _intfld || _type == _intzerofld)
|
||||
{
|
||||
@ -4377,7 +4379,7 @@ TRecfield::operator const real() const
|
||||
{
|
||||
TString80 tmp;
|
||||
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
{
|
||||
if (_type == _realfld)
|
||||
{
|
||||
@ -4390,8 +4392,7 @@ TRecfield::operator const real() const
|
||||
else
|
||||
get_subfield(tmp);
|
||||
|
||||
real r(tmp);
|
||||
return r;
|
||||
return real(tmp);
|
||||
}
|
||||
|
||||
|
||||
@ -4399,7 +4400,7 @@ TRecfield::operator TDate() const
|
||||
{
|
||||
TString16 tmp;
|
||||
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
{
|
||||
if (_type == _datefld)
|
||||
{
|
||||
@ -4420,7 +4421,7 @@ TRecfield::operator const char*() const
|
||||
{
|
||||
TString& tmp = get_tmp_string(max(_len, 50));
|
||||
|
||||
if (_subfield == NULL)
|
||||
if (_sub_field.empty())
|
||||
{
|
||||
if (_type == _memofld)
|
||||
return _rec->get(_name);
|
||||
|
@ -780,8 +780,8 @@ class TRecfield : public TObject
|
||||
|
||||
// @access:(INTERNAL) Private Member
|
||||
{
|
||||
// @cmember:(INTERNAL) Nome del campo
|
||||
TString80 _name;
|
||||
// @cmember:(INTERNAL) Nome del campo e sottocampo (Es. G1:TOTDOC)
|
||||
TString16 _name, _sub_field;
|
||||
// @cmember:(INTERNAL) Puntatore a inizio record
|
||||
TRectype* _rec;
|
||||
// @cmember:(INTERNAL) Puntatore a inizio campo
|
||||
@ -792,15 +792,13 @@ class TRecfield : public TObject
|
||||
byte _dec;
|
||||
// @cmember:(INTERNAL) Tipo del campo
|
||||
TFieldtypes _type;
|
||||
// @cmember:(INTERNAL) Sottocampo (Es. G1:TOTDOC)
|
||||
char* _subfield;
|
||||
// @cmember:(INTERNAL) Da per i sottocampi (Es. G1:TOTDOC[2,3])
|
||||
byte _from;
|
||||
// @cmember:(INTERNAL) A per i sottocampi (Es. G1:TOTDOC[2,3])
|
||||
byte _to;
|
||||
|
||||
// @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 put_subfield(const char * s);
|
||||
|
||||
|
@ -243,11 +243,10 @@ void TRelationdef::print_on(TToken_string& out) const
|
||||
const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to)
|
||||
{
|
||||
TExpression& expr = (TExpression&)_exprs[j];
|
||||
TString16 name;
|
||||
for (int k = 0; k < expr.numvar(); k++)
|
||||
{
|
||||
name = expr.varname(k); name.upper();
|
||||
expr.setvar(k, to.get(name));
|
||||
const TFieldref fr(expr.varname(k), to.num());
|
||||
expr.setvar(k, fr.read(to.curr()));
|
||||
}
|
||||
|
||||
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];
|
||||
for (int k = 0; k < expr.numvar(); k++)
|
||||
{
|
||||
name = altexpr.varname(k); name.upper();
|
||||
altexpr.setvar(k, to.get(name));
|
||||
const TFieldref fr(altexpr.varname(k), to.num());
|
||||
altexpr.setvar(k, fr.read(to.curr()));
|
||||
}
|
||||
val = (const char*)altexpr.as_string();
|
||||
}
|
||||
@ -2369,14 +2368,16 @@ const char* TFieldref::read(const TRectype& rec) const
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = _name; buffer.upper();
|
||||
/*buffer = _name; buffer.upper();
|
||||
buffer = rec.get(buffer);
|
||||
if (_from > 0 || _to > 0)
|
||||
{
|
||||
const int l = buffer.len();
|
||||
if (_to < l && _to > 0) buffer.cut(_to);
|
||||
if (_from > 0) buffer.ltrim(_from);
|
||||
}
|
||||
} */
|
||||
const TRecfield rf((TRectype&)rec, _name, _from, _to);
|
||||
buffer = rf;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user