[CSProjects] Modularitate

Razvan Deaconescu razvan at anaconda.cs.pub.ro
Thu Apr 19 09:21:19 EEST 2007


Vlad Dogaru wrote:
> Daca ar fi usor nu ar mai fi fun. Still, can you elaborate on this when 
> you find the time? Un exemplu, poate?

ok, scuze de ambiguitate (pentru ca asa si este fara un exemplu clar)

uite cum ma gandesc eu:
- cream o biblioteca al carei rol este sa transforme o structura a 
noastra data intr=un fisier format spreadsheet - XML; se apeleaza o functie

int convert_info_to_xml_spreadsheet (const struct spreasheet_info *si, 
const char *spreadsheet_fname);

si se obtine din informatia transmisa ca parametru  un fisier formatul 
dorit de noi cu numele al doilea parametru

cum ar arata structura struct spreadsheet_info? pai la o prima vedere 
cam asa:

-----

/*
  * this structure describes an entire spreadsheet document; it is
  * stored in memory and it should be easy to convert this info into
  * a spreadsheet document
  */

struct spreadsheet_info {
	size_t heigth;
	size_t width;
	struct spreadsheet_cell **cell_v; /* cell matrix = heigth * width */
};

/*
  * possible spreadsheet cell types
  */

enum cell_type {
	CELL_TYPE_EMPTY,
	CELL_TYPE_STRING,
	CELL_TYPE_FORMULA,
	CELL_TYPE_...
};

/*
  * spreadsheet cell description
  */

struct spreadsheet_cell {
	enum cell_type type;
	union {
		char *string;
		struct formula *formula;
		...
	}
};

/*
  * description of a spreadsheet formula
  *
  * NB: don't know how the spreadsheet XML file stores formulas;
  * we may be able to use simple strings (char *) for formulas
  */

struct formula *formula {
	...
};

-----

in felul acesta am putea avea o biblioteca care exporta aceste 
structuri, functia de conversie si diverse alte functii (adaugare linie, 
adaugare formula, etc.); partea frumoasa este ca, in felul acesta, 
biblioteca este independenta de cerintele din spate: este doar o 
biblioteca de conversie care poate fi folosita cu succes si in alte 
proiecte care ar necesita asa ceva

Razvan



More information about the cspay-dev mailing list