本文整理汇总了C++中WebPage::filename方法的典型用法代码示例。如果您正苦于以下问题:C++ WebPage::filename方法的具体用法?C++ WebPage::filename怎么用?C++ WebPage::filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebPage
的用法示例。
在下文中一共展示了WebPage::filename方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: looks_for_webpage
WebPage* SearchEng::looks_for_webpage(std::string filename) {
for(MySetWebPage::iterator it = allPages.begin();it != allPages.end(); ++it) {
WebPage* tempPage = *it;
if( tempPage->filename() == filename) {
return *it;
}
}
WebPage* newPage = new WebPage;
newPage->filename(filename);
allPages.insert(newPage);
return newPage;
}
示例2:
bool
WebPage::operator== (const WebPage & web)
{
return fname == web.filename (); //check if they have the same filename
}
示例3: add_parse_page
void SearchEng::add_parse_page(std::string filename,
PageParser* parser) {
MySetString currentWords;
MySetString currentLinks_strings;
parser->parse(filename, currentWords, currentLinks_strings);
std::cout << "Just ran parse" << std::endl;
WebPage* currentPage = new WebPage;
currentPage->filename( filename );
currentPage->all_words(currentWords);
for( MySetString::iterator it = currentLinks_strings.begin(); it != currentLinks_strings.end(); ++it) {
currentPage->add_outgoing_link(looks_for_webpage(*it));
//Need to deal with links still
/*MySetString::iterator it2 = allPages.find(*it);
if(it2 != allPages.end() ) {
currentPage->add_outgoing_link(it);
}*/
}
allPages.insert(currentPage);
// std::cout << "inserted page" << std::endl; //debug
MySetString::iterator it;
for( it = currentWords.begin(); it != currentWords.end(); ++it ) { // makes wordMap;
std::string word = *it;
makeLower(word);
std::map<std::string, MySetWebPage>::iterator it2 = wordMap.find(word);
//std::cout << "trying to insert: " << word << std::endl; //debug
if(it2 != wordMap.end()) {
it2->second.insert(currentPage);
//std::cout << "added page to " << it2->first << std::endl; //debug
} else {
MySetWebPage newSet;
newSet.insert( currentPage );
wordMap.insert( make_pair(word, newSet));
//std::cout << "inserted: " << word << std::endl; //debug
}
//std::cout << "went through for loop" << std::endl; //debug
}
//deals with all incoming links;
MySetWebPage::iterator it3;
for( it3 = allPages.begin(); it3!= allPages.end(); ++it3) {
WebPage* outgoingPage = *it3;
MySetWebPage outgoingLinks = outgoingPage->outgoing_links();
MySetWebPage::iterator it4;
for( it4 = outgoingLinks.begin(); it4 != outgoingLinks.end(); ++it4) {
WebPage* incomingPage = *it4;
incomingPage->add_incoming_link(outgoingPage);
}
}
//delete currentPage;
return;
}
示例4: search
void MainWin::search(){
results->clear();
string input = txtSearch->text().toStdString();
for(int j = 0; input[j]; j++){ //converts to lower case and checks for valid input
if(input[j] != ' ' && !isalnum(input[j])){
QMessageBox *message = new QMessageBox;
message->setWindowTitle("Error!");
message->setText("Invalid search. \nIs your input alphanumeric?");
message->show();
return void();
}
else
input[j] = tolower(input[j]);
}
try{
Set<WebPage*> result;
char cinput[input.size()+1];
strcpy(cinput, input.c_str()); //convert to char* to tokenize
char* cword1 = strtok(cinput," "); //extract first word
string word1(cword1); //convert char* to string to trim and input into set
trim(word1);
Set<WebPage*> and1 = words.at(word1);
result = and1;
if(btnAnd->isChecked()){
cword1 = strtok(NULL," "); //could just do ", " to get rid of leading white space
while(cword1!=NULL){ //but i already made the trim function so too bad
string word2(cword1); //essentially doing what I did above
trim(word2);
Set<WebPage*> and2 = words.at(word2);
result = and1.setIntersection(and2); //check for intersections
Set<WebPage*> and1 = result; //*** resets and1 to be result thus and2 will check for
cword1 = strtok(NULL," "); //an intersection of previous words
}
}
else if (btnOr->isChecked()){
cword1 = strtok(NULL," "); //could just do ", " to get rid of leading white space
while(cword1!=NULL){ //but i already made the trim function so too bad
string word2(cword1);
trim(word2);
Set<WebPage*> and2 = words.at(word2);
result = and1.setUnion(and2);
Set<WebPage*> and1 = result;
cword1 = strtok(NULL," ");
}
}
if(result.size() == 0){
QMessageBox *message = new QMessageBox;
message->setWindowTitle("Error!");
message->setText("No search results.");
message->show();
}
else{
for(Set<WebPage*>::iterator it = result.begin(); it != result.end(); ++it){
WebPage* wp = *it;
results->addItem(QString::fromStdString(wp->filename()));
}
}
}
catch(logic_error &e){
QMessageBox *message = new QMessageBox;
message->setWindowTitle("Error!");
message->setText("No search results.");
message->show();
}
}