Patch level : 2.2
Files correlati : cazzero Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@12553 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
10b647d216
commit
163fab4d7d
@ -1,5 +1,6 @@
|
||||
#include "calib01.h"
|
||||
|
||||
#include <tabutil.h>
|
||||
#include <tree.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -29,7 +30,7 @@ void TAnal_tree_pos::reset()
|
||||
|
||||
class TAnal_tree : public TBidirectional_tree
|
||||
{
|
||||
TLocalisamfile _file;
|
||||
TLocalisamfile* _file;
|
||||
const TArray& _key1_fields;
|
||||
const TArray& _key2_fields;
|
||||
|
||||
@ -61,7 +62,8 @@ protected:
|
||||
public:
|
||||
virtual bool goto_root();
|
||||
|
||||
TAnal_tree(int logicnum, const TArray& key1, const TArray& key2);
|
||||
TAnal_tree(int logicnum, const char* tabname, const TArray& key1, const TArray& key2);
|
||||
virtual ~TAnal_tree();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -188,7 +190,7 @@ short TAnal_msk::create_tree_field()
|
||||
id = F_TREE;
|
||||
add_tree(id, 0, 0, 1, delta*2, -1);
|
||||
|
||||
TAnal_tree* t = new TAnal_tree(get_logicnum(), _key1_fields, _key2_fields);
|
||||
TAnal_tree* t = new TAnal_tree(get_logicnum(), get_tabname(), _key1_fields, _key2_fields);
|
||||
tfield(id).set_tree(t);
|
||||
t->goto_root();
|
||||
t->expand();
|
||||
@ -261,7 +263,7 @@ const TToken_string& TAnal_msk::get_key_value(int c) const
|
||||
const TToken_string& TAnal_tree::curr_of_file() const
|
||||
{
|
||||
TToken_string& k = get_tmp_string();
|
||||
const TRectype& rec = _file.curr();
|
||||
const TRectype& rec = _file->curr();
|
||||
for (int i = 0; i < max_level(); i++)
|
||||
{
|
||||
const TFieldref& fld = (const TFieldref&)_key1_fields[i];
|
||||
@ -321,7 +323,7 @@ void TAnal_tree::update_curr()
|
||||
{
|
||||
_curr._key = curr_of_file();
|
||||
if (_curr._key.not_empty())
|
||||
_curr._recno = _file.recno();
|
||||
_curr._recno = _file->recno();
|
||||
else
|
||||
_curr.reset();
|
||||
}
|
||||
@ -331,7 +333,7 @@ bool TAnal_tree::repos() const
|
||||
bool ok = false;
|
||||
if (_curr.level() > 0)
|
||||
{
|
||||
if (_file.recno() != _curr._recno)
|
||||
if (_file->recno() != _curr._recno)
|
||||
ok = ((TLocalisamfile&)_file).readat(_curr._recno) == NOERR;
|
||||
else
|
||||
ok = true;
|
||||
@ -347,7 +349,7 @@ void TAnal_tree::node2id(const TObject* node, TString& id) const
|
||||
|
||||
bool TAnal_tree::goto_root()
|
||||
{
|
||||
const bool ok = _file.first() == NOERR;
|
||||
const bool ok = _file->first() == NOERR;
|
||||
if (ok)
|
||||
update_curr();
|
||||
else
|
||||
@ -360,7 +362,7 @@ bool TAnal_tree::goto_firstson()
|
||||
bool ok = _curr.level() < max_level() && repos();
|
||||
if (ok)
|
||||
{
|
||||
ok = _file.next() == NOERR;
|
||||
ok = _file->next() == NOERR;
|
||||
if (ok)
|
||||
{
|
||||
ok = father_of_file() == _curr._key;
|
||||
@ -377,7 +379,7 @@ bool TAnal_tree::goto_rbrother()
|
||||
if (repos())
|
||||
{
|
||||
const TToken_string curr_father = father_of(_curr._key);
|
||||
while (_file.next() == NOERR)
|
||||
while (_file->next() == NOERR)
|
||||
{
|
||||
const int lev = level_of_file();
|
||||
if (lev > _curr.level())
|
||||
@ -396,7 +398,7 @@ bool TAnal_tree::goto_rbrother()
|
||||
bool TAnal_tree::goto_node(const TString &id)
|
||||
{
|
||||
const TRecnotype rec = atol(id);
|
||||
const int err = _file.readat(rec);
|
||||
const int err = _file->readat(rec);
|
||||
|
||||
if (err == NOERR)
|
||||
update_curr();
|
||||
@ -410,7 +412,7 @@ bool TAnal_tree::goto_father()
|
||||
bool ok = lev > 1;
|
||||
if (ok)
|
||||
{
|
||||
TRectype& rec = _file.curr();
|
||||
TRectype& rec = _file->curr();
|
||||
rec.zero();
|
||||
|
||||
for (int i = 0; i < lev-1; i++)
|
||||
@ -419,7 +421,7 @@ bool TAnal_tree::goto_father()
|
||||
const TFieldref& fld = (const TFieldref&)_key1_fields[i];
|
||||
fld.write(val, rec);
|
||||
}
|
||||
ok = _file.read() == NOERR;
|
||||
ok = _file->read() == NOERR;
|
||||
if (ok)
|
||||
update_curr();
|
||||
}
|
||||
@ -432,7 +434,7 @@ bool TAnal_tree::goto_lbrother()
|
||||
if (repos())
|
||||
{
|
||||
const TString curr_father = father_of(_curr._key);
|
||||
while (_file.prev() == NOERR)
|
||||
while (_file->prev() == NOERR)
|
||||
{
|
||||
const int lev = level_of_file();
|
||||
if (lev > _curr.level())
|
||||
@ -463,16 +465,25 @@ bool TAnal_tree::get_description(TString& desc) const
|
||||
{
|
||||
const TFieldref& fld1 = (const TFieldref&)_key1_fields[lev-1];
|
||||
const TFieldref& fld2 = (const TFieldref&)_key2_fields[0];
|
||||
desc = fld1.read(_file.curr());
|
||||
desc << ' ' << fld2.read(_file.curr());
|
||||
desc = fld1.read(_file->curr());
|
||||
desc << ' ' << fld2.read(_file->curr());
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
TAnal_tree::TAnal_tree(int logicnum, const TArray& key1, const TArray& key2)
|
||||
: _file(logicnum), _key1_fields(key1), _key2_fields(key2)
|
||||
TAnal_tree::TAnal_tree(int logicnum, const char* tabname, const TArray& key1, const TArray& key2)
|
||||
: _key1_fields(key1), _key2_fields(key2)
|
||||
{
|
||||
if (tabname && *tabname)
|
||||
_file = new TTable(tabname);
|
||||
else
|
||||
_file = new TLocalisamfile(logicnum);
|
||||
}
|
||||
|
||||
TAnal_tree::~TAnal_tree()
|
||||
{
|
||||
delete _file;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -481,10 +492,12 @@ TAnal_tree::TAnal_tree(int logicnum, const TArray& key1, const TArray& key2)
|
||||
|
||||
const char* TSimple_anal_msk::get_key_fieldname(int k) const
|
||||
{
|
||||
const RecDes& rd = prefix().get_recdes(get_logicnum());
|
||||
const int logic = get_logicnum();
|
||||
const RecDes& rd = prefix().get_recdes(logic);
|
||||
CHECKD(k > 0 && k <= rd.NKeys, "Invalid key ", k);
|
||||
const KeyDes& ky = rd.Ky[k-1];
|
||||
const int pos = ky.FieldSeq[0] % MaxFields;
|
||||
const int idx = (logic == LF_TAB || logic == LF_TABCOM) ? 1 : 0;
|
||||
const int pos = ky.FieldSeq[idx] % MaxFields;
|
||||
return rd.Fd[pos].Name;
|
||||
}
|
||||
|
||||
@ -509,7 +522,14 @@ void TSimple_anal_msk::create_key_browse(TEdit_field& kfld, int level, TConfig&
|
||||
{
|
||||
TFilename tmp; tmp.temp();
|
||||
ofstream out(tmp);
|
||||
out << "US " << get_logicnum() << " KE 1";
|
||||
|
||||
const int logic = get_logicnum();
|
||||
out << "US ";
|
||||
if (logic == LF_TAB || logic == LF_TABCOM)
|
||||
out << '"' << get_tabname() << '"';
|
||||
else
|
||||
out << get_logicnum();
|
||||
out << " KE 1";
|
||||
append_select_clause(out, level);
|
||||
out << "KE 1" << endl;
|
||||
|
||||
@ -545,7 +565,13 @@ void TSimple_anal_msk::create_des_browse(TEdit_field& kfld, int level, TConfig&
|
||||
|
||||
TFilename tmp; tmp.temp();
|
||||
ofstream out(tmp);
|
||||
out << "US " << get_logicnum() << " KE 2";
|
||||
const int logic = get_logicnum();
|
||||
out << "US ";
|
||||
if (logic == LF_TAB || logic == LF_TABCOM)
|
||||
out << '"' << get_tabname() << '"';
|
||||
else
|
||||
out << get_logicnum();
|
||||
out << " KE 2";
|
||||
append_select_clause(out, level);
|
||||
out << "KE 2" << endl;
|
||||
out << "DI \"Descrizione@50\" " << key2 << endl;
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
int fieldrefs(int key = 1) const;
|
||||
|
||||
virtual int get_logicnum() const pure;
|
||||
virtual const char* get_tabname() const { return ""; }
|
||||
virtual short get_field_id(int n, int key = 1) const pure;
|
||||
|
||||
virtual const TToken_string& get_key_value(const TRectype& rec, int k = 1) const;
|
||||
@ -54,7 +55,7 @@ protected:
|
||||
virtual const char* get_key_var() const pure;
|
||||
virtual const char* get_des_var() const pure;
|
||||
const char* get_key_fieldname(int k) const;
|
||||
|
||||
|
||||
void append_select_clause(ostream& out, int level) const;
|
||||
void create_key_browse(TEdit_field& kfld, int level, TConfig& cfg);
|
||||
void create_des_browse(TEdit_field& kfld, int level, TConfig& cfg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user