void OutputToFile(MovieInfo* moviePtr, //IN&OUT - keeps the first item on // the list ofstream &outFile) //OUT - output file variable { outFile << left; outFile << endl << endl; outFile << setw(75) << setfill('*') << '*'; outFile << setfill(' ') << endl; outFile << "Title: "; outFile << setw(51) << CheckTitle(moviePtr->title,50); outFile << endl; outFile << setw(75) << setfill('-') << '-'; outFile << setfill(' ') << endl; outFile << "Year: " << setw(12) << moviePtr->year; outFile << "Rating: " << moviePtr->rating << endl; outFile << setw(75) << setfill('-') << '-'; outFile << setfill(' ') << endl; outFile << setw(18) << "Leading Actor:" << setw(25); outFile << moviePtr->leadActor; outFile << "Genre 1: " << moviePtr->genre << endl; outFile << "Supporting Actor: " << setw(25); outFile << moviePtr->suppActor; outFile << "Genre 2: " << moviePtr->AltGenre << endl; outFile << setw(75) << setfill('-') << '-'; outFile << setfill(' ') << endl; outFile << "PLOT:" << endl; WordWrap(moviePtr->synopsis,75, outFile); outFile << setw(75) << setfill('*') << '*'; outFile << setfill(' ') << endl; outFile << endl << endl; outFile << right; }
void Client::EnableTitle(int titleset) { if (CheckTitle(titleset)) { return; } char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; if(!database.RunQuery(query,MakeAnyLenString(&query, "INSERT INTO player_titlesets (char_id, title_set) VALUES (%i, %i)", CharacterID(), titleset), errbuf)) { LogFile->write(EQEMuLog::Error, "Error in EnableTitle query for titleset %i and charid %i", titleset, CharacterID()); safe_delete_array(query); return; } else { safe_delete_array(query); return; } }
void Client::RemoveTitle(int titleset) { if (!CheckTitle(titleset)) { return; } char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; if (database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM player_titlesets WHERE `title_set`=%i AND `char_id`=%i", titleset, CharacterID()), errbuf)) { safe_delete_array(query); } else { LogFile->write(EQEMuLog::Error, "Error in RemoveTitle query '%s': %s", query, errbuf); safe_delete_array(query); } return; }
static bool FormatDecodedMETARLine(const TCHAR *line, unsigned length, const ParsedMETAR &parsed, tstring &output) { const TCHAR *end = line + length; const TCHAR *colon = (const TCHAR *)memchr(line, _T(':'), length); if (!colon) return false; unsigned title_length = colon - line; if (title_length == 0) return false; const TCHAR *value = colon + 1; while (*value == _T(' ')) value++; unsigned value_length = end - value; if (CheckTitle(line, title_length, _T("Wind"))) { StaticString<256> buffer; if (!parsed.wind_available) { buffer.Format(_T("%s: "), _("Wind")); buffer.append(value, value_length); } else { TCHAR wind_speed_buffer[16]; FormatUserWindSpeed(parsed.wind.norm, wind_speed_buffer, ARRAY_SIZE(wind_speed_buffer)); buffer.Format(_T("%s: %.0f" DEG " %s"), _("Wind"), (double)parsed.wind.bearing.Degrees(), wind_speed_buffer); } output += buffer; output += '\n'; return true; } if (CheckTitle(line, title_length, _T("Temperature"))) { StaticString<256> buffer; if (!parsed.temperatures_available) { buffer.Format(_T("%s: "), _("Temperature")); buffer.append(value, value_length); } else { TCHAR temperature_buffer[16]; FormatUserTemperature(parsed.temperature, temperature_buffer, ARRAY_SIZE(temperature_buffer)); buffer.Format(_T("%s: %s"), _("Temperature"), temperature_buffer); } output += buffer; output += '\n'; return true; } if (CheckTitle(line, title_length, _T("Dew Point"))) { StaticString<256> buffer; if (!parsed.temperatures_available) { buffer.Format(_T("%s: "), _("Dew Point")); buffer.append(value, value_length); } else { TCHAR temperature_buffer[16]; FormatUserTemperature(parsed.dew_point, temperature_buffer, ARRAY_SIZE(temperature_buffer)); buffer.Format(_T("%s: %s"), _("Dew Point"), temperature_buffer); } output += buffer; output += '\n'; return true; } if (CheckTitle(line, title_length, _T("Pressure (altimeter)"))) { StaticString<256> buffer; if (!parsed.qnh_available) { buffer.Format(_T("%s: "), _("Pressure")); buffer.append(value, value_length); } else { TCHAR qnh_buffer[16]; FormatUserPressure(parsed.qnh, qnh_buffer, ARRAY_SIZE(qnh_buffer)); buffer.Format(_T("%s: %s"), _("Pressure"), qnh_buffer); } output += buffer; output += '\n'; return true; } if (CheckTitle(line, title_length, _T("Visibility"))) { StaticString<256> buffer; buffer.Format(_T("%s: "), _("Visibility")); if (!parsed.qnh_available) { buffer.append(value, value_length); } else { TCHAR vis_buffer[32]; if (parsed.visibility >= 9999) { FormatUserDistanceSmart(fixed(10000), vis_buffer, ARRAY_SIZE(vis_buffer)); buffer.AppendFormat(_("more than %s"), vis_buffer); } else { FormatUserDistanceSmart(fixed(parsed.visibility), vis_buffer, ARRAY_SIZE(vis_buffer)); buffer += vis_buffer; } } output += buffer; output += '\n'; return true; } if (CheckTitle(line, title_length, _T("Sky conditions"))) { StaticString<256> buffer; buffer.Format(_T("%s: "), _("Sky Conditions")); StaticString<64> _value; _value.set(value, value_length); buffer += gettext(_value); output += buffer; output += '\n'; return true; } if (CheckTitle(line, title_length, _T("Weather"))) { StaticString<256> buffer; buffer.Format(_T("%s: "), _("Weather")); StaticString<64> _value; _value.set(value, value_length); buffer += gettext(_value); output += buffer; output += '\n'; return true; } StaticString<64> title; title.set(line, title_length); StaticString<256> buffer; buffer.Format(_T("%s: "), gettext(title.c_str())); buffer.append(value, value_length); output += buffer; output += '\n'; return true; }
static int CreateChoicesMenu( intf_thread_t *p_intf, GtkMenu *submenu, const char *psz_var, vlc_object_t *p_object, bool b_root ) { vlc_value_t val, val_list, text_list; int i_type, i; /* Check the type of the object variable */ i_type = var_Type( p_object, psz_var ); /* Make sure we want to display the variable */ if( !g_list_length(GTK_MENU_SHELL(submenu)->children) && IsMenuEmpty( psz_var, p_object, b_root ) ) return VLC_EGENERIC; switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: case VLC_VAR_FLOAT: break; default: /* Variable doesn't exist or isn't handled */ return VLC_EGENERIC; } if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, &text_list ) < 0 ) { return VLC_EGENERIC; } #define CURVAL val_list.p_list->p_values[i] #define CURTEXT text_list.p_list->p_values[i].psz_string for( i = 0; i < val_list.p_list->i_count; i++ ) { vlc_value_t another_val; char string[16] = {0}; char *menutext = string; switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VARIABLE: { GtkWidget *subsubmenu = gtk_menu_new(); GtkWidget *submenuitem = gtk_menu_item_new_with_label( CURTEXT ? CURTEXT : CURVAL.psz_string ); gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenuitem), subsubmenu); gtk_menu_append( submenu, submenuitem ); CreateChoicesMenu( p_intf, GTK_MENU(subsubmenu), CURVAL.psz_string, p_object, false ); break; } case VLC_VAR_STRING: var_Get( p_object, psz_var, &val ); another_val.psz_string = strdup( CURVAL.psz_string ); menutext = CURTEXT ? CURTEXT : another_val.psz_string; CreateAndConnect( p_intf, submenu, psz_var, menutext, "", ITEM_RADIO, p_object, another_val, i_type, val.psz_string && !strcmp( val.psz_string, CURVAL.psz_string ) ); free( val.psz_string ); break; case VLC_VAR_INTEGER: var_Get( p_object, psz_var, &val ); if( CURTEXT ) menutext = CURTEXT; else snprintf( menutext, sizeof(string)-1, "%"PRId64, CURVAL.i_int ); CreateAndConnect( p_intf, submenu, psz_var, menutext, "", ITEM_RADIO, p_object, CURVAL, i_type, ( CURVAL.i_int == val.i_int ) && CheckTitle( p_object, psz_var ) ); break; case VLC_VAR_FLOAT: var_Get( p_object, psz_var, &val ); if( CURTEXT ) menutext = CURTEXT; else snprintf( menutext, sizeof(string)-1, "%.2f", CURVAL.f_float ); CreateAndConnect( p_intf, submenu, psz_var, menutext, "", ITEM_RADIO, p_object, CURVAL, i_type, CURVAL.f_float == val.f_float ); break; default: break; } } /* clean up everything */ var_FreeList( &val_list, &text_list ); #undef CURVAL #undef CURTEXT return !g_list_length(GTK_MENU_SHELL(submenu)->children) ? VLC_EGENERIC : VLC_SUCCESS; }
int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var, vlc_object_t *p_object, bool b_root ) { vlc_value_t val, val_list, text_list; int i_type, i; /* Check the type of the object variable */ i_type = var_Type( p_object, psz_var ); /* Make sure we want to display the variable */ if( submenu->isEmpty() && IsMenuEmpty( psz_var, p_object, b_root ) ) return VLC_EGENERIC; switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: case VLC_VAR_FLOAT: break; default: /* Variable doesn't exist or isn't handled */ return VLC_EGENERIC; } if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, &text_list ) < 0 ) { return VLC_EGENERIC; } #define CURVAL val_list.p_list->p_values[i] #define CURTEXT text_list.p_list->p_values[i].psz_string for( i = 0; i < val_list.p_list->i_count; i++ ) { vlc_value_t another_val; QString menutext; QMenu *subsubmenu = new QMenu( submenu ); switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VARIABLE: CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false ); subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) ); submenu->addMenu( subsubmenu ); break; case VLC_VAR_STRING: var_Get( p_object, psz_var, &val ); another_val.psz_string = strdup( CURVAL.psz_string ); menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string ); CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO, p_object, another_val, i_type, val.psz_string && !strcmp( val.psz_string, CURVAL.psz_string ) ); free( val.psz_string ); break; case VLC_VAR_INTEGER: var_Get( p_object, psz_var, &val ); if( CURTEXT ) menutext = qfu( CURTEXT ); else menutext.sprintf( "%d", CURVAL.i_int ); CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO, p_object, CURVAL, i_type, ( CURVAL.i_int == val.i_int ) && CheckTitle( p_object, psz_var ) ); break; case VLC_VAR_FLOAT: var_Get( p_object, psz_var, &val ); if( CURTEXT ) menutext = qfu( CURTEXT ); else menutext.sprintf( "%.2f", CURVAL.f_float ); CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO, p_object, CURVAL, i_type, CURVAL.f_float == val.f_float ); break; default: break; } } currentGroup = NULL; /* clean up everything */ var_FreeList( &val_list, &text_list ); #undef CURVAL #undef CURTEXT return submenu->isEmpty() ? VLC_EGENERIC : VLC_SUCCESS; }
void SearchLinkedList(MovieInfo *head, Menu item, ofstream &outFile) { MovieInfo *itemPtr; itemPtr = head; string stringKey; int intKey; int counter; counter= 0; cout << left; switch(item) { case TITLESEARCH: cout << "\nWhich title are you looking for? "; getline(cin,stringKey); cout << "\nSearching for movie " << stringKey << endl ; break; case GENRESEARCH: cout << "\nWhat genre are you looking for? "; getline(cin, stringKey); cout << "\nSearching for genre " << stringKey << endl ; break; case ACTORSEARCH: cout << "\nWhat actor are you looking for? "; getline(cin, stringKey); cout << "\nSearching for the actor " << stringKey << endl ; break; case YEARSEARCH: // cout << "\nWhat year are you looking for? "; // cin >> intKey; intKey = IntErrorCheck("\nWhat year are you looking for? ", "**** The number is an invalid entry ****", "**** Please input a number between 1878 and 3000",1878,3000); cout << "\nSearching for the year" << endl; break; case RATINGSEARCH: cout << "\nWhat rating are you looking for? "; cin >> intKey; cout << "\nSearching for the rating" << endl ; break; } // if() // { // outFile << setw(9) << "MOVIE #"; // outFile << setw(50) << "TITLE"; // outFile << setw(6) << "YEAR"; // outFile << setw(8) << "RATING"; // outFile << setw(17) << "GENRE"; // outFile << setw(17) << "ALT GENRE"; // outFile << setw(20) << "LEAD ACTOR"; // outFile << setw(18) << "SUPPORTING ACTOR" << endl; // } while(itemPtr != NULL) { if(stringKey == itemPtr->genre || stringKey == itemPtr->AltGenre || stringKey == itemPtr->leadActor || stringKey == itemPtr->suppActor || intKey == itemPtr->rating || intKey == itemPtr->year) { outFile << setw(9) << counter + 1; outFile << setw(51) <<CheckTitle(itemPtr->title,45); outFile << setw(8) << itemPtr->year; outFile << setw(5) << itemPtr->rating ; outFile << setw(17) << itemPtr->genre; outFile << setw(17) << itemPtr->AltGenre ; outFile << setw(20) << itemPtr->leadActor; outFile << setw(18) << itemPtr->suppActor << endl; counter++; } else if(stringKey == itemPtr->title) { outFile << left << endl << endl; outFile << setw(75) << setfill('*') << '*' << setfill(' ') << endl; outFile <<"Title: "; outFile << setw(51) << CheckTitle(itemPtr->title,50); outFile << endl; outFile << setw(75) << setfill('-') << '-' << setfill(' ') << endl; outFile << "Year: " << setw(12) << itemPtr->year; outFile << "Rating: " << itemPtr->rating << endl; outFile << setw(75) << setfill('-') << '-' << setfill(' ') << endl; outFile << setw(18) << "Leading Actor:"<< setw(25) << itemPtr->leadActor; outFile << "Genre 1: " << itemPtr->genre << endl; outFile << "Supporting Actor: " << setw(25) << itemPtr->suppActor; outFile << "Genre 2: "<< itemPtr->AltGenre << endl; outFile << setw(75) << setfill('-') << '-' << setfill(' ') << endl; outFile << "PLOT:" << endl; WordWrap(itemPtr->synopsis,75, outFile); outFile << setw(75) << setfill('*') << '*' << setfill(' ') << endl; outFile << endl << endl; counter++; } itemPtr = itemPtr->next; } if(counter > 0) { cout << ""; if (item == TITLESEARCH) { cout <<"Found the movie \""<< stringKey << "\""; } else if(item == GENRESEARCH) { cout << "Found "<< counter << " movies for the genre " << stringKey; } else if (item == ACTORSEARCH) { cout << "Found "<< counter << " movies for the actor " << stringKey; } else if (item == YEARSEARCH) { cout << "Found "<< counter << " movies for the year " << intKey; } else if (item == RATINGSEARCH) { cout << "Found "<< counter << " movies for the rating " << intKey; } cout << "!"<< endl << endl; } else { cout << "Sorry, "; if (item == TITLESEARCH) { cout <<"the movie \""<< stringKey << "\" was not found " << endl; } else if(item == GENRESEARCH) { cout << "no movies for the genre, " << stringKey <<" were found" << endl; } else if (item == ACTORSEARCH) { cout << "no movies for the actor" << stringKey << " were found" << endl; } else if (item == YEARSEARCH) { cout << " no movies for the year" << intKey << " were found" << endl; } else if (item == RATINGSEARCH) { cout << "no movies for the year "<< intKey << " were found;" << endl; } } }