bool MovieSearch(MovieNode* searchNode,		//The current node to search
											//					IN
				 MenuOptions command,		//The type of search to be done
				 	 	 	 	 	 	 	//					IN & CALC
				 string keyS,				//sed for string search IN
				 int keyI)					//Used for int search 	 IN
{
	//VARIABLE LIST
	bool found;		//this is the return value.  when the searchNode == the
					// key value, it returns true

	//INITIALIZE - set found to false
	found = false;

	if(keyS != "DUMMY VALUE")
	{
		keyS = StringToUpper(keyS);
	}

	//SWITCH - runs the appropriate check depending on which command was
	// 				chosen
	switch(command)
		{
		//ENTIRE LIST - always true so that every movie is sent to the file
		case ENTIRE_LIST   : found = true;
							 break;

		//GENRE - search by eoither primary genre or alternative genre
		case GENRE_SEARCH  : found = (StringToUpper(searchNode->genre)
									  == keyS
									  ||
									  StringToUpper(searchNode->altGenre)
									  == keyS);
							 break;

		//ACTOR	- search either the lead or the supporting actor
		case ACTOR_SEARCH  : found = (StringToUpper(searchNode->lead)
									  == keyS
									  ||
									  StringToUpper(searchNode->support)
									  == keyS);
							 break;

		//YEAR - compare the int key to the year of the movie
		case YEAR_SEARCH   : found = (searchNode->year == keyI);
							 break;

		//RATING - compare the int key to the rating of the movie
		case RATING_SEARCH : found = (searchNode->rating == keyI);
							 break;

		//used just in case one of the other MenuOptions gets passed in
		// somehow
		default			   : cout <<"\nERROR:MovieSearch Function";
							 break;
		}

	//return whether or not a match was found.
	return found;
}
Esempio n. 2
0
/* Will list all the files which have the given extension 
* extension: The extension (without the dot)
* putExtension: If the extension should be displayed
*/
std::vector<std::string> FileSyst::GetFilesPathByExtension(std::string extension, bool putExtension){
	std::vector<std::string> result;
	std::vector<directoryvector>::iterator i;
	std::vector<file>::iterator j;
	extension = StringToUpper(extension);

	//for every file
	for (i = directories.begin(); i != directories.end(); i++){
		for (j = (*i).files.begin(); j != (*i).files.end(); j++){

			//if the file has the right extension
			std::string fileExtension = StringToUpper( (*j).extension );
			if (extension == fileExtension){
				//if extension + fileName are needed
				if (putExtension) { 
					result.push_back( (*i).path + "\\" + (*j).fileName + "." + (*j).extension ); }
				//if the fileName is needed
				else { 
					result.push_back( (*i).path + "\\" + (*j).fileName ); }

			}
		}
	}

	return result;
}
Esempio n. 3
0
bool	HasExtNoCase(const string& inStr, const char * inExt)
{
	string s(inStr);
	string e(inExt);
	StringToUpper(s);
	StringToUpper(e);
	
	
	if (s.rfind(e) == (s.length() - e.length()))
		return true;
	return false;
}
/******************************************************************************
* ++
* Method name : CListStudent::Update(string sID)
* Description : Cap nhat thong tin sinh vien
*
* Parameters :
*		string sID: ma cua sinh vien can cap nhat thong tin
* Return values :
*		IS_SUCCESS	:	cap nhat thanh cong
*		NOT_SUCCESS	:	cap nhat khong thanh cong
* --
*****************************************************************************/
bool CListStudent::Update(string sID)
{
	//Tien hanh lay sinh vien co ma la chuoi truyen vao
	CStudent* cStudent = this->GetStudentByID(sID);

	if(cStudent)	//Neu sinh vien ton tai
	{
		//Nhap thong tin sinh vien
		cStudent->InputInformation();

		//Lay ma lop sau khi nhap thong tin
		string sString = cStudent->GetClassID();
		//Neu ma lop khong ton tai
		while(g_cSchool->GetListClass()->IsValidateClass(sString))
		{
			cout<<endl<<"Class ID is not exist, please enter another Class ID!"<<endl;

			//Tien hanh nhap lai ma lop
			cout<<"Class ID: ";
			InputString(sString);
			sString = StringToUpper(sString);
		}
		cStudent->SetClassID(sString);	//Gan gia tri moi cho ma lop

		return IS_SUCCESS;
	}
	return NOT_SUCCESS;
}
Esempio n. 5
0
void MostrarPropriedade(Noticia * noticia, char * nomePropriedade){
	char * nomePropriedadeMaiuscula = StringToUpper(nomePropriedade);
	if (strcmp(nomePropriedadeMaiuscula, "TITLE") == 0){
		MarcarMostrarObjetoNaNoticia(noticia, Title);
	}
	else if (strcmp(nomePropriedadeMaiuscula, "ABSTRACT") == 0){
		MarcarMostrarObjetoNaNoticia(noticia, Abstract);
	}
	else if (strcmp(nomePropriedadeMaiuscula, "AUTHOR") == 0){
		MarcarMostrarObjetoNaNoticia(noticia, Author);
	}
	else if (strcmp(nomePropriedadeMaiuscula, "DATE") == 0){
		MarcarMostrarObjetoNaNoticia(noticia, Date);
	}
	else if (strcmp(nomePropriedadeMaiuscula, "IMAGE") == 0){
		MarcarMostrarObjetoNaNoticia(noticia, Image);
	}
	else if (strcmp(nomePropriedadeMaiuscula, "SOURCE") == 0){
		MarcarMostrarObjetoNaNoticia(noticia, Source);
	}
	else if (strcmp(nomePropriedadeMaiuscula, "TEXT") == 0){
		MarcarMostrarObjetoNaNoticia(noticia, Text);
	}
	else{
		fprintf(stderr, "\nWarning - Token nao reconhecido\n");
	}
	free(nomePropriedadeMaiuscula);
}
/******************************************************************************
* ++
* Method name :CSubject::Input()
* Description : Nhap thong tin cho mon hoc bao gom ca ma mon hoc
* --
*****************************************************************************/
void CSubject::Input()
{
	//Tien hanh nhap ma mon hoc
	cout<<"Subject ID: ";
	InputString(this->m_sID);
	//Chuyen ma mon hoc sang kieu in hoa
	this->m_sID = StringToUpper(this->m_sID);
	
	//Tien hanh nhap thong tin mon hoc
	this->InputInformation();
}
Esempio n. 7
0
/** Sets the Text of the current control */
void Button::SetText(const String& string)
{
	Text = string;
	if (string.length()) {
		if (Flags&IE_GUI_BUTTON_LOWERCASE)
			StringToLower( Text );
		else if (Flags&IE_GUI_BUTTON_CAPS)
			StringToUpper( Text );
		hasText = true;
	} else {
		hasText = false;
	}
	MarkDirty();
}
/******************************************************************************
* ++
* Method name : CListStudent::CreateStudent()
* Description : Tao moi mot sinh vien
*
* Return values :
*		cStudent : sinh vien moi tao
* --
*****************************************************************************/
CStudent* CListStudent::CreateStudent()
{
	//Khoi tao sinh vien moi
	CStudent* cStudent = new CStudent();

	//Tien hanh nhap du lieu cho sinh vien
	cStudent->Input();

	string sString = cStudent->GetID();
	//Neu ma sinh vien da ton tai
	while(IsValidateStudent(sString) == NOT_VALIDATE)
	{
		cout<<endl<<"ID is inserted, please enter new ID!"<<endl;

		//Tien hanh nhap lai ma sinh vien
		cout<<"ID: ";
		InputString(sString);
		//Chuyen ma sinh vien sang kieu in hoa
		sString = StringToUpper(sString);
	}
	cStudent->SetID(sString);

	sString = cStudent->GetClassID();
	//Neu ma lop khong ton tai
	while(g_cSchool->GetListClass()->IsValidateClass(sString) == IS_VALIDATE)
	{
		cout<<endl<<"Class ID is not exist, please enter another Class ID!"<<endl;

		//Tien hanh nhap lai ma lop
		cout<<"Class ID: ";
		InputString(sString);
		sString = StringToUpper(sString);
	}
	cStudent->SetClassID(sString);	//Gan gia tri moi cho ma lop

	return cStudent;
}
inline void server_config::configline(string line)
{
	if(line.size() == 0) return;
	unsigned int i;
	for(i = 0; i < line.size(); i++)
	{
		if(line[i] == '#') return;
		if(line[i] != ' ') break;
	}

	string option = "";
	for(i = i; i < line.size(); i ++)
	{
		if(line[i] != '=' && line[i] != ' ')
			option += line[i];
		else
			break;
	}
	for(i = i; i < line.size(); i++)
	{
		if(!(line[i] == ' ' || line[i] == '='))
			break;
	}
	string value = "";
	for(i = i; i < line.size();i++)
	{
		if(line[i] != ' ' && line[i] != '\n' && line[i] != '\r')
			value += line[i];
		else
			break;
	}

	option = StringToUpper(option);
	
	if(conlog)
	cout << option << " : " << value << endl;


	optmap.insert(pair<string,string>(option,value));

}
Esempio n. 10
0
//Os argumentos precisam ser strings bem formadas (com NUL no final). Todos os objetos sao reinstanciados, ou seja, pode dar free nos fontes depois
//Nao mudar abstrac para abstract. Palavra reservada.
Noticia NewNoticia(char * nomeObjeto, char * title, char * abstrac, char * author, char * date, char * image, char * source, char * text, int numCol){
	Noticia retorno;
	int i = 0;

	retorno.NomeObjeto = (char *)calloc(strlen(nomeObjeto) + 1, sizeof(char));
	retorno.NomeObjeto = StringToUpper(nomeObjeto);

	retorno.Abstract = (char*)calloc(strlen(abstrac) + 1, sizeof(char));
	strcpy(retorno.Abstract, abstrac);

	retorno.Author = (char*)calloc(strlen(author) + 1, sizeof(char));
	strcpy(retorno.Author, author);

	retorno.Date = (char*)calloc(strlen(date) + 1, sizeof(char));
	strcpy(retorno.Date, date);

	retorno.Image = (char*)calloc(strlen(image) + 1, sizeof(char*));
	strcpy(retorno.Image, image);

	retorno.Source = (char *)calloc(strlen(source) + 1, sizeof(char));
	strcpy(retorno.Source, source);

	retorno.Text = (char *)calloc(strlen(text), sizeof(char));
	strcpy(retorno.Text, text);

	retorno.Title = (char *)calloc(strlen(title), sizeof(char));
	strcpy(retorno.Title, title);

	retorno.numCol = numCol;

	for (i = 0; i < 7; i++){
		retorno.listaPropriedades[i] = Invalido;
	}

	retorno.buscada = 0;
	retorno.posicaoNoticia = -1;
	return retorno;
}
/******************************************************************************
* ++
* Method name : CListSubject::CreateSubject()
* Description : Tao moi mot mon hoc
*
* Return values :
*		cSubject : mon hoc moi tao
* --
*****************************************************************************/
CSubject* CListSubject::CreateSubject()
{
	//Khoi tao mon hoc moi
	CSubject* cSubject = new CSubject();

	//Tien hanh nhap thong tin mon hoc moi
	cSubject->Input();

	//Tien hanh kiem tra ma mon hoc co hop le
	string sString = cSubject->GetID();
	//Neu ma mon hoc khong hop le
	while(IsValidateSubject(sString) == NOT_VALIDATE)
	{
		//Tien hanh nhap lai ma mon hoc
		cout<<endl<<"Subject ID is inserted, please enter new ID!"<<endl;
		cout<<"Subject ID: ";
		InputString(sString);
		//Chuyen ma mon hoc sang kieu in hoa
		sString = StringToUpper(sString);
	}
	cSubject->SetID(sString);

	return cSubject;
}
Esempio n. 12
0
//Sinaliza que a noticia apontada deve ser impressa no final.
//nomeToken eh o nome da noticia digitado no codigo que vem do token
//Se nao achar a noticia na lista joga no stderror que o usuario digitou alguma besteira
//Deve ser chamado na ordem do structure da news, pois a ordem de chamada influencia
//na hora da leitura
void MarcarNoticiaParaExibicao(ListaNoticias * listaNoticias, char * nomeToken){
	int ultimaNoticia = -2;
	char *nomeTokenMaiusculo = StringToUpper(nomeToken); //Precisa converter o nome do token para maiusculas, pois o nome do objeto eh sempre em maiusculas (para ser case insensitive)
	int i = 0;

	for (i = 0; i < (*listaNoticias).tamanho; i++){ //pega a posicao atribuida da ultima noticia
		if ((*listaNoticias).valores[i].posicaoNoticia > ultimaNoticia)
			ultimaNoticia = (*listaNoticias).valores[i].posicaoNoticia;
	}
	ultimaNoticia++; //Representa a posicao da proxima noticia

	//Faz a busca na lista
	for (i = 0; i < (*listaNoticias).tamanho; i++){
		if (strcmp((*listaNoticias).valores[i].NomeObjeto, nomeTokenMaiusculo) == 0 && (*listaNoticias).valores[i].posicaoNoticia == -1){
			(*listaNoticias).valores[i].posicaoNoticia = ultimaNoticia;
			free(nomeTokenMaiusculo);
			return;
		}
	}

	fprintf(stderr, "\nWarning: Noticia %s nao faz parte das noticias declaradas\n", nomeTokenMaiusculo);
	free(nomeTokenMaiusculo);
	return;
}
Esempio n. 13
0
void AdicionarChave(DicionarioNoticia * dic, char * chave, char * valor){
	char * chaveMaiuscula = StringToUpper(chave);
	if (strcmp(chaveMaiuscula, "TITLE") == 0){
		if (strcmp((*dic).Title, "") == 0){
			free((*dic).Title);
			(*dic).Title = (char *)calloc(strlen(valor) + 1, sizeof(char));
			strcpy((*dic).Title, valor);
		}
		else{
			fprintf(stderr, "\nWarning - Atributo TITLE repetido no jornal\n");
		}
	}
	else if (strcmp(chaveMaiuscula, "ABSTRACT") == 0){
		if (strcmp((*dic).Abstract, "") == 0){
			free((*dic).Abstract);
			(*dic).Abstract = (char *)calloc(strlen(valor) + 1, sizeof(char));
			strcpy((*dic).Abstract, valor);
		}
		else{
			fprintf(stderr, "\nWarning - Atributo ABSTRACT repetido no jornal\n");
		}
	}
	else if (strcmp(chaveMaiuscula, "AUTHOR") == 0){
		if (strcmp((*dic).Author, "") == 0){
			free((*dic).Author);
			(*dic).Author = (char *)calloc(strlen(valor) + 1, sizeof(char));
			strcpy((*dic).Author, valor);
		}
		else{
			fprintf(stderr, "\nWarning - Atributo AUTHOR repetido no jornal\n");
		}
	}
	else if (strcmp(chaveMaiuscula, "DATE") == 0){
		if (strcmp((*dic).Date, "") == 0){
			free((*dic).Date);
			(*dic).Date = (char *)calloc(strlen(valor) + 1, sizeof(char));
			strcpy((*dic).Date, valor);
		}
		else{
			fprintf(stderr, "\nWarning - Atributo DATE repetido no jornal\n");
		}
	}
	else if (strcmp(chaveMaiuscula, "IMAGE") == 0){
		if (strcmp((*dic).Image, "") == 0){
			free((*dic).Image);
			(*dic).Image = (char *)calloc(strlen(valor) + 1, sizeof(char));
			strcpy((*dic).Image, valor);
		}
		else{
			fprintf(stderr, "\nWarning - Atributo IMAGE repetido no jornal\n");
		}
	}
	else if (strcmp(chaveMaiuscula, "SOURCE") == 0){
		if (strcmp((*dic).Source, "") == 0){
			free((*dic).Source);
			(*dic).Source = (char *)calloc(strlen(valor) + 1, sizeof(char));
			strcpy((*dic).Source, valor);
		}
		else{
			fprintf(stderr, "\nWarning - Atributo SOURCE repetido no jornal\n");
		}
	}
	else if (strcmp(chaveMaiuscula, "TEXT") == 0){
		if (strcmp((*dic).Text, "") == 0){
			free((*dic).Text);
			(*dic).Text = (char *)calloc(strlen(valor) + 1, sizeof(char));
			strcpy((*dic).Text, valor);
		}
		else{
			fprintf(stderr, "\nWarning - Atributo TEXT repetido no jornal\n");
		}
	}
	else{
		fprintf(stderr, "\nWarning - Atributo desconhecido no jornal\n");
	}


	free(chaveMaiuscula);
}