我一直在研究用于安排电视录制的 PVR 后端,我正在尝试找出保存包含所有相关信息的简单数据库的最佳方法。我整理了一个懒人的原型(如下所示),但我不想静态分配巨大的数组,然后简单地将这些对象的 ram 内容转储到磁盘进行存储。
鉴于以下懒惰/不良实践原型,我的最佳选择是什么?一个有经验的程序员会如何选择做这样的事情?如果我要在不使用 toString/fromString 函数的情况下完成这一切,我该怎么做?
struct Recording{
Date date;
int channel;
int length; //length in hours, minutes, or seconds
bool is_interlaced; //if true, denotes that the episode is interlaced
bool done; //if true, denotes that the episode has been recorded
bool record_successful; //Currently unused
};
struct TV_Episode{
struct Recording recording;
char title[128]; //Episode Title
char season; //Season number
char episode; //Episode number
};
struct TV_Show{
char name[64]; //TV Show name
char numepisodes; //The number of episodes in the array
struct TV_Episode episodes[100]; //Array containing airings of a TV show
};
struct Movie{
struct Recording recording;
char title[128]; //Movie Title, optionally including the year in brackets
};
struct Recordings_DB{ /*
* Obviously these types can be done away with using inheritance
* and the Recordings_DB type can be done away with using a vector.
* They are just here to illustrate the concept.
*/
struct TV_Show shows[20];
struct Movie movies[20];
};