/* * MathPlanner 3.1 - Mathematical design tool. * Copyright(C) 2002 Jarmo Nikkanen * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation. * * You should have received a copy of the GNU General Public License with this program. * */ #ifndef _MATHPLANNER_DATASTORE_H #define _MATHPLANNER_DATASTORE_H #include #include #include #include #include #include #include #include "BaseStructures.h" // For Special MathPlanner additions struct DataEntry { char type; char name[15]; int size; int position; }; class DataStorage { public: DataStorage(char *name=0); ~DataStorage(); bool Record(char **,int *size,bool pack); bool Build(char *address,int size); void Load(QString file); void Save(QString file); void Print(); bool AddData(char *name,void *data,int size); bool AddInt(char *name,int data); bool AddString(char *name,char *data); bool AddLongDouble(char *name,long double); bool ReadData(char *name,void **data,int *size=0); bool ReadInt(char *name,int *data); int ReadInt(char *name,bool *ok=NULL); long double ReadLongDouble(char *name); bool AddDataStorage(char *name,class DataStorage *data,bool=false); bool ReadDataStorage(char *name,class DataStorage *data); bool AddPointer(char *name,void *data); bool ReadPointer(char *name,void **data); void *ReadPointer(char *name,bool *ok=NULL); bool Contains(char *,int *index=0); bool Clear(); // SPECIAL QT ADDITIONS bool AddQString(char *name,QString *s); bool AddQString(char *name,QString s); QString ReadQString(char *name); bool AddQFont(char *name,QFont *font); bool ReadQFont(char *name,QFont *font); bool AddQComboBox(char *name,QComboBox *box,bool all); bool ReadQComboBox(char *name,QComboBox *box); bool AddQLineEdit(char *name,QLineEdit *line); bool ReadQLineEdit(char *name,QLineEdit *line); bool AddQSpinBox(char *name,QSpinBox *box); bool ReadQSpinBox(char *name,QSpinBox *box); bool AddQColor(char *name,QColor *c); bool AddQColor(char *name,QColor c); bool ReadQColor(char *name,QColor *c); QColor ReadQColor(char *name,bool *ok=NULL); bool AddQRect(char *name,QRect *); bool ReadQRect(char *name,QRect *); bool AddQPoint(char *name,QPoint *); bool ReadQPoint(char *name,QPoint *); void AddQByteArray(char *name,QByteArray c); QByteArray ReadQByteArray(char *name); // Special MathPlanner Additions bool AddLayoutRect(char *name,layout_rect *c); bool ReadLayoutRect(char *name,layout_rect *c); // End section private: bool Allocate(int entry=0,int data=0); bool AddEntry(char *name,char type,int size,int position); bool AddSpace(int size,int position); int FindSpaceEntry(int size); int FindEntry(char *name=0,bool read=0); void DeleteEntry(int no); void ChangeSpace(int,int); char id[8]; int packed; int headersize; int headercount; int datasize; int packedsize_h; int packedsize_d; int reserved[10]; DataEntry *header; void *address; char filename[64]; }; // entry types 1=4bytes 2=string 3=space-entry 0=unused #endif