当前位置: 首页>>代码示例>>C++>>正文


C++ FileStore::setBaseFolder方法代码示例

本文整理汇总了C++中FileStore::setBaseFolder方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStore::setBaseFolder方法的具体用法?C++ FileStore::setBaseFolder怎么用?C++ FileStore::setBaseFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileStore的用法示例。


在下文中一共展示了FileStore::setBaseFolder方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

TEST(FilePersistence, SaveMultipleUnits)
{
	QString testDir = QDir::tempPath() + QDir::toNativeSeparators("/Envision/FilePersistence/tests");
	Model::Model model;
	FileStore store;
	store.setBaseFolder(testDir);

	TestNodes::BinaryNode* root = dynamic_cast<TestNodes::BinaryNode*> (model.createRoot("BinaryNode"));

	model.beginModification(root, "set title");
	root->name()->set("Root");
	TestNodes::BinaryNode* left = root->setLeft<TestNodes::BinaryNodePersistenceUnit>();
	TestNodes::BinaryNode* right = root->setRight<TestNodes::BinaryNode>();

	left->name()->set("Left child");
	TestNodes::BinaryNode* leftleft = left->setLeft<TestNodes::BinaryNode>();
	leftleft->name()->set("in a new unit");
	right->name()->set("Right child");
	model.endModification();

	model.setName("units");
	model.save(&store);
	CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/units/units", testDir + "/units/units");
	CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/units/2", testDir + "/units/2");
}
开发者ID:luciaa,项目名称:Envision,代码行数:25,代码来源:SaveTests.cpp

示例2:

TEST(FilePersistence, SaveList)
{
	QString testDir = QDir::tempPath() + "/Envision/FilePersistence/tests";
	Model::Model model;
	FileStore store;
	store.setBaseFolder(testDir);

	TestNodes::PartialList* root = dynamic_cast<TestNodes::PartialList*> (model.createRoot("PartialList"));

	model.beginModification(root, "create ");
	Model::Text* one = new Model::Text();
	one->set("one");
	root->list()->append(one);
	Model::Text* two = new Model::Text();
	two->set("two");
	root->list()->append(two);
	Model::Text* three = new Model::Text();
	three->set("three");
	root->list()->append(three);
	Model::Text* four = new Model::Text();
	four->set("four");
	root->list()->append(four);
	model.endModification();

	model.setName("partial");
	model.save(&store);

	CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/partial/partial", testDir + "/partial/partial");
}
开发者ID:Andresbu,项目名称:Envision,代码行数:29,代码来源:PartialNodeTests.cpp

示例3:

TEST(FilePersistence, LoadMultipleUnits)
{
	QString testDir = ":/FilePersistence/test/persisted";
	Model::Model model;
	FileStore store;
	store.setBaseFolder(testDir);

	model.load(&store, "units");
	TestNodes::BinaryNode* root = dynamic_cast<TestNodes::BinaryNode*> (model.root());

	CHECK_STR_EQUAL("BinaryNode", root->typeName() );
	CHECK_STR_EQUAL("Root", root->name()->get() );
	CHECK_CONDITION(root->left() != nullptr);
	CHECK_CONDITION(root->right() != nullptr);
	CHECK_STR_EQUAL("BinaryNodePersistenceUnit", root->left()->typeName() );
	CHECK_STR_EQUAL("Left child", root->left()->name()->get() );
	CHECK_CONDITION(root->left()->left() != nullptr);
	CHECK_CONDITION(root->left()->right() == nullptr);
	CHECK_STR_EQUAL("BinaryNode", root->left()->left()->typeName() );
	CHECK_STR_EQUAL("in a new unit", root->left()->left()->name()->get() );
	CHECK_CONDITION(root->left()->left()->left() == nullptr);
	CHECK_CONDITION(root->left()->left()->right() == nullptr);
	CHECK_STR_EQUAL("BinaryNode", root->right()->typeName() );
	CHECK_STR_EQUAL("Right child", root->right()->name()->get() );
	CHECK_CONDITION(root->right()->left() == nullptr);
	CHECK_CONDITION(root->right()->right() == nullptr);
}
开发者ID:Andresbu,项目名称:Envision,代码行数:27,代码来源:LoadTests.cpp

示例4:

TEST(FilePersistence, LoadingList)
{
	QString testDir = ":/FilePersistence/test/persisted";
	Model::Model model;
	FileStore store;
	store.setBaseFolder(testDir);

	model.load(&store, "partial");
	TestNodes::PartialList* root = dynamic_cast<TestNodes::PartialList*> (model.root());
	CHECK_CONDITION(root != nullptr);

	Model::List* list = root->list();

	CHECK_CONDITION(list != nullptr);
	CHECK_STR_EQUAL("List", list->typeName() );
	CHECK_CONDITION(list->isFullyLoaded() == false);
	CHECK_INT_EQUAL(1, list->id());

	list->loadFully(store);

	CHECK_CONDITION(list->isFullyLoaded());
	CHECK_INT_EQUAL(4, list->size());

	Model::Text* one = list->at<Model::Text>(0);
	Model::Text* two = list->at<Model::Text>(1);
	Model::Text* three = list->at<Model::Text>(2);
	Model::Text* four = list->at<Model::Text>(3);

	CHECK_CONDITION(one != nullptr);
	CHECK_STR_EQUAL("one", one->get());
	CHECK_INT_EQUAL(2, one->id());

	CHECK_CONDITION(two != nullptr);
	CHECK_STR_EQUAL("two", two->get());
	CHECK_INT_EQUAL(3, two->id())

	CHECK_CONDITION(three != nullptr);
	CHECK_STR_EQUAL("three", three->get());
	CHECK_INT_EQUAL(4, three->id())

	CHECK_CONDITION(four != nullptr);
	CHECK_STR_EQUAL("four", four->get());
	CHECK_INT_EQUAL(5, four->id());

}
开发者ID:luciaa,项目名称:Envision,代码行数:45,代码来源:PartialNodeTests.cpp

示例5: srcDir

TEST(FilePersistence, ReSaveList)
{
	QString srcDir(":/FilePersistence/test/persisted");
	QString destDir(QDir::tempPath() + "/Envision/FilePersistence/tests");

	QFile src(srcDir + "/partial/partial");
	QFile dest(destDir + "/partialResave/partialResave");

	if (dest.exists())
	{
		bool removed = dest.remove();
		CHECK_CONDITION(removed);
	}

	if (!QDir(destDir + "/partialResave").exists())
	{
		bool createdDir = QDir().mkpath(destDir + "/partialResave");
		CHECK_CONDITION(createdDir);
	}
	bool copied = src.copy(dest.fileName());
	CHECK_CONDITION(copied);

	bool permissionOk = dest.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
	CHECK_CONDITION(permissionOk);

	Model::Model model;
	FileStore store;
	store.setBaseFolder(destDir);

	model.load(&store, "partialResave");
	TestNodes::PartialList* root = dynamic_cast<TestNodes::PartialList*> (model.root());

	CHECK_CONDITION(root->list()->isFullyLoaded() == false);

	model.beginModification(root->list(), "fake modification ");
	model.endModification();

	CHECK_CONDITION(root->list()->isFullyLoaded() == false);
	model.setName("partialResave");
	model.save(&store);
	CHECK_CONDITION(root->list()->isFullyLoaded() == false);

	CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/partialResave/partialResave", destDir + "/partialResave/partialResave");
}
开发者ID:Andresbu,项目名称:Envision,代码行数:44,代码来源:PartialNodeTests.cpp

示例6:

TEST(FilePersistence, SavingTypedList)
{
	QString testDir = QDir::tempPath() + "/Envision/FilePersistence/tests";
	Model::Model model;
	FileStore store;
	store.setBaseFolder(testDir);

	Model::TypedList<Model::Text>* list = dynamic_cast<Model::TypedList<Model::Text>*> (model.createRoot("TypedListOfText"));

	model.beginModification(list, "create");
	Model::Text* one = new Model::Text();
	one->set("one");
	list->append(one);
	Model::Text* two = new Model::Text();
	two->set("two");
	list->append(two);
	model.endModification();

	model.setName("typedList");
	model.save(&store);

	CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/typedList/typedList", testDir + "/typedList/typedList");
}
开发者ID:Andresbu,项目名称:Envision,代码行数:23,代码来源:TypedListTests.cpp

示例7:

TEST(FilePersistence, LoadDataMultipleUnits)
{
	QString testDir = ":/FilePersistence/test/persisted";
	FileStore store;
	store.setBaseFolder(testDir);

	typedef PersistedValue< QString >* String;
	typedef PersistedValue< QList<PersistedNode*> >* Composite;

	// Root Node
	Composite root = dynamic_cast<Composite> (store.loadCompleteNodeSubtree("units", nullptr));
	CHECK_CONDITION(root);
	CHECK_STR_EQUAL("BinaryNode", root->type() );
	CHECK_STR_EQUAL("units", root->name());
	CHECK_INT_EQUAL(0, root->id());
	CHECK_CONDITION(!root->partialHint());
	CHECK_CONDITION(!root->isNewPersistenceUnit());
	CHECK_INT_EQUAL(3, root->value().size());

	// Root Node children
	String rootName = dynamic_cast<String> (root->value().at(0));
	CHECK_CONDITION(rootName);
	CHECK_STR_EQUAL("Text", rootName->type() );
	CHECK_STR_EQUAL("name", rootName->name());
	CHECK_INT_EQUAL(1, rootName->id());
	CHECK_CONDITION(!rootName->partialHint());
	CHECK_CONDITION(!rootName->isNewPersistenceUnit());
	CHECK_STR_EQUAL("Root", rootName->value());

	Composite left = dynamic_cast<Composite> (root->value().at(1));
	CHECK_CONDITION(left);
	CHECK_STR_EQUAL("BinaryNodePersistenceUnit", left->type() );
	CHECK_STR_EQUAL("left", left->name());
	CHECK_INT_EQUAL(2, left->id());
	CHECK_CONDITION(!left->partialHint());
	CHECK_CONDITION(left->isNewPersistenceUnit());
	CHECK_INT_EQUAL(2, left->value().size());

	Composite right = dynamic_cast<Composite> (root->value().at(2));
	CHECK_CONDITION(right);
	CHECK_STR_EQUAL("BinaryNode", right->type() );
	CHECK_STR_EQUAL("right", right->name());
	CHECK_INT_EQUAL(6, right->id());
	CHECK_CONDITION(!right->partialHint());
	CHECK_CONDITION(!right->isNewPersistenceUnit());
	CHECK_INT_EQUAL(1, right->value().size());

	// Left Node children
	String leftName = dynamic_cast<String> (left->value().at(0));
	CHECK_CONDITION(leftName);
	CHECK_STR_EQUAL("Text", leftName->type() );
	CHECK_STR_EQUAL("name", leftName->name());
	CHECK_INT_EQUAL(3, leftName->id());
	CHECK_CONDITION(!leftName->partialHint());
	CHECK_CONDITION(!leftName->isNewPersistenceUnit());
	CHECK_STR_EQUAL("Left child", leftName->value());

	Composite leftleft = dynamic_cast<Composite> (left->value().at(1));
	CHECK_CONDITION(leftleft);
	CHECK_STR_EQUAL("BinaryNode", leftleft->type() );
	CHECK_STR_EQUAL("left", leftleft->name());
	CHECK_INT_EQUAL(4, leftleft->id());
	CHECK_CONDITION(!leftleft->partialHint());
	CHECK_CONDITION(!leftleft->isNewPersistenceUnit());
	CHECK_INT_EQUAL(1, leftleft->value().size());

	String leftleftName = dynamic_cast<String> (leftleft->value().at(0));
	CHECK_CONDITION(leftleftName);
	CHECK_STR_EQUAL("Text", leftleftName->type() );
	CHECK_STR_EQUAL("name", leftleftName->name());
	CHECK_INT_EQUAL(5, leftleftName->id());
	CHECK_CONDITION(!leftleftName->partialHint());
	CHECK_CONDITION(!leftleftName->isNewPersistenceUnit());
	CHECK_STR_EQUAL("in a new unit", leftleftName->value());

	// Right Node children
	String rightName = dynamic_cast<String> (right->value().at(0));
	CHECK_CONDITION(rightName);
	CHECK_STR_EQUAL("Text", rightName->type() );
	CHECK_STR_EQUAL("name", rightName->name());
	CHECK_INT_EQUAL(7, rightName->id());
	CHECK_CONDITION(!rightName->partialHint());
	CHECK_CONDITION(!rightName->isNewPersistenceUnit());
	CHECK_STR_EQUAL("Right child", rightName->value());
}
开发者ID:JurajKubelka,项目名称:Envision,代码行数:85,代码来源:LoadNodeDataTests.cpp


注:本文中的FileStore::setBaseFolder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。