本文整理汇总了C++中FileInputStream::eof方法的典型用法代码示例。如果您正苦于以下问题:C++ FileInputStream::eof方法的具体用法?C++ FileInputStream::eof怎么用?C++ FileInputStream::eof使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileInputStream
的用法示例。
在下文中一共展示了FileInputStream::eof方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLogger
TEST(testIndexP, testRecoverNames) {
Logger* log = getLogger(NULL);
std::set<std::string> keys;
keys.insert("_id");
BPlusIndexP* index = new BPlusIndexP("testIndexNames");
index->setKeys(keys);
FileInputStream* fis = new FileInputStream("names.txt", "r");
cout << "Adding names to the index" << endl;
std::vector<std::string> names;
int x = 0;
while (true) {
if (fis->eof()) {
cout << "No more names" << endl;
break;
}
if (x >= 100) {
break;
}
x++;
BSONObj o;
std::string* name = fis->readString();
o.add("_id", name->c_str());
char* temp = strcpy(const_cast<char*>(name->c_str()), name->length());
index->add(o, djondb::string(temp, name->length()), 100);
index->debug();
if (log->isDebug()) log->debug("===============================================================================");
names.push_back(*name);
delete name;
}
index->debug();
delete index;
cout << "Finding names from the index" << endl;
index = new BPlusIndexP("testIndexNames");
index->setKeys(keys);
index->debug();
for (std::vector<std::string>::iterator i = names.begin(); i != names.end(); i++) {
std::string name = *i;
BSONObj o;
o.add("_id", name.c_str());
Index* idx = index->find(&o);
ASSERT_TRUE(idx != NULL) << "_id " << name.c_str() << " not found";
ASSERT_TRUE(idx->key->has("_id")) << "Retrieved index for _id " << name.c_str() << " does not returned the _id";
EXPECT_TRUE(idx->key->getString("_id").compare(name) == 0) << "Recovered a wrong key, expected: " << name.c_str() << " and retrived: " << idx->key->getString("_id").c_str();
}
delete index;
}