bool bHasSuffix(const Glib::ustring & _rsString, const Glib::ustring & _rsSuffix, bool _bCaseSensitive) { if (_rsSuffix.size() > _rsString.size()) { return false; } Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size()); if (_bCaseSensitive) { if (_rsSuffix == sEnd) { return true; } } else { if (_rsSuffix.lowercase() == sEnd.lowercase()) { return true; } } return false; }
void Document::setField (Glib::ustring const &field, Glib::ustring const &value) { DEBUG (String::ucompose ("%1 : %2", field, value)); if (field == "doi") bib_.setDoi (value); else if (field.lowercase() == "title") bib_.setTitle (value); else if (field.lowercase() == "volume") bib_.setVolume (value); else if (field.lowercase() == "number") bib_.setIssue (value); else if (field.lowercase() == "journal") bib_.setJournal (value); else if (field.lowercase() == "author") bib_.setAuthors (value); else if (field.lowercase() == "year") bib_.setYear (value); else if (field.lowercase() == "pages") bib_.setPages (value); else if (field == "key") setKey (value); else { /* The extras map uses a case-folding comparator */ bib_.extras_[field] = value; } }
int MemberList::on_sort_compare(const Gtk::TreeModel::iterator& a, const Gtk::TreeModel::iterator& b) { int result; if ((result = (*b)[columns.affiliation] - (*a)[columns.affiliation]) == 0) { if ((result = (*a)[columns.presence] - (*b)[columns.presence]) == 0) { Glib::ustring an = (*a)[columns.name]; Glib::ustring bn = (*b)[columns.name]; result = an.lowercase().compare(bn.lowercase()); } } return result; }
void SearchNotesWidget::perform_search() { // For some reason, the matches column must be rebuilt // every time because otherwise, it's not sortable. remove_matches_column(); Search search(m_manager); Glib::ustring text = m_search_text; if(text.empty()) { m_current_matches.clear(); m_store_filter->refilter(); if(m_tree->get_realized()) { m_tree->scroll_to_point (0, 0); } return; } text = text.lowercase(); m_current_matches.clear(); // Search using the currently selected notebook notebooks::Notebook::Ptr selected_notebook = get_selected_notebook(); if(dynamic_pointer_cast<notebooks::SpecialNotebook>(selected_notebook)) { selected_notebook = notebooks::Notebook::Ptr(); } Search::ResultsPtr results = search.search_notes(text, false, selected_notebook); // if no results found in current notebook ask user whether // to search in all notebooks if(results->size() == 0 && selected_notebook != NULL) { no_matches_found_action(); } else { for(Search::Results::const_reverse_iterator iter = results->rbegin(); iter != results->rend(); iter++) { m_current_matches[iter->second->uri()] = iter->first; } add_matches_column(); m_store_filter->refilter(); if(m_tree->get_realized()) { m_tree->scroll_to_point(0, 0); } } }
Glib::ustring string_to_lower(const Glib::ustring & source) { return source.lowercase(); }
void Stroke::set_join(const Glib::ustring & c) { if ( c.lowercase() == "miter" ) this->set_join( Cairo::LINE_JOIN_MITER ); else if ( c.lowercase() == "round" ) this->set_join( Cairo::LINE_JOIN_ROUND ); else if ( c.lowercase() == "bevel" ) this->set_join( Cairo::LINE_JOIN_BEVEL ); }
void Stroke::set_cap(const Glib::ustring & c) { if ( c.lowercase() == "butt" ) this->set_cap( Cairo::LINE_CAP_BUTT ); else if ( c.lowercase() == "round" ) this->set_cap( Cairo::LINE_CAP_ROUND ); else if ( c.lowercase() == "square" ) this->set_cap( Cairo::LINE_CAP_SQUARE ); }
void MySaxParser::on_characters(const Glib::ustring& text) { /*if(flag==1) { docID.clear(); docID=text; flag=2; }*/ //else //{ /* if(countFlush==1) { cout<<"count is 1"<<endl; flushTofile(); countFlush=0; } countFlush++;*/ string charFlag; string s; try { if(TITLE) { docID.clear(); s=text.lowercase(); strs.clear(); newStr.clear(); if(prevStr.size()!=0) s=prevStr+s; boost::split(strs,s, boost::is_any_of("\"=,|][_:{}<>!-' .//*()\n#$%&*@1234567890^-+~?;\\\t\r"),boost::token_compress_on); //tokenize prevStr.clear(); prevStr=strs[strs.size()-1]; charFlag="t"; for(size_t i=0;i<strs.size()-1;i++) { if(myArray.find(strs[i]) == myArray.end() && boost::all(strs[i],boost::is_alpha())) { Porter2Stemmer::stem(strs[i]); newStr.push_back(strs[i]); docWord++; //Words[strs[i]][docID][charFlag]+=1; } } } if(ID && !REVISION) { docID.clear(); docID=text; tempdoc=docID; for(size_t i=0;i<newStr.size();i++) Words[newStr[i]][docID]["t"]+=1; } if(TEXT) { s=text.lowercase(); strs.clear(); //newStr.clear(); if(prevStr.size()!=0) s=prevStr+s; boost::split(strs,s, boost::is_any_of("\",|][:}<>!-_' .//*()\n#$%&*@1234567890^-+~?;\\\t\r"),boost::token_compress_on); //tokenize prevStr.clear(); prevStr=strs[strs.size()-1]; for(size_t i=0;i<strs.size()-1;i++) { if(strs[i].find("{{infobox")!=string::npos) INFOBOX=true; else if(strs[i]=="footnotes") INFOBOX=false; if(strs[i]=="==external") LINK=true; else if(strs[i]=="category") { CATEGORY=true; LINK=false; } if(strs[i]=="ca" && CATEGORY==true) CATEGORY=false; if(myArray.find(strs[i]) == myArray.end() && boost::all(strs[i],boost::is_alpha())) { strs[i].erase (std::remove(strs[i].begin(), strs[i].end(), '{'), strs[i].end()); strs[i].erase (std::remove(strs[i].begin(), strs[i].end(), '='), strs[i].end()); Porter2Stemmer::stem(strs[i]); docWord++; //newStr.push_back(strs[i]); if(INFOBOX) charFlag="i"; else { if(LINK) charFlag="l"; else { if(CATEGORY) charFlag="c"; else charFlag="b"; } } Words[strs[i]][docID][charFlag]+=1;// for phase 2 //Words[strs[i]].insert(docID); } } //for(size_t i=0;i<newStr.size();i++) //cout<<newStr[i]<<" "; //std::cout << "on_characters(): " << text << std::endl; } } catch(const Glib::ConvertError& ex) { std::cerr << "MySaxParser::on_characters(): Exception caught while converting text for std::cout: " << ex.what() << std::endl; } // } }