bool CProjet::Sauver() { // L'objet n'est pas modifié if ( !(DoitEtreSauver() || DoitEtreSupprimer()) ) return true; // L'objet est supprimé if ( !(PeutEtreSauver() || PeutEtreSupprimer()) ) return false; // L'objet est à supprimer if ( DoitEtreSupprimer() ) return Supprimer(); // SaveGuard DObject::DObjSaveGuard::Start(this); // Gestion automatique des transactions __TRANSACTION_AUTO_DEBUT__(CSQLiteSource::Transaction()); // Sauvegarde de l'objet if (EstModifier()) { if (!Verifier()) { // Fin de la transaction automatique __TRANSACTION_AUTO_ANNULE__; return DObject::DObjSaveGuard::Error(this); } try { if (EstNouveau()) { std::ostringstream osQuery; osQuery << "insert into PROJET (PRJ_IDENT, PRJ_LIBELLE, PRJ_DESCRIPTION, PRJ_H_FOLDER, PRJ_CPP_FOLDER, PRJ_UUID_RES_GEN, PRJ_UUID_CLS_GEN)"; osQuery << " values ("; osQuery << " " << ToQuery(DefULong) << ","; osQuery << " " << ToQuery(m_sLibelle) << ","; osQuery << " " << ToQuery(m_sDescription) << ","; osQuery << " " << ToQuery(m_ptHFolder.toString()) << ","; osQuery << " " << ToQuery(m_ptCppFolder.toString()) << ","; osQuery << " " << ToQuery(m_uuidResGen.toString()) << ","; osQuery << " " << ToQuery(m_uuidClsGen.toString()) << ""; osQuery << ");"; CSQLiteSource::Database()->exec(osQuery.str()); m_ulId = static_cast<unsigned long>(CSQLiteSource::Database()->getLastInsertRowid()); } else if (EstModifier()) { std::ostringstream osQuery; osQuery << "update PROJET set"; osQuery << " PRJ_LIBELLE = " << ToQuery(m_sLibelle) << ","; osQuery << " PRJ_DESCRIPTION = " << ToQuery(m_sDescription) << ","; osQuery << " PRJ_H_FOLDER = " << ToQuery(m_ptHFolder.toString()) << ","; osQuery << " PRJ_CPP_FOLDER = " << ToQuery(m_ptCppFolder.toString()) << ","; osQuery << " PRJ_UUID_RES_GEN = " << ToQuery(m_uuidResGen.toString()) << ","; osQuery << " PRJ_UUID_CLS_GEN = " << ToQuery(m_uuidClsGen.toString()) << " "; osQuery << "where"; osQuery << " PRJ_IDENT = " << ToQuery(m_ulId) << ";"; CSQLiteSource::Database()->exec(osQuery.str()); } // L'objet est acquis SetAcquis(); } catch (SQLite::Exception& e) { Poco::Logger::get("SQLiteException").debug(e.what()); // Fin de la transaction automatique __TRANSACTION_AUTO_ANNULE__; return DObject::DObjSaveGuard::Error(this); } } // if (!SontEnfantsModifier()) { // Fin de la transaction automatique __TRANSACTION_AUTO_VALIDE__; return DObject::DObjSaveGuard::Sucess(this); } // if (m_pFiltreListe && (!((m_pFiltreListe->SetPrjIdent(m_ulId)) && (m_pFiltreListe->Sauver())))) { // Fin de la transaction automatique __TRANSACTION_AUTO_ANNULE__; return DObject::DObjSaveGuard::Error(this); } // Fin de la transaction automatique __TRANSACTION_AUTO_VALIDE__; return DObject::DObjSaveGuard::Sucess(this); }
int main(int argc, char* argv[]) { MainArgs margs = parse_main_arguments(argc, argv); if (margs.print_version_and_exit) { std::cout << Help::version_to_string(Globals::version) << std::endl; return 0; } else if (margs.print_help_and_exit) { print_usage(); return 0; } // From here, load either the game or the interactive replay checker. // This will depend on existing dirs later on. setenv_allegro_modules(); allegro_init(); unsetenv_allegro_modules(); Help::timer_start(); ::loadpng_init(); Globals::initialize(); User::initialize(); Log::initialize(); LixEn::initialize(); // Check whether the Globals decided we're in one of the accepted // working directories, so all files are found. Otherwise, exit with error. if (! Help::dir_exists(gloB->dir_data_bitmap)) { allegro_message("%s", gloB->error_wrong_working_dir.c_str()); Log::deinitialize(); Globals::deinitialize(); return -1; } gloB->load(); if (margs.input_user_name) { gloB->user_name = ""; } useR->load(); // Graphics are needed both by interactive and noninteractive mode ::set_color_depth(16); if (margs.replays_to_verify.empty()) { // interactive mode, i.e., no replay checking mode install_keyboard(); hardware.set_mouse_accel_on_windows(useR->mouse_acceleration); install_mouse(); if (! margs.suppress_sound_driver && gloB->sound_load_driver) Sound::initialize(); if (margs.resolution_or_fullscreen_suggested_via_args) set_screen_mode(margs.fullscreen, margs.graphics_driver, margs.screen_xl, margs.screen_yl); else set_screen_mode(! useR->screen_windowed, margs.graphics_driver, 0, 0); // BUG: in Windows, setting the window title with non-ASCII UTF-8 // string does not seem to work (Allegro bug?)--non-ASCII characters // turn into ^. Workaround by forcing use of English string here. // // (should main_name_of_the_game even be allowed for translation?) set_window_title(Language::main_name_of_game_English); if (useR->language == Language::NONE || useR->language >= Language::MAX) { // This is for the "initial use" case where there is no // user profile and therefore no language set. // // It is preferrable in that case to load the custom language // if it exists, so that we display the "loading..." texts (inside // load_all_bitmaps() below) text in the language the user probably // wants (the custom one if it exists, otherwise English) static_cast<void>(Language::try_load_custom_language(false)); } load_all_bitmaps(GraLib::LOAD_WITH_RECOLOR_LIX); Network::initialize(); // Main loop. See other/lmain.cpp for this. LMain* l_main = new LMain; l_main->main_loop(); delete l_main; // Clean up useR->save(); gloB->save(); destroy_all_bitmaps(); Network::deinitialize(); Sound::deinitialize(); } else { // noninteractive mode that checks replays Help::interactive_mode = false; Verifier(margs.replays_to_verify, margs.convert_and_overwrite ? Verifier::yes : Verifier::no); } Log::deinitialize(); Globals::deinitialize(); // don't call allegro_exit(), doing that causes the program // to not terminate in rare cases return 0; }