本文整理汇总了C++中Store::open方法的典型用法代码示例。如果您正苦于以下问题:C++ Store::open方法的具体用法?C++ Store::open怎么用?C++ Store::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Store
的用法示例。
在下文中一共展示了Store::open方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
printf("sizeof(portable_off_t)=%d\n",(int)sizeof(portable_off_t));
Store s;
if (s.open("test.db")==0)
{
const char *str1 = "This is a test message... ";
const char *str2 = "Another message. ";
int i,j;
for (j=0;j<5;j++)
{
char buf[100];
portable_off_t handle = s.alloc();
for (i=0;i<1000000000;i++)
{
s.write(str1,strlen(str1)+1);
}
s.end();
portable_off_t handle2 = s.alloc();
for (i=0;i<10;i++)
{
s.write(str2,strlen(str2)+1);
}
s.end();
s.seek(handle);
for (i=0;i<3;i++)
{
s.read(buf,strlen(str1)+1);
printf("i=%d Read: %s\n",i,buf);
}
s.release(handle);
s.seek(handle2);
for (i=0;i<3;i++)
{
s.read(buf,strlen(str2)+1);
printf("i=%d Read: %s\n",i,buf);
}
s.release(handle2);
}
s.close();
}
else
{
printf("Open failed! %s\n",strerror(errno));
}
}
示例2: calc
void calc(Store& s, char* store_fname, int order){
s.open(store_fname);
if (!s.is_init()){
wcerr << "Store is not initialized, initializing..." << endl;
s.init();
wcerr << "Store initialized!" << endl;
}
double H = s.entropy(order);
wcout << H << endl;
}
示例3: gen
void gen(Store& s, char* store_fname, char* output_fname, int length, int order){
ofstream ofs;
ofs.open(output_fname);
s.open(store_fname);
if (!s.is_init()){
wcerr << "Store is not initialized, initializing..." << endl;
s.init();
wcerr << "Store initialized!" << endl;
}
string txt = generate_text(s, length, order);
replace(txt.begin(), txt.end(), '_', ' ');
ofs << txt;
ofs.close();
}
示例4: assim
void assim(Store& s, char* store_fname, char* text_fname, int order){
s.open(store_fname);
order++;
if (!s.is_init()){
wcerr << "Store is not initialized, initializing..." << endl;
s.init();
wcerr << "Store initialized!" << endl;
}
string txt = read_text(text_fname);
#ifndef CHARS
assimilate_text(txt, s, order);
#else
assimilate_text_chars(txt, s, order);
#endif
s.close(store_fname);
}