本文整理汇总了C++中Movie类的典型用法代码示例。如果您正苦于以下问题:C++ Movie类的具体用法?C++ Movie怎么用?C++ Movie使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Movie类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: infile
// ------------------------------------readMovieFile-----------------------------------------
// Description: reads from .txt file and insert each movie in
// movies in corresponding binary search tree.
// ------------------------------------------------------------------------------------------
void Store::readMovieFile()
{
const string movieFileName = "data4movies.txt";
fstream infile(movieFileName, ios_base::in);
if (infile.fail())
{
cerr << "Can't find movie file: " << movieFileName << endl;
return;
}
while(!infile.eof())
{
Movie *movie = MovieFactory::Create(infile);
if (movie)
{
switch (movie->getMovieType())
{
case MovieType::ComedyType:
ComedyTree.insert(dynamic_cast<Comedy *>(movie));
break;
case MovieType::DramaType:
DramaTree.insert(dynamic_cast<Drama *>(movie));
break;
case MovieType::ClassicalType:
ClassicsTree.insert(dynamic_cast<Classics *>(movie));
break;
default:
throw new logic_error("Unexpected type");
}
}
}
}
示例2: backdropFinished
/**
* @brief Called when backdrop scraping has finished
* Starts the next backdrop download or tells the movie that scraping is done
*/
void Cinefacts::backdropFinished()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
reply->deleteLater();
Movie *movie = reply->property("storage").value<Storage*>()->movie();
QStringList backdrops = reply->property("backdrops").toStringList();
QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
if (!movie)
return;
if (reply->error() == QNetworkReply::NoError) {
QString msg = QString::fromUtf8(reply->readAll());
QRegExp rx("<a href=\"([^\"]*)\" target=\"_blank\">Bild in Originalgr..e</a>");
rx.setMinimal(true);
if (rx.indexIn(msg) != -1) {
Poster p;
p.thumbUrl = rx.cap(1);
p.originalUrl = rx.cap(1);
movie->addBackdrop(p);
}
if (!backdrops.isEmpty()) {
reply = qnam()->get(QNetworkRequest(QUrl(QString("http://www.cinefacts.de%1").arg(backdrops.takeFirst()))));
reply->setProperty("storage", Storage::toVariant(reply, movie));
reply->setProperty("backdrops", backdrops);
reply->setProperty("infosToLoad", Storage::toVariant(reply, infos));
connect(reply, SIGNAL(finished()), this, SLOT(backdropFinished()));
return;
}
}
movie->controller()->scraperLoadDone(this);
}
示例3: parseAndAssignInfos
void IMDB::onLoadFinished()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
reply->deleteLater();
Movie *movie = reply->property("storage").value<Storage*>()->movie();
QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
if (!movie)
return;
if (reply->error() == QNetworkReply::NoError ) {
QString msg = QString::fromUtf8(reply->readAll());
parseAndAssignInfos(msg, movie, infos);
QString posterUrl = parsePosters(msg);
if (infos.contains(MovieScraperInfos::Poster) && !posterUrl.isEmpty()) {
QNetworkReply *reply = qnam()->get(QNetworkRequest(posterUrl));
reply->setProperty("storage", Storage::toVariant(reply, movie));
reply->setProperty("infosToLoad", Storage::toVariant(reply, infos));
connect(reply, SIGNAL(finished()), this, SLOT(onPosterLoadFinished()));
} else {
movie->controller()->scraperLoadDone(this);
}
} else {
qWarning() << "Network Error (load)" << reply->errorString();
}
}
示例4: backdropFinished
/**
* @brief Called when backdrops are loaded
*/
void VideoBuster::backdropFinished()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
Movie *movie = reply->property("storage").value<Storage*>()->movie();
QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
reply->deleteLater();
if (!movie)
return;
if (reply->error() == QNetworkReply::NoError ) {
QString msg = reply->readAll();
QRegExp rx("href=\"https://gfx.videobuster.de/archive/resized/([^\"]*)\"(.*)([^<]*)<img (.*) src=\"https://gfx.videobuster.de/archive/resized/c110/([^\"]*)\"");
rx.setMinimal(true);
int pos = 0;
while ((pos = rx.indexIn(msg, pos)) != -1) {
pos += rx.matchedLength();
if (rx.cap(2).contains("titledtl_cover_pictures")) {
continue;
}
Poster p;
p.thumbUrl = QUrl(QString("https://gfx.videobuster.de/archive/resized/w700/%1").arg(rx.cap(5)));
p.originalUrl = QUrl(QString("https://gfx.videobuster.de/archive/resized/%1").arg(rx.cap(1)));
movie->addBackdrop(p);
}
} else {
qWarning() << "Network Error" << reply->errorString();
}
movie->controller()->scraperLoadDone();
}
示例5: while
void MovieCollection::topTen()
{
//creating a copy of the array
Movie tempArray[CAPACITY];
for (int i=0; i < mySize; i++)
{
tempArray[i] = myArray[i];
}
//sort the copied array by the number of times rented in descending order
for (int i=1; i < mySize; i++)
{
Movie tempMovie = tempArray[i];
int j = i-1;
while (j >= 0 && tempMovie.getNumTimesRented() >
tempArray[j].getNumTimesRented())
{
tempArray[j+1] = tempArray[j];
j = j-1;
}
tempArray[j+1] = tempMovie;
}
//output the first 10 movies of the array (if available)
int iterations = 10;
if (mySize < 10) {
iterations = mySize;
}
cout << "--------------------Top Ten---------------------" << endl;
for (int i=0; i < iterations; i++)
{
cout << "Movie: " << tempArray[i].getTitle() << " ";
cout << "Times Rented: " << tempArray[i].getNumTimesRented() << endl;
}
cout << "------------------------------------------------" << endl << endl;
}
示例6: p
void OmdbDataProvider::GetMovieList(string &path, vector<Movie> & movies){
fs::path p (path); // p reads clearer than argv[1] in the following code
try {
if (!fs::exists(p)){ // does p actually exist?
cout << p << " does not exist." << endl;
return;
}
if (fs::is_directory(p)){ // is p a directory?
vec v; // so we can sort them later
copy(fs::directory_iterator(p), fs::directory_iterator(), back_inserter(v));
sort(v.begin(), v.end()); // sort, since directory iteration
// is not ordered on some file systems
for (auto it = v.begin(); it != v.end(); ++it){
string fn = it->filename().string();
if(fn[0] == '.' && fn.size() > 1) continue;
size_t f = fn.find("(");
Movie m;
m.Set(FIELDS::NAME, fn.substr(0, f-1));
m.Set(FIELDS::YEAR, fn.substr(f+1, 4));
m.SetVotes(0);
m.SetRate(0);
movies.push_back(m);
}
}
}
catch (const fs::filesystem_error& ex){
cerr << ex.what() << endl;
// exit(EXIT_FAILURE);
return;
}
}
示例7: if
void Movie::LinkButton()
{
if (!visible || !active || !hasButton)
return;
for (int dlDepth = 0; dlDepth < data->depths; ++dlDepth) {
Object *obj = m_displayList[dlDepth].get();
if (obj) {
if (obj->IsButton()) {
((Button *)obj)->LinkButton();
} else if (obj->IsMovie()) {
Movie *movie = (Movie *)obj;
if (movie->hasButton)
movie->LinkButton();
}
}
}
if (!m_attachedMovies.empty()) {
AttachedMovieList::iterator it(m_attachedMovieList.begin()),
itend(m_attachedMovieList.end());
for (; it != itend; ++it)
if (it->second && it->second->hasButton)
it->second->LinkButton();
}
if (!m_attachedLWFs.empty()) {
AttachedLWFList::iterator
it(m_attachedLWFList.begin()), itend(m_attachedLWFList.end());
for (; it != itend; ++it)
if (it->second)
it->second->LinkButton();
}
}
示例8: findCustomer
bool StoreManager::checkIn(int customerId, int movieId)
{
Customer *customer = findCustomer(customerId);
Movie *movie = findMovie(movieId);
if (customer == NULL)
std::cout << "Customer not found.\n\n";
if (movie == NULL)
std::cout << "Movie not found.\n\n";
if (customer == NULL || movie == NULL)
return false;
std::set<Movie *> movies = customer->getMovies();
for (std::set<Movie *>::iterator it = movies.begin(); it != movies.end(); ++it)
{
if (*it == movie)
{
customer->removeMovie(movie);
movie->setInCount(movie->getInCount() + 1);
movie->setOutCount(movie->getOutCount() - 1);
return true;
}
}
std::cout << "That movie was not found in customer's profile.\n\n";
return false;
}
示例9: GetStringId
Button *LWF::SearchButtonInstance(string instanceName) const
{
size_t pos = instanceName.find(".");
if (pos != string::npos) {
vector<string> names = Utility::Split(instanceName, '.');
if (names[0] != data->strings[m_rootMovieStringId])
return 0;
Movie *m = rootMovie.get();
for (size_t i = 1; i < names.size(); ++i) {
if (i == names.size() - 1) {
return m->SearchButtonInstance(names[i], false);
} else {
m = m->SearchMovieInstance(names[i], false);
if (!m)
return 0;
}
}
return 0;
}
int stringId = GetStringId(instanceName);
if (stringId == -1)
return rootMovie->SearchButtonInstance(instanceName, true);
return SearchButtonInstance(stringId);
}
示例10: SearchInstanceId
int LWF::AddMovieEventHandler(
string instanceName, const MovieEventHandlerDictionary &h)
{
if (h.empty())
return -1;
int instId = SearchInstanceId(GetStringId(instanceName));
if (instId >= 0)
return AddMovieEventHandler(instId, h);
if (instanceName.find('.') == string::npos)
return -1;
MovieEventHandlersDictionary::iterator it =
m_movieEventHandlersByFullName.find(instanceName);
if (it == m_movieEventHandlersByFullName.end()) {
m_movieEventHandlersByFullName[instanceName] = MovieEventHandlers();
it = m_movieEventHandlersByFullName.find(instanceName);
}
int id = GetEventOffset();
it->second.Add(id, h);
Movie *m = SearchMovieInstance(instId);
if (m)
m->AddHandlers(&it->second);
return id;
}
示例11: in
vector<Movie*>MoFileRepo::findAll()
{
vector<Movie*> v;
Movie* pm;
ifstream in(fileName);
if(!in.is_open())
cout <<"Failed to open movies file!findAll()"<<fileName<<endl;
else
{
while(!in.eof())
{
pm = new Movie ;
cout<<v.size()<<"---------------------------------"<<endl;
in >> *pm;
if(pm->getTitle().length() == 0)
delete pm;
else{
v.push_back(pm);
}
cout<<v.size()<<"---------------------------------"<<endl;
}
in.close();
}
return v;
}
示例12:
shared_ptr<class LWF> LWFNode::attachLWF(
const char *pszFilename, const char *pszTarget, const char *pszAttachName)
{
if (!lwf)
return shared_ptr<class LWF>();
shared_ptr<LWFData> data =
LWFResourceCache::sharedLWFResourceCache()->loadLWFData(pszFilename);
if (!data)
return shared_ptr<class LWF>();
shared_ptr<LWFRendererFactory> factory =
make_shared<LWFRendererFactory>(this);
shared_ptr<class LWF> child = make_shared<class LWF>(data, factory);
if (!child) {
LWFResourceCache::sharedLWFResourceCache()->unloadLWFData(data);
return child;
}
Movie *movie = lwf->SearchMovieInstance(pszTarget);
if (!movie) {
LWFResourceCache::sharedLWFResourceCache()->unloadLWFData(data);
return shared_ptr<class LWF>();
}
movie->AttachLWF(child, pszAttachName);
return child;
}
示例13: create
Instruction* Borrow:: create(MovieStore* store, ifstream& infile) const {
int id;
Customer* customerToBeProcessed = NULL;
infile >> id;
if ((store->customers).retrieve(id, customerToBeProcessed)) {
char mediaT, movieT;
Movie* movieToBeSearch = NULL;
infile >> mediaT >> movieT;
movieToBeSearch = movieFactory->createSimpleIt(movieT, infile);
if (movieToBeSearch == NULL) {
string reading;
getline(infile, reading);
return NULL;
}
Movie* movieToBeProcessed = NULL;
if ((store->moviesDatabase)[hash(movieT)]->
retrieve(movieToBeSearch, movieToBeProcessed)) {
if (movieToBeProcessed->borrowType(mediaT, 1)) {
customerToBeProcessed->addOwn(movieToBeProcessed);
Borrow* newInstruction = new Borrow;
newInstruction->movie = movieToBeProcessed;
newInstruction->customer = customerToBeProcessed;
newInstruction->mediaType = mediaT;
newInstruction->customer->addHistory(newInstruction);
return newInstruction;
}
}
}
示例14:
ostream& operator<<(ostream& os, const ActIn& ai) {
Person p = ai.actorId;
os << "\t\tActor ID: " << p.getId() << endl;
Movie m = ai.movieId;
os << "\t\tMovie ID: " << m.getId() << endl;
return os;
}
示例15: foreach
void FilesWidget::unmarkForSync()
{
m_contextMenu->close();
foreach (const QModelIndex &index, ui->files->selectionModel()->selectedRows(0)) {
int row = index.model()->data(index, Qt::UserRole).toInt();
Movie *movie = Manager::instance()->movieModel()->movie(row);
movie->setSyncNeeded(false);
ui->files->update(index);
}
}