📄 readme.txt
字号:
Use this class in the following manner (where MY_TYPE is a class or structure written by you)
Adding a record:
*************
MY_TYPE mt;
// Set values of mt member variables
DataStore<MY_TYPE> ds("my.dat");
if(ds.Open()) {
if(ds.AddRecord(mt)) {
cout<<"Record saved"<<endl;
}else {
cout<<"Failed to save record"<<endl;
}
ds.Close();
}else {
cout<<"Failed to open file"<<endl;
}
*********************************
~~~~~~~~~~~~~~~~~~~~~~~~~~
Finding number of records in a data file:
******************************
DataStore<MY_TYPE> ds("my.dat");
if(ds.Open()) {
unsigned long recs = ds.GetRecordCount();
}
***********************************
~~~~~~~~~~~~
Deleting a record:
*************
unsigned long index = 0;
for(unsigned long i=0;i<recs;i++) {
mt = ds.FindRecord(i);
// compare a field of mt against a search value
if (comparison is true) {
break;
}else {
index++;
}
}
ds.DeleteRecord(index);
// ds.ModifyRecord(new_mt,index);
ds.Close();
***********************************
DataStore has a member function called GetNextRecordNo() which can be used to generate
a unique long id for the next record to be written.
This function can be used for getting an id for uniquely identifying a record in the file.
For this a class that serializes itself using DataStore should have an unsigned long field in it.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -