本文整理汇总了C++中DataStore类的典型用法代码示例。如果您正苦于以下问题:C++ DataStore类的具体用法?C++ DataStore怎么用?C++ DataStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ListGroups
void ListGroups(const DataStore& ds){
int i;
for(i=0;i<ds.group_size();i++){
const DataGroup& dg = ds.group(i);
ListValues(dg);
}
}
示例2: DataStore
//---------------------------------------------------------------------------------------------------
Ptr<DataStore> DataStore::Create(LPCTSTR Filename, BLOCKADDRESS BlockSize)
{
DataStore* pStore = new DataStore();
if (BlockSize < sizeof(STOREHEADER))
throw DataStoreException(pStore, "The BlockSize must be at least as large as the size of the header");
pStore->m_pFile = MemoryMappedFile::Open(Filename, FileMode::CREATE);
pStore->m_pFile->Resize(10 * BlockSize);
pStore->m_pView = pStore->m_pFile->CreateView();
pStore->m_pHeader = (STOREHEADER*)pStore->m_pView->GetBasePointer();
ZeroMemory(pStore->m_pHeader, sizeof(STOREHEADER));
pStore->m_pHeader->DataStoreVersion = DATASTOREVERSION;
pStore->m_pHeader->BlockAllocationIndex0 = 1;
pStore->m_pHeader->BlockCount = 10;
pStore->m_pHeader->BlockSize = BlockSize;
pStore->m_pHeader->FreeBlockCount = 6;
//pStore->m_pHeader->MetaDataTable.BlockCount = 0;
//pStore->m_pHeader->MetaDataTable.BlockDirectory = 0;
pStore->m_pBlockAllocationIndex0 = (BLOCKADDRESS*)pStore->GetBlock(1);
pStore->m_pBlockBitmaps = new DWORD*[BlockSize / sizeof(BLOCKADDRESS)];
ZeroMemory(pStore->m_pBlockBitmaps, sizeof(DWORD*) * BlockSize / sizeof(BLOCKADDRESS));
pStore->m_pBlockAllocationIndex0[0] = 2;
pStore->m_pBlockBitmaps[0] = (DWORD*)pStore->GetBlock(2);
pStore->m_pBlockAllocationIndex0[1] = 3;
pStore->m_pBlockBitmaps[1] = (DWORD*)pStore->GetBlock(3);
pStore->m_pBlockBitmaps[0][0] = 0xf;
return pStore;
}
示例3: main
int main()
{
DataStore ds;
ds.save("one", "../TESTFOLDER");
ds.save("two", "../TESTFOLDER/Dir1");
ds.save("one", "../TESTFOLDER/Dir1");
map<string,set<string>> catalog=ds.fetch();
ostream_iterator< string > output(cout, "\n|");
map<string, set<string>>::iterator it;
for (it = catalog.begin(); it != catalog.end(); ++it)
{
set<string> value = catalog[it->first];
cout << "_______________________________________" << endl;
cout << "| " << "FileName: " << it->first << endl;
cout << "----------------------------------------" << endl;
cout << "|" << "Path:\n|";
copy(value.begin(), value.end(), output);
cout << "----------------------------------------" << endl;
}
std::cout << "\n\n";
return 0;
}
示例4: main
int main(int argc, char **argv){
// Verify that the version of the library that we linked against is
// compatible with the version of the headers we compiled against.
GOOGLE_PROTOBUF_VERIFY_VERSION;
DataStore ds;
fstream input;
if (argc != 2) {
cerr << "Usage: " << argv[0] << " DATA_STORE_FILE" << endl;
return -1;
}
{
// Read the existing address book.
input.open(argv[1], ios::in | ios::binary);
if (!ds.ParseFromIstream(&input)) {
cerr << "Failed to parse address book." << endl;
return -1;
}
input.close();
}
ListGroups(ds);
// Optional: Delete all global objects allocated by libprotobuf.
google::protobuf::ShutdownProtobufLibrary();
return 0;
}
示例5: printTree
void DataStore::printTree(){
std::cout << m_path << std::endl;
std::map<std::string, IDataBlockPtr>::iterator it;
DataStore* ds;
for(it=m_map.begin();it!=m_map.end();it++){
ds = dynamic_cast<DataStore*>(it->second.get());
if(ds) ds->printTree();
//else std::cout << ("/"==m_path)?m_path+it->first:m_path+"/"+it->first << std::endl;
}
};
示例6: connection
bool Store::addFlags(const PimItem::List &items, const QSet<QByteArray> &flags, bool &flagsChanged)
{
const Flag::List flagList = HandlerHelper::resolveFlags(flags);
DataStore *store = connection()->storageBackend();
if (!store->appendItemsFlags(items, flagList, &flagsChanged)) {
qCDebug(AKONADISERVER_LOG) << "Store::addFlags: Unable to add new item flags";
return false;
}
return true;
}
示例7: addLinks
bool MIQPSolver::addLinks(const DataStore &store)
{
int num = 0;
for (DataStore::LinkMap::const_iterator it = store.Begin(); it != store.End(); it++)
{
if (!addLink(num, it->first.first, it->first.second, it->second))
return false;
++num;
}
return true;
}
示例8: connection
bool Delete::deleteRecursive(Collection &col)
{
Collection::List children = col.children();
for (Collection &child : children) {
if (!deleteRecursive(child)) {
return false;
}
}
DataStore *db = connection()->storageBackend();
return db->cleanupCollection(col);
}
示例9: find
IDataBlockPtr DataStore::find(std::string name){
vector<std::string> dividedName;
vector<std::string>::iterator itName;
boost::split(dividedName, name, boost::is_any_of("/"), boost::token_compress_on);
DataStore* current = (0==name.find("/"))?m_root.get():this;
IDataBlockPtr db;
for(itName=dividedName.begin(); itName !=dividedName.end(); itName++){
if(0==(*itName).size()) continue;
db = current->retrieveObject(*itName);
current = dynamic_cast<DataStore*>(db.get());
if(not current)return db;
}
return db;
}
示例10: main
int main()
{
DataStore ds;
ds.addFile("demo.txt", "path1");
ds.addFile("demo.txt", "path2");
ds.addFile("demo1.txt", "path1");
ds.addFile("demo1.txt", "path2");
ds.addFile("demo2.txt", "path1");
ds.addFile("demo2.txt", "path2");
ds.addFile("demo2.txt", "path3");
std::cout << "\n";
}
示例11: removeResourceInstance
void ResourceManager::removeResourceInstance(const QString &name)
{
DataStore *db = DataStore::self();
// remove items and collections
Resource resource = Resource::retrieveByName(name);
if (resource.isValid()) {
const QVector<Collection> collections = resource.collections();
Q_FOREACH (/*sic!*/ Collection collection, collections) {
db->cleanupCollection(collection);
}
// remove resource
resource.remove();
}
示例12: fillToTheBrim
void fillToTheBrim(DataStore &data_store, PointType point_type, T value)
{
for (int i(0); i < RTIMDB_POINT_COUNT; ++i)
{
data_store.insert(point_type, PointValue(value), Flags(), Timestamp());
}
}
示例13: cmd
bool ColMove::parseStream()
{
Protocol::MoveCollectionCommand cmd(m_command);
Collection source = HandlerHelper::collectionFromScope(cmd.collection(), connection());
if (!source.isValid()) {
return failureResponse("Invalid collection to move");
}
Collection target;
if (cmd.destination().isEmpty()) {
target.setId(0);
} else {
target = HandlerHelper::collectionFromScope(cmd.destination(), connection());
if (!target.isValid()) {
return failureResponse("Invalid destination collection");
}
}
if (source.parentId() == target.id()) {
return successResponse<Protocol::MoveCollectionResponse>();
}
CacheCleanerInhibitor inhibitor;
// retrieve all not yet cached items of the source
ItemRetriever retriever(connection());
retriever.setCollection(source, true);
retriever.setRetrieveFullPayload(true);
if (!retriever.exec()) {
return failureResponse(retriever.lastError());
}
DataStore *store = connection()->storageBackend();
Transaction transaction(store);
if (!store->moveCollection(source, target)) {
return failureResponse("Unable to reparent collection");
}
if (!transaction.commit()) {
return failureResponse("Cannot commit transaction.");
}
return successResponse<Protocol::MoveCollectionResponse>();
}
示例14: main
int main()
{
std::cout << "\n Testing DataStore";
DataStore ds;
ds.save("one");
ds.save("two");
ds.save("three");
DataStore::iterator iter = ds.begin();
std::cout << "\n " << (*iter).c_str();
for (auto item : ds)
{
std::cout << "\n " << item.c_str();
}
std::cout << "\n\n";
}
示例15: main
int main()
{
DataStore ds;
ds.addFile("demo.txt", "path1");
ds.addFile("demo.txt", "path2");
ds.addFile("demo1.txt", "path1");
ds.addFile("demo1.txt", "path2");
ds.addFile("demo2.txt", "path1");
ds.addFile("demo2.txt", "path2");
ds.addFile("demo2.txt", "path3");
DisplayData::title("\n Demonstrate DataStore Package ");
DisplayData::title("\n Save data in std::map<std::string,std::list < std::set < std::string >::iterator > > and print", '-');
DisplayData::showFileCatalouge(ds);
std::cout << "\n";
}