Gestita meglio la chiamata di programmi Windows in cascata
git-svn-id: svn://10.65.10.50/trunk@110 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
11cbb99740
commit
5e097d8630
@ -168,9 +168,10 @@ long TApplication::task_eh(WINDOW win, EVENT *ep)
|
||||
|
||||
void TApplication::about() const
|
||||
{
|
||||
#include <prassi.ver>
|
||||
#include <prassi.ver>
|
||||
const TFilename n(__argv[0]);
|
||||
message_box("PRASSI Versione %g\nProgramma %s\nLibreria del %s",
|
||||
VERSION, (const char*)name(), __DATE__);
|
||||
VERSION, (const char*)n.name(), __DATE__);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,93 +1,93 @@
|
||||
#ifndef __APPLICATION_H
|
||||
#define __APPLICATION_H
|
||||
|
||||
#ifndef INCL_XVTH
|
||||
#include <xvt.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
#ifndef __MODAUT_H
|
||||
//#include <modaut.h>
|
||||
#endif
|
||||
|
||||
// @C
|
||||
// Classe TApplication
|
||||
// @END
|
||||
|
||||
#define MSG_AI "AI" // message auto_insert (relapp)
|
||||
#define MSG_FS "FS" // message filtered start (relapp)
|
||||
#define MSG_LN "LN" // message (printapp -> relapp)
|
||||
|
||||
class TApplication
|
||||
{
|
||||
// @DPRIV
|
||||
int _bar;
|
||||
int __argc;
|
||||
const char** __argv;
|
||||
|
||||
TString _name;
|
||||
TPrinter* _printer;
|
||||
|
||||
protected:
|
||||
const char* get_module_name() const;
|
||||
static long task_eh(WINDOW win, EVENT* ep);
|
||||
|
||||
virtual long handler(WINDOW win, EVENT* ep);
|
||||
virtual bool extended_firm() const { return FALSE; } // Extended set_firm dialog box?
|
||||
|
||||
void terminate();
|
||||
bool config();
|
||||
void about() const;
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
|
||||
void setbar(int menubar) { _bar = menubar;} // Modifica la menu-bar
|
||||
void run(int argc, char* argv[], const char* name);
|
||||
|
||||
// @DES Queste funzioni possono essere ridefinite da ogni applicazione
|
||||
// @FPUB
|
||||
virtual bool create(); // Crea la finestra principale
|
||||
virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu
|
||||
virtual bool destroy(); // Rimuove l'applicazione
|
||||
virtual void print();
|
||||
void stop_run(); // Forza chiusura applicazione
|
||||
|
||||
void check_menu_item(MENU_TAG item); // Check menu
|
||||
void uncheck_menu_item(MENU_TAG item); // Uncheck
|
||||
void enable_menu_item(MENU_TAG item, bool on = TRUE);
|
||||
void disable_menu_item(MENU_TAG item) { enable_menu_item(item, FALSE); }
|
||||
void dispatch_e_menu(MENU_TAG item);
|
||||
|
||||
const char* name() const { return _name; }
|
||||
const char** argv() const { return __argv; }
|
||||
const char* argv(int i) const { return __argv[i]; }
|
||||
int argc() const { return __argc; }
|
||||
|
||||
void set_title(const char* t);
|
||||
const char* title() const;
|
||||
|
||||
void wait_for(const char* name);
|
||||
void wake_up_caller() const;
|
||||
|
||||
TPrinter* set_printer(TPrinter* p);
|
||||
TPrinter& printer();
|
||||
|
||||
virtual bool change_config(const char* var, const char* oldv, const char* newv);
|
||||
|
||||
bool has_module(int module) const;
|
||||
bool set_firm(long cod = -1);
|
||||
long get_firm() const;
|
||||
const char* get_firm_dir() const;
|
||||
|
||||
TApplication();
|
||||
virtual ~TApplication();
|
||||
};
|
||||
|
||||
bool xvt_running(); // xvt is running?
|
||||
TApplication* MainApp(); // main application
|
||||
|
||||
#endif // __APPLICATION_H
|
||||
#ifndef __APPLICATION_H
|
||||
#define __APPLICATION_H
|
||||
|
||||
#ifndef INCL_XVTH
|
||||
#include <xvt.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
#ifndef __MODAUT_H
|
||||
//#include <modaut.h>
|
||||
#endif
|
||||
|
||||
// @C
|
||||
// Classe TApplication
|
||||
// @END
|
||||
|
||||
#define MSG_AI "AI" // message auto_insert (relapp)
|
||||
#define MSG_FS "FS" // message filtered start (relapp)
|
||||
#define MSG_LN "LN" // message (printapp -> relapp)
|
||||
|
||||
class TApplication
|
||||
{
|
||||
// @DPRIV
|
||||
int _bar;
|
||||
int __argc;
|
||||
const char** __argv;
|
||||
|
||||
TString _name;
|
||||
TPrinter* _printer;
|
||||
|
||||
protected:
|
||||
const char* get_module_name() const;
|
||||
static long task_eh(WINDOW win, EVENT* ep);
|
||||
|
||||
virtual long handler(WINDOW win, EVENT* ep);
|
||||
virtual bool extended_firm() const { return FALSE; } // Extended set_firm dialog box?
|
||||
|
||||
void terminate();
|
||||
bool config();
|
||||
void about() const;
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
|
||||
void setbar(int menubar) { _bar = menubar;} // Modifica la menu-bar
|
||||
void run(int argc, char* argv[], const char* name);
|
||||
|
||||
// @DES Queste funzioni possono essere ridefinite da ogni applicazione
|
||||
// @FPUB
|
||||
virtual bool create(); // Crea la finestra principale
|
||||
virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu
|
||||
virtual bool destroy(); // Rimuove l'applicazione
|
||||
virtual void print();
|
||||
void stop_run(); // Forza chiusura applicazione
|
||||
|
||||
void check_menu_item(MENU_TAG item); // Check menu
|
||||
void uncheck_menu_item(MENU_TAG item); // Uncheck
|
||||
void enable_menu_item(MENU_TAG item, bool on = TRUE);
|
||||
void disable_menu_item(MENU_TAG item) { enable_menu_item(item, FALSE); }
|
||||
void dispatch_e_menu(MENU_TAG item);
|
||||
|
||||
const TString& name() const { return _name; }
|
||||
const char** argv() const { return __argv; }
|
||||
const char* argv(int i) const { return __argv[i]; }
|
||||
int argc() const { return __argc; }
|
||||
|
||||
void set_title(const char* t);
|
||||
const char* title() const;
|
||||
|
||||
void wait_for(const char* name);
|
||||
void wake_up_caller() const;
|
||||
|
||||
TPrinter* set_printer(TPrinter* p);
|
||||
TPrinter& printer();
|
||||
|
||||
virtual bool change_config(const char* var, const char* oldv, const char* newv);
|
||||
|
||||
bool has_module(int module) const;
|
||||
bool set_firm(long cod = -1);
|
||||
long get_firm() const;
|
||||
const char* get_firm_dir() const;
|
||||
|
||||
TApplication();
|
||||
virtual ~TApplication();
|
||||
};
|
||||
|
||||
bool xvt_running(); // xvt is running?
|
||||
TApplication* MainApp(); // main application
|
||||
|
||||
#endif // __APPLICATION_H
|
||||
|
2136
include/form.cpp
2136
include/form.cpp
File diff suppressed because it is too large
Load Diff
159
include/form.h
159
include/form.h
@ -1,79 +1,80 @@
|
||||
#ifndef __FORM_H
|
||||
#define __FORM_H
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
#ifndef __RELATION_H
|
||||
class TRelation;
|
||||
class TCursor;
|
||||
#endif
|
||||
|
||||
#ifndef __SCANNER_H
|
||||
#include <scanner.h>
|
||||
#endif
|
||||
|
||||
class TForm;
|
||||
class TForm_item;
|
||||
|
||||
class TPrint_section : public TArray
|
||||
{
|
||||
TString _name;
|
||||
int _heigth;
|
||||
|
||||
TForm* _form;
|
||||
TArray _item;
|
||||
|
||||
protected:
|
||||
virtual void print_on(ostream& out) const;
|
||||
TForm_item* parse_item(TScanner& scanner);
|
||||
|
||||
public:
|
||||
TPrintrow& row(int num);
|
||||
TForm* form() const { return _form; }
|
||||
|
||||
TForm_item* item(int n) const { return (TForm_item*)_item.objptr(n); }
|
||||
int items() const { return _item.items(); }
|
||||
|
||||
bool update();
|
||||
bool parse(TScanner& scanner);
|
||||
|
||||
bool edit(int mode);
|
||||
|
||||
TPrint_section(const char* name, TForm* f);
|
||||
};
|
||||
|
||||
|
||||
class TForm : public TObject
|
||||
{
|
||||
TFilename _name;
|
||||
|
||||
TRelation* _relation;
|
||||
TCursor* _cursor;
|
||||
|
||||
TPrint_section _head;
|
||||
TPrint_section _body;
|
||||
TPrint_section _foot;
|
||||
|
||||
protected:
|
||||
virtual void print_on(ostream& out) const;
|
||||
|
||||
bool parse_use(TScanner&);
|
||||
bool parse_join(TScanner&);
|
||||
|
||||
bool set_header();
|
||||
bool set_footer();
|
||||
|
||||
public:
|
||||
bool print(long from = 0L, long to = -1L);
|
||||
TRelation* relation() const { return _relation; }
|
||||
TCursor* cursor() const { return _cursor; }
|
||||
|
||||
bool edit(int mode, int section = 1);
|
||||
|
||||
TForm(const char* form);
|
||||
~TForm();
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef __FORM_H
|
||||
#define __FORM_H
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
#ifndef __RELATION_H
|
||||
class TRelation;
|
||||
class TCursor;
|
||||
#endif
|
||||
|
||||
#ifndef __SCANNER_H
|
||||
#include <scanner.h>
|
||||
#endif
|
||||
|
||||
class TForm;
|
||||
class TForm_item;
|
||||
|
||||
class TPrint_section : public TArray
|
||||
{
|
||||
TString16 _name;
|
||||
int _heigth;
|
||||
|
||||
TForm* _form;
|
||||
TArray _item;
|
||||
|
||||
protected:
|
||||
virtual void print_on(ostream& out) const;
|
||||
TForm_item* parse_item(TScanner& scanner);
|
||||
|
||||
public:
|
||||
TPrintrow& row(int num);
|
||||
TForm* form() const { return _form; }
|
||||
|
||||
TForm_item* item(int n) const { return (TForm_item*)_item.objptr(n); }
|
||||
int items() const { return _item.items(); }
|
||||
|
||||
bool update();
|
||||
bool parse(TScanner& scanner);
|
||||
|
||||
bool edit(int mode);
|
||||
|
||||
TPrint_section(const char* name = "", TForm* form = NULL);
|
||||
void init(const char* name, TForm* form);
|
||||
};
|
||||
|
||||
|
||||
class TForm : public TObject
|
||||
{
|
||||
TFilename _name;
|
||||
|
||||
TRelation* _relation;
|
||||
TCursor* _cursor;
|
||||
|
||||
TPrint_section _head;
|
||||
TPrint_section _body;
|
||||
TPrint_section _foot;
|
||||
|
||||
protected:
|
||||
virtual void print_on(ostream& out) const;
|
||||
|
||||
bool parse_use(TScanner&);
|
||||
bool parse_join(TScanner&);
|
||||
|
||||
bool set_header();
|
||||
bool set_footer();
|
||||
|
||||
public:
|
||||
bool print(long from = 0L, long to = -1L);
|
||||
TRelation* relation() const { return _relation; }
|
||||
TCursor* cursor() const { return _cursor; }
|
||||
|
||||
bool edit(int mode, int section = 1);
|
||||
|
||||
TForm(const char* form);
|
||||
~TForm();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
// $Id: maskfld.cpp,v 1.9 1994-08-30 14:40:25 guy Exp $
|
||||
// $Id: maskfld.cpp,v 1.10 1994-08-31 12:20:32 guy Exp $
|
||||
#include <xvt.h>
|
||||
|
||||
#include <applicat.h>
|
||||
@ -597,7 +597,7 @@ bool TMask_field::do_message(int num)
|
||||
if (value != prev)
|
||||
{
|
||||
f.set(value);
|
||||
if (f.showed())
|
||||
if (f.showed() || f.ghost())
|
||||
f.on_hit();
|
||||
}
|
||||
}
|
||||
@ -1240,7 +1240,8 @@ bool TBrowse::do_insert()
|
||||
{
|
||||
app = _insert.mid(1);
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
app.insert("a", 3);
|
||||
if (strnicmp(app, MainApp()->name(), 3) == 0)
|
||||
app.insert("a", 3);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ class TSpreadsheet : public TWindow
|
||||
int _columns;
|
||||
bool _dirty;
|
||||
|
||||
XI_OBJ *_list;
|
||||
XI_OBJ *_list, *_itf;
|
||||
|
||||
SPREADSHEET_NOTIFY _notify;
|
||||
|
||||
@ -217,8 +217,8 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
|
||||
xi_create(NULL, itfdef);
|
||||
xi_tree_free(itfdef);
|
||||
|
||||
XI_OBJ* itf = xi_get_itf(win);
|
||||
_list = xi_get_obj(itf, LIST_CID);
|
||||
_itf = xi_get_itf(win);
|
||||
_list = xi_get_obj(_itf, LIST_CID);
|
||||
}
|
||||
|
||||
|
||||
@ -337,8 +337,6 @@ void TSpreadsheet::update(int row)
|
||||
{
|
||||
xi_cell_request(_list); // Force updatde
|
||||
xi_scroll(_list, XI_SCROLL_FIRST);
|
||||
XI_OBJ* itf = xi_get_itf(win()); // Remove focus
|
||||
xi_move_focus(itf);
|
||||
set_front_window(win()); // Seems necessary
|
||||
}
|
||||
else
|
||||
@ -468,6 +466,7 @@ if (xiev->v.xi_obj->type == XIT_LIST)
|
||||
}
|
||||
break;
|
||||
case XIE_ON_ROW:
|
||||
if (_check_enabled)
|
||||
{
|
||||
const int rec = row2rec(xiev->v.xi_obj->v.row);
|
||||
if (rec < items())
|
||||
@ -487,7 +486,7 @@ break;
|
||||
str2mask(_cur_row); // It shouldn't have to be necessary
|
||||
bool ok = _mask.check_fields();
|
||||
if (ok)
|
||||
{
|
||||
{
|
||||
mask2str(_cur_row);
|
||||
ok = notify(_cur_row, K_ENTER); // Notify edit
|
||||
}
|
||||
@ -505,6 +504,7 @@ break;
|
||||
}
|
||||
break;
|
||||
case XIE_ON_CELL:
|
||||
if (_check_enabled)
|
||||
{
|
||||
TMask_field* f = cell2field(xiev->v.xi_obj);
|
||||
const int col = (f->dlg() - FIRST_FIELD) % 100;
|
||||
@ -512,22 +512,15 @@ break;
|
||||
{
|
||||
_edit_field = f;
|
||||
_cur_col = xiev->v.xi_obj->v.cell.column;
|
||||
_check_enabled = FALSE;
|
||||
xi_set_focus(_itf);
|
||||
xi_set_color(xiev->v.xi_obj, XIC_BACK, FOCUS_BACK_COLOR);
|
||||
xi_set_focus(xiev->v.xi_obj);
|
||||
_check_enabled = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
xiev->refused = TRUE; // Refuse focus on disabled cells
|
||||
/*
|
||||
const int r = xiev->v.xi_obj->v.cell.row;
|
||||
int c = xiev->v.xi_obj->v.cell.column;
|
||||
c += cur_col > col ? -1 : +1;
|
||||
if (c < 1) c = _columns-1; else
|
||||
if (c >= _columns) c = 1;
|
||||
|
||||
XI_OBJ cell;
|
||||
XI_MAKE_CELL(&cell, _list, r, c);
|
||||
xi_move_focus(&cell);
|
||||
*/
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -581,8 +574,7 @@ break;
|
||||
case E_FOCUS:
|
||||
if (ep->v.active == FALSE)
|
||||
{
|
||||
XI_OBJ* itf = xi_get_itf(win());
|
||||
const bool ok = (bool)xi_move_focus(itf);
|
||||
const bool ok = (bool)xi_move_focus(_itf);
|
||||
if (!ok)
|
||||
{
|
||||
set_dirty(2);
|
||||
@ -621,8 +613,7 @@ break;
|
||||
case K_PREV:
|
||||
case K_NEXT:
|
||||
{
|
||||
XI_OBJ* itf = xi_get_itf(win());
|
||||
const bool ok = (bool)xi_move_focus(itf);
|
||||
const bool ok = (bool)xi_move_focus(_itf);
|
||||
if (ok) dispatch_e_char(parent(), k);
|
||||
}
|
||||
break;
|
||||
|
@ -713,6 +713,13 @@ const char* TToken_string::get(int n)
|
||||
}
|
||||
|
||||
|
||||
// Certified 99%
|
||||
char TToken_string::get_char(int n)
|
||||
{
|
||||
const char* num = get(n);
|
||||
return num ? *num : '\0';
|
||||
}
|
||||
|
||||
// Certified 99%
|
||||
int TToken_string::get_int(int n)
|
||||
{
|
||||
|
@ -1,268 +1,269 @@
|
||||
#ifndef __STRINGS_H
|
||||
#define __STRINGS_H
|
||||
|
||||
#ifndef __STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef __OBJECT_H
|
||||
#include <object.h>
|
||||
#endif
|
||||
|
||||
// @C
|
||||
// Classe TString : public TObject
|
||||
// @END
|
||||
|
||||
class TString : public TObject
|
||||
{
|
||||
protected:
|
||||
// @DPROT
|
||||
char* _str; // Puntatore alla stringa
|
||||
int _size; // Lunghezza
|
||||
// @END
|
||||
|
||||
// @FPROT
|
||||
int make_room(int size); // Cerca spazio per altri size caratteri
|
||||
TString& set(const char*); // Inizializza con la stringa puntata da char* di lunghezza size
|
||||
|
||||
TString(char* str, int size) : _str(str), _size(size) {}
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
virtual void resize(int size, bool cpy); // Ri/alloca la stringa
|
||||
|
||||
TString();
|
||||
TString(int size); // Default constructor for a string of given size
|
||||
TString(const char* s); // Costruttore a partire da una stringa s
|
||||
TString(const TString& s); // Costruttore da un oggetto TString s
|
||||
virtual ~TString(); // Deallocates the string
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// @DES Methods derived from TObject
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// @FPUB
|
||||
virtual const char* class_name() const; // Ritorna il nome della classe
|
||||
virtual word class_id() const; // Ritorna l'identificatore della classe
|
||||
virtual bool ok() const { return _str != NULL; }
|
||||
virtual TObject* dup() const;
|
||||
virtual void print_on(ostream& out) const;
|
||||
virtual void read_from(istream& in);
|
||||
virtual word hash() const; // Return hash value
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// @DES Query methods
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// @FPUB
|
||||
operator const char*() const { return (const char*)_str; } // *(TString) -> _str
|
||||
char& operator[](int i) const { return _str[i]; } // TString[i] -> _str[i]
|
||||
|
||||
int size() const { return _size; }
|
||||
int len() const { return strlen(_str); }
|
||||
bool empty() const { return *_str == '\0'; }
|
||||
bool not_empty() const { return *_str != '\0'; }
|
||||
|
||||
int find(char, int from = 0) const; // Ritorna la posizione del carattere char nell'oggetto TString
|
||||
int find(const char* s, int from = 0) const; // Ritorna la posizione della stringa s nell'oggetto TString
|
||||
|
||||
const char* left(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da sinistra
|
||||
const char* mid(int from, int count = -1) const; // Ritorna l'oggetto TString composto dai count caratteri a partire da from
|
||||
const char* sub(int from, int to = -1) const; // Ritorna la stringa da FROM a TO (escluso)
|
||||
const char* right(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da destra
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// @DES Modifying methods
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// @FPUB
|
||||
TString& fill(char c, int n = -1); // Riempie con n caratteri c
|
||||
TString& spaces(int n = -1) { return fill(' ', n); }
|
||||
TString& overwrite(const char* s, int pos = 0); // Sovrascrive la stringa s dalla posizione pos
|
||||
TString& insert(const char* s, int pos = 0); // Inserisce la stringa s dalla posizione pos
|
||||
|
||||
TString& strip(const char* k); // Elimina tutti i caratteri contenuti in k
|
||||
TString& strip_spaces(); // Elimina tutti gli spazi non contenuti tra apici singoli o doppi
|
||||
TString& ltrim(int n = 0); // Elimina gli spazi da sinistra se n=0 altrimenti elimina i primi n caratteri (da sinistra).
|
||||
TString& rtrim(int n = 0); // Elimina gli spazi da destra se n=0 altrimenti elimina i primi n caratteri (da destra).
|
||||
TString& trim(); // ltrim e rtrim
|
||||
|
||||
TString& right_just(int n = -1, char c = ' '); // Giustifica a destra
|
||||
TString& center_just(int n = -1, char c = ' '); // Centra
|
||||
TString& left_just(int n = -1, char c = ' '); // Giustifica a sinistra
|
||||
|
||||
TString& picture(const char* pic, const char* s);
|
||||
TString& format(const char* fmt, ...);
|
||||
|
||||
TString& cut(int n); // Inserisce un '\0' alla posizione n-esima.
|
||||
|
||||
TString& upper(); // Mette la stringa in maiuscolo
|
||||
TString& lower(); // Mette la stringa in minuscolo
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// @DES Standard operators
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// @FPUB
|
||||
const TString& operator =(const TString& s) { return set(s._str); }
|
||||
const TString& operator =(const char* s) { return set(s); }
|
||||
|
||||
TString& operator <<(const char*);
|
||||
TString& operator <<(char);
|
||||
TString& operator <<(int);
|
||||
TString& operator <<(long);
|
||||
TString& operator <<(double);
|
||||
TString& operator <<(const TObject& obj);
|
||||
TString& operator <<(const TString& str); // For efficiency only
|
||||
|
||||
bool operator ==(const char* s) const { return strcmp(_str, s) == 0; }
|
||||
bool operator ==(char* s) const { return strcmp(_str, s) == 0; }
|
||||
bool operator ==(const TString& s) const { return strcmp(_str, s._str) == 0; }
|
||||
bool operator !=(const char* s) const { return strcmp(_str, s) != 0; }
|
||||
bool operator !=(char* s) const { return strcmp(_str, s) != 0; }
|
||||
bool operator !=(const TString& s) const { return strcmp(_str, s._str) != 0; }
|
||||
bool operator <(const char* s) const { return strcmp(_str, s) < 0; }
|
||||
bool operator >(const char* s) const { return strcmp(_str, s) > 0; }
|
||||
bool operator >=(const char* s) const { return strcmp(_str, s) >= 0; }
|
||||
bool operator <=(const char* s) const { return strcmp(_str, s) <= 0; }
|
||||
bool match(const char* s) const;
|
||||
bool compare(const char* s, int max = -1, bool ignorecase = FALSE) const;
|
||||
};
|
||||
|
||||
// @C
|
||||
// Classe TFixed_string : public TString
|
||||
// @END
|
||||
|
||||
class TFixed_string : public TString
|
||||
{
|
||||
protected:
|
||||
virtual void resize(int size, bool cpy); // Causa un errore fatale!
|
||||
|
||||
public:
|
||||
TFixed_string(const char* str, int size = -1);
|
||||
virtual ~TFixed_string();
|
||||
|
||||
const TString& operator =(const TString& s) { return set((const char*)s); }
|
||||
const TString& operator=(const char* s) { return set(s); }
|
||||
|
||||
void strncpy(const char* s, int n);
|
||||
};
|
||||
|
||||
class TString16 : public TFixed_string
|
||||
{
|
||||
char _str16[17];
|
||||
|
||||
public:
|
||||
TString16(const char* str = "") : TFixed_string(_str16, 17) { set(str); }
|
||||
const TString& operator =(const TString& s) { return set((const char*)s); }
|
||||
const TString& operator=(const char* s) { return set(s); }
|
||||
};
|
||||
|
||||
class TString80 : public TFixed_string
|
||||
{
|
||||
char _str80[81];
|
||||
|
||||
public:
|
||||
TString80(const char* str = "") : TFixed_string(_str80, 81) { set(str); }
|
||||
const TString& operator =(const TString& s) { return set((const char*)s); }
|
||||
const TString& operator=(const char* s) { return set(s); }
|
||||
};
|
||||
|
||||
class TString256 : public TFixed_string
|
||||
{
|
||||
char _str256[257];
|
||||
|
||||
public:
|
||||
TString256(const char* str = "") : TFixed_string(_str256, 257) { set(str); }
|
||||
const TString& operator =(const TString& s) { return set((const char*)s); }
|
||||
const TString& operator=(const char* s) { return set(s); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
// @C
|
||||
// Classe TFilename : public TString
|
||||
// @END
|
||||
|
||||
class TFilename : public TString
|
||||
{
|
||||
public:
|
||||
// @FPUB
|
||||
|
||||
TFilename(const char* n = "") : TString(24) { set(n); }
|
||||
|
||||
const TString& operator =(const char* s) { return set(s); }
|
||||
// assegnazione tra TFile e stringa
|
||||
|
||||
const char* ext() const; // Ritorna l'estensione
|
||||
void ext(const char*); // Imposta come estensione la stringa puntata da char*
|
||||
|
||||
const char* name() const; // Ritorna il nome del file
|
||||
TString& temp(const char* prefix = NULL); // Genera il nome di un file temporaneo
|
||||
TString& tempdir(); // Genera il nome della directory temporanea
|
||||
};
|
||||
|
||||
// @C
|
||||
// Classe TToken_string : public TString
|
||||
// @END
|
||||
|
||||
class TToken_string : public TString
|
||||
{
|
||||
// @DPRIV
|
||||
char _separator; // Carattere separatore
|
||||
int _last; // Puntatore all'ultimo
|
||||
|
||||
protected:
|
||||
// @FPROT
|
||||
|
||||
TObject* dup() const; // Crea un duplicato della token string
|
||||
bool set_item(const char* v, int n);
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
TToken_string(const char* = "", char separator = '|');
|
||||
TToken_string(int n, char separator = '|');
|
||||
TToken_string(const TToken_string& s);
|
||||
|
||||
void separator(char s) { _separator = s; } // Setta il separatore a s
|
||||
|
||||
void restart() { _last = empty() ? -1 : 0; } // Rimette all'inizio il puntatore
|
||||
const TString& operator =(const char* s) { set(s);restart();return *this; }
|
||||
const TString& operator =(const TString& s) { set(s);restart();return *this; }
|
||||
|
||||
void add(const char* s, int n = -1); // Aggiunge un token
|
||||
void add(char c, int pos = -1); // Aggiunge un char
|
||||
void add(long n, int pos = -1); // Aggiunge un intero
|
||||
void add(int n, int pos = -1); // Aggiunge un intero
|
||||
void destroy(int pos); // Toglie il token pos
|
||||
const char* get(); // Ritorna il prossimo token
|
||||
const char* get(int n); // Ritorna un token (-1 = prossimo; -2 = ultimo; n = ennesimo)
|
||||
int get_int(int n = -1); // Ritorna un intero
|
||||
long get_long(int n = -1); // Ritorna un intero esteso
|
||||
int get_pos(const char* s); // Ritorna la posizione dell'item s
|
||||
int items() const; // Ritorna il numero di token presenti
|
||||
bool empty_items() const; // Controlla se tutti i token sono nulli
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// @DES Paragraph
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TParagraph_string : public TToken_string
|
||||
{
|
||||
int _width;
|
||||
bool _fixed;
|
||||
|
||||
protected:
|
||||
void tokenize();
|
||||
|
||||
public:
|
||||
TParagraph_string(const char* s, int width);
|
||||
const TString& operator =(const char* s);
|
||||
void set_width(int width) { _width = width; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#define __STRINGS_H
|
||||
|
||||
#ifndef __STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef __OBJECT_H
|
||||
#include <object.h>
|
||||
#endif
|
||||
|
||||
// @C
|
||||
// Classe TString : public TObject
|
||||
// @END
|
||||
|
||||
class TString : public TObject
|
||||
{
|
||||
protected:
|
||||
// @DPROT
|
||||
char* _str; // Puntatore alla stringa
|
||||
int _size; // Lunghezza
|
||||
// @END
|
||||
|
||||
// @FPROT
|
||||
int make_room(int size); // Cerca spazio per altri size caratteri
|
||||
TString& set(const char*); // Inizializza con la stringa puntata da char* di lunghezza size
|
||||
|
||||
TString(char* str, int size) : _str(str), _size(size) {}
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
virtual void resize(int size, bool cpy); // Ri/alloca la stringa
|
||||
|
||||
TString();
|
||||
TString(int size); // Default constructor for a string of given size
|
||||
TString(const char* s); // Costruttore a partire da una stringa s
|
||||
TString(const TString& s); // Costruttore da un oggetto TString s
|
||||
virtual ~TString(); // Deallocates the string
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// @DES Methods derived from TObject
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// @FPUB
|
||||
virtual const char* class_name() const; // Ritorna il nome della classe
|
||||
virtual word class_id() const; // Ritorna l'identificatore della classe
|
||||
virtual bool ok() const { return _str != NULL; }
|
||||
virtual TObject* dup() const;
|
||||
virtual void print_on(ostream& out) const;
|
||||
virtual void read_from(istream& in);
|
||||
virtual word hash() const; // Return hash value
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// @DES Query methods
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// @FPUB
|
||||
operator const char*() const { return (const char*)_str; } // *(TString) -> _str
|
||||
char& operator[](int i) const { return _str[i]; } // TString[i] -> _str[i]
|
||||
|
||||
int size() const { return _size; }
|
||||
int len() const { return strlen(_str); }
|
||||
bool empty() const { return *_str == '\0'; }
|
||||
bool not_empty() const { return *_str != '\0'; }
|
||||
|
||||
int find(char, int from = 0) const; // Ritorna la posizione del carattere char nell'oggetto TString
|
||||
int find(const char* s, int from = 0) const; // Ritorna la posizione della stringa s nell'oggetto TString
|
||||
|
||||
const char* left(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da sinistra
|
||||
const char* mid(int from, int count = -1) const; // Ritorna l'oggetto TString composto dai count caratteri a partire da from
|
||||
const char* sub(int from, int to = -1) const; // Ritorna la stringa da FROM a TO (escluso)
|
||||
const char* right(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da destra
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// @DES Modifying methods
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// @FPUB
|
||||
TString& fill(char c, int n = -1); // Riempie con n caratteri c
|
||||
TString& spaces(int n = -1) { return fill(' ', n); }
|
||||
TString& overwrite(const char* s, int pos = 0); // Sovrascrive la stringa s dalla posizione pos
|
||||
TString& insert(const char* s, int pos = 0); // Inserisce la stringa s dalla posizione pos
|
||||
|
||||
TString& strip(const char* k); // Elimina tutti i caratteri contenuti in k
|
||||
TString& strip_spaces(); // Elimina tutti gli spazi non contenuti tra apici singoli o doppi
|
||||
TString& ltrim(int n = 0); // Elimina gli spazi da sinistra se n=0 altrimenti elimina i primi n caratteri (da sinistra).
|
||||
TString& rtrim(int n = 0); // Elimina gli spazi da destra se n=0 altrimenti elimina i primi n caratteri (da destra).
|
||||
TString& trim(); // ltrim e rtrim
|
||||
|
||||
TString& right_just(int n = -1, char c = ' '); // Giustifica a destra
|
||||
TString& center_just(int n = -1, char c = ' '); // Centra
|
||||
TString& left_just(int n = -1, char c = ' '); // Giustifica a sinistra
|
||||
|
||||
TString& picture(const char* pic, const char* s);
|
||||
TString& format(const char* fmt, ...);
|
||||
|
||||
TString& cut(int n); // Inserisce un '\0' alla posizione n-esima.
|
||||
|
||||
TString& upper(); // Mette la stringa in maiuscolo
|
||||
TString& lower(); // Mette la stringa in minuscolo
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// @DES Standard operators
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// @FPUB
|
||||
const TString& operator =(const TString& s) { return set(s._str); }
|
||||
const TString& operator =(const char* s) { return set(s); }
|
||||
|
||||
TString& operator <<(const char*);
|
||||
TString& operator <<(char);
|
||||
TString& operator <<(int);
|
||||
TString& operator <<(long);
|
||||
TString& operator <<(double);
|
||||
TString& operator <<(const TObject& obj);
|
||||
TString& operator <<(const TString& str); // For efficiency only
|
||||
|
||||
bool operator ==(const char* s) const { return strcmp(_str, s) == 0; }
|
||||
bool operator ==(char* s) const { return strcmp(_str, s) == 0; }
|
||||
bool operator ==(const TString& s) const { return strcmp(_str, s._str) == 0; }
|
||||
bool operator !=(const char* s) const { return strcmp(_str, s) != 0; }
|
||||
bool operator !=(char* s) const { return strcmp(_str, s) != 0; }
|
||||
bool operator !=(const TString& s) const { return strcmp(_str, s._str) != 0; }
|
||||
bool operator <(const char* s) const { return strcmp(_str, s) < 0; }
|
||||
bool operator >(const char* s) const { return strcmp(_str, s) > 0; }
|
||||
bool operator >=(const char* s) const { return strcmp(_str, s) >= 0; }
|
||||
bool operator <=(const char* s) const { return strcmp(_str, s) <= 0; }
|
||||
bool match(const char* s) const;
|
||||
bool compare(const char* s, int max = -1, bool ignorecase = FALSE) const;
|
||||
};
|
||||
|
||||
// @C
|
||||
// Classe TFixed_string : public TString
|
||||
// @END
|
||||
|
||||
class TFixed_string : public TString
|
||||
{
|
||||
protected:
|
||||
virtual void resize(int size, bool cpy); // Causa un errore fatale!
|
||||
|
||||
public:
|
||||
TFixed_string(const char* str, int size = -1);
|
||||
virtual ~TFixed_string();
|
||||
|
||||
const TString& operator =(const TString& s) { return set((const char*)s); }
|
||||
const TString& operator=(const char* s) { return set(s); }
|
||||
|
||||
void strncpy(const char* s, int n);
|
||||
};
|
||||
|
||||
class TString16 : public TFixed_string
|
||||
{
|
||||
char _str16[17];
|
||||
|
||||
public:
|
||||
TString16(const char* str = "") : TFixed_string(_str16, 17) { set(str); }
|
||||
const TString& operator =(const TString& s) { return set((const char*)s); }
|
||||
const TString& operator=(const char* s) { return set(s); }
|
||||
};
|
||||
|
||||
class TString80 : public TFixed_string
|
||||
{
|
||||
char _str80[81];
|
||||
|
||||
public:
|
||||
TString80(const char* str = "") : TFixed_string(_str80, 81) { set(str); }
|
||||
const TString& operator =(const TString& s) { return set((const char*)s); }
|
||||
const TString& operator=(const char* s) { return set(s); }
|
||||
};
|
||||
|
||||
class TString256 : public TFixed_string
|
||||
{
|
||||
char _str256[257];
|
||||
|
||||
public:
|
||||
TString256(const char* str = "") : TFixed_string(_str256, 257) { set(str); }
|
||||
const TString& operator =(const TString& s) { return set((const char*)s); }
|
||||
const TString& operator=(const char* s) { return set(s); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
// @C
|
||||
// Classe TFilename : public TString
|
||||
// @END
|
||||
|
||||
class TFilename : public TString
|
||||
{
|
||||
public:
|
||||
// @FPUB
|
||||
|
||||
TFilename(const char* n = "") : TString(24) { set(n); }
|
||||
|
||||
const TString& operator =(const char* s) { return set(s); }
|
||||
// assegnazione tra TFile e stringa
|
||||
|
||||
const char* ext() const; // Ritorna l'estensione
|
||||
void ext(const char*); // Imposta come estensione la stringa puntata da char*
|
||||
|
||||
const char* name() const; // Ritorna il nome del file
|
||||
TString& temp(const char* prefix = NULL); // Genera il nome di un file temporaneo
|
||||
TString& tempdir(); // Genera il nome della directory temporanea
|
||||
};
|
||||
|
||||
// @C
|
||||
// Classe TToken_string : public TString
|
||||
// @END
|
||||
|
||||
class TToken_string : public TString
|
||||
{
|
||||
// @DPRIV
|
||||
char _separator; // Carattere separatore
|
||||
int _last; // Puntatore all'ultimo
|
||||
|
||||
protected:
|
||||
// @FPROT
|
||||
|
||||
TObject* dup() const; // Crea un duplicato della token string
|
||||
bool set_item(const char* v, int n);
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
TToken_string(const char* = "", char separator = '|');
|
||||
TToken_string(int n, char separator = '|');
|
||||
TToken_string(const TToken_string& s);
|
||||
|
||||
void separator(char s) { _separator = s; } // Setta il separatore a s
|
||||
|
||||
void restart() { _last = empty() ? -1 : 0; } // Rimette all'inizio il puntatore
|
||||
const TString& operator =(const char* s) { set(s);restart();return *this; }
|
||||
const TString& operator =(const TString& s) { set(s);restart();return *this; }
|
||||
|
||||
void add(const char* s, int n = -1); // Aggiunge un token
|
||||
void add(char c, int pos = -1); // Aggiunge un char
|
||||
void add(long n, int pos = -1); // Aggiunge un intero
|
||||
void add(int n, int pos = -1); // Aggiunge un intero
|
||||
void destroy(int pos); // Toglie il token pos
|
||||
const char* get(); // Ritorna il prossimo token
|
||||
const char* get(int n); // Ritorna un token (-1 = prossimo; -2 = ultimo; n = ennesimo)
|
||||
char get_char(int n = -1); // Ritorna un carattere
|
||||
int get_int(int n = -1); // Ritorna un intero
|
||||
long get_long(int n = -1); // Ritorna un intero esteso
|
||||
int get_pos(const char* s); // Ritorna la posizione dell'item s
|
||||
int items() const; // Ritorna il numero di token presenti
|
||||
bool empty_items() const; // Controlla se tutti i token sono nulli
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// @DES Paragraph
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TParagraph_string : public TToken_string
|
||||
{
|
||||
int _width;
|
||||
bool _fixed;
|
||||
|
||||
protected:
|
||||
void tokenize();
|
||||
|
||||
public:
|
||||
TParagraph_string(const char* s, int width);
|
||||
const TString& operator =(const char* s);
|
||||
void set_width(int width) { _width = width; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -75,7 +75,7 @@ char* format(const char* fmt, ...)
|
||||
const char* cmd2name(const char* argv0, const char* argv1)
|
||||
{
|
||||
TFilename app(argv0); app.ext(""); app = app.name();
|
||||
if (argv1) app << ' ' << argv1;
|
||||
if (argv1 != NULL) app << ' ' << argv1;
|
||||
app.lower();
|
||||
|
||||
const int par = app.find(" -");
|
||||
|
Loading…
x
Reference in New Issue
Block a user