⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 storageactor.cpp

📁 磁盘管理工具,主要管理光盘信息和内容希望大家喜欢
💻 CPP
字号:
//$Id: StorageActor.cpp,v 1.7 2006/03/19 02:21:12 markus Rel $//PROJECT     : CDManager//SUBSYSTEM   : Storage//REFERENCES  ://TODO        ://BUGS        ://REVISION    : $Revision: 1.7 $//AUTHOR      : Markus Schwab//CREATED     : 21.01.2006//COPYRIGHT   : Copyright (C) 2006// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.#include <sstream>#include <YGP/Check.h>#include <YGP/Trace.h>#include <YGP/StatusObj.h>#include "DB.h"#include "StorageActor.h"//-----------------------------------------------------------------------------/// Loads the actors and its movies from the database/// \param aActors: Map to map an actor-id to movie-IDs//-----------------------------------------------------------------------------void StorageActor::StorageActor::loadActorsInMovies (std::map<unsigned int, std::vector<unsigned int> >& aActors)   throw (std::exception) {   TRACE7 ("StorageActor::loadActorsInMovies (std::map<...>&)");   Database::execute ("SELECT idActor, idMovie FROM ActorsInMovies ORDER BY idActor");   if (Database::resultSize ()) {      std::map<unsigned int, std::vector<unsigned int> >::iterator iter (aActors.end ());      while (Database::hasData ()) {	 unsigned int idLast (0);	 unsigned int idAct (Database::getResultColumnAsUInt (0)); Check3 (idAct);	 if (idAct != idLast) {	    idLast = idAct;	    iter = aActors.insert (aActors.end (), std::pair<unsigned int, std::vector<unsigned int> > (idAct, std::vector<unsigned int> ()));	 }	 Check3 (iter != aActors.end ());	 iter->second.push_back (Database::getResultColumnAsUInt (1));	 Database::getNextResultRow ();      } // end-while actors for movies available   } // endif actors for movies stored in the DB}//-----------------------------------------------------------------------------/// Deletes the actor with the passed ID from the database/// \param idActor: Actor to remove//-----------------------------------------------------------------------------void StorageActor::deleteActor (unsigned int idActor) throw (std::exception) {   TRACE9 ("StorageActor::deleteActor (unsigned int)");   Check3 (idActor);   std::stringstream query;   query << "DELETE FROM Actors WHERE id=" << idActor;   Database::execute (query.str ().c_str ());   std::stringstream query2;   query2 << "DELETE FROM ActorsInMovies WHERE idActor=" << idActor;   Database::execute (query2.str ().c_str ());}//-----------------------------------------------------------------------------/// Deletes the movies of the actor with the passed ID from the database/// \param idActor: Actor to remove//-----------------------------------------------------------------------------void StorageActor::deleteActorMovies (unsigned int idActor) throw (std::exception) {   TRACE9 ("StorageActor::deleteActorMovies (unsigned int)");   Check3 (idActor);   std::stringstream del;   del << "DELETE FROM ActorsInMovies WHERE idActor=" << idActor;   Database::execute (del.str ().c_str ());}//-----------------------------------------------------------------------------/// Connects an actor with a movie/// \param idActor: Actor to connect/// \param idMovie: ID of movie the actors plays in//-----------------------------------------------------------------------------void StorageActor::saveActorMovie (unsigned int idActor, unsigned int idMovie) throw (std::exception) {   std::stringstream query;   query << "INSERT INTO ActorsInMovies SET idActor=" << idActor << ", idMovie=" << idMovie;   Database::execute (query.str ().c_str ());}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -