예제 #1
0
void menu(vector<Book>& collection)
{
	char exit = 'n'; 
	do
	{
		int item;
		int& ritem = item; 
		string choice;
		cout << " ___________________________________________________________________________________________________ " << endl
			<< "| __________               __     _________        .__  .__                 __  .__                 |" << endl
			<< "| \\______   \\ ____   ____ |  | __ \\_   ___ \\  ____ |  | |  |   ____   _____/  |_|__| ____   ____    |" << endl
			<< "|  |    |  _//  _ \\ /  _ \\|  |/ / /    \\  \\/ /  _ \\|  | |  | _/ __ \\_/ ___\\   __\\  |/  _ \\ /    \\   |" << endl
			<< "|  |    |   (  <_> |  <_> )    <  \\     \\___(  <_> )  |_|  |_\\  ___/\\  \\___|  | |  (  <_> )   |  \\  |" << endl
			<< "|  |______  /\\____/ \\____/|__|_ \\  \\______  /\\____/|____/____/\\___  >\\___  >__| |__|\\____/|___|  /  |" << endl
			<< "|_________\\/___________________\\/_________\\/______________________\\/_____\\/____________________\\/___|" << endl
			<< "|                                                                                                   |" << endl
			<< "|1.View Collection			        2.Add Book			      3.Delete Book |" << endl
			<< "|4.Search Collection				5.Save to File			      6.Exit Program|" << endl
			<< "|___________________________________________________________________________________________________|" << endl
			<< "\t\t\tEnter a number to access a menu item:\t";
		//addBook(collection); 
		getline(cin, choice);
		try
		{
			ritem = stoi(choice);
		}
		catch (invalid_argument e)
		{
			cout << "Please enter a digit\n";
			system("pause");  
		}
		switch (item) 
		{
		case 1:
			viewCollection(collection); 
			system("pause");
			break;
		case 2:
			addBook(collection);
			break;
		case 3:
			deleteBook(collection); 
			break;
		case 4:
			searchBook(collection); 
			system("pause");  
			break;
		case 5:
			saveCollection(collection); 
			break;
		case 6:
			exit = exitProgram(); 
			break;  
		default:
			cout << "Enter a number associated with a menu item (1-6).\n";
		}
		system("cls"); 
	}while(exit == 'n'); 
} // menu function
예제 #2
0
void XMLWriter::saveProperty(QString name, QObject* item, QDomElement *node)
{
    QString typeName;
    if (name.compare("itemIndexMethod")==0)
        typeName = item->metaObject()->property(item->metaObject()->indexOfProperty(name.toLatin1())).typeName();
    else
        typeName = item->property(name.toLatin1()).typeName();

    CreateSerializator creator=0;
    if (isCollection(name,item)) { saveCollection(name,item,node); return;}
    if (isQObject(name,item)) {
        if (qvariant_cast<QObject *>(item->property(name.toLatin1())))
            putQObjectProperty(name,qvariant_cast<QObject *>(item->property(name.toLatin1())),node);
        else {
            qDebug()<<"Warnig property can`t be casted to QObject"<<name;
        }
        return;
    }

    if (enumOrFlag(name,item))
        creator=XMLAbstractSerializatorFactory::instance().objectCreator(
                    "enumAndFlags"
                );
    else
    try {
        creator=XMLAbstractSerializatorFactory::instance().objectCreator(typeName);
    } catch (LimeReport::ReportError &exception){
        qDebug()<<"class name ="<<item->metaObject()->className()
               <<"property name="<<name<<" property type="<<typeName
               <<exception.what();

    }

    if (creator) {
        QScopedPointer<SerializatorIntf> serializator(creator(m_doc.data(),node));
        serializator->save(
            item->property(name.toLatin1()),
            name
        );
    }
}
예제 #3
0
void VolumeCollectionSave::process() {
    if (inport_.hasChanged() && continousSave_.get())
        saveCollection();
}
예제 #4
0
void saveCollection(QIODevice &d, const Collection &c) {
	QXmlStreamWriter w(&d);
	saveCollection(w, c);
}