本文整理汇总了C++中WordList类的典型用法代码示例。如果您正苦于以下问题:C++ WordList类的具体用法?C++ WordList怎么用?C++ WordList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WordList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replaceWordsInCurrentEditor
void SpellCheckerCore::replaceWordsInCurrentEditor(const WordList &wordsToReplace, const QString &replacementWord)
{
if(wordsToReplace.count() == 0) {
Q_ASSERT(wordsToReplace.count() != 0);
return;
}
if(d->currentEditor == NULL) {
Q_ASSERT(d->currentEditor != NULL);
return;
}
TextEditor::TextEditorWidget* editorWidget = qobject_cast<TextEditor::TextEditorWidget*>(d->currentEditor->widget());
if(editorWidget == NULL) {
Q_ASSERT(editorWidget != NULL);
return;
}
QTextCursor cursor = editorWidget->textCursor();
/* Iterate the words and replace all one by one */
foreach(const Word& wordToReplace, wordsToReplace) {
editorWidget->gotoLine(wordToReplace.lineNumber, wordToReplace.columnNumber - 1);
int wordStartPos = editorWidget->textCursor().position();
editorWidget->gotoLine(wordToReplace.lineNumber, wordToReplace.columnNumber + wordToReplace.length - 1);
int wordEndPos = editorWidget->textCursor().position();
cursor.beginEditBlock();
cursor.setPosition(wordStartPos);
cursor.setPosition(wordEndPos, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
cursor.insertText(replacementWord);
cursor.endEditBlock();
}
示例2: giveSuggestionsForWordUnderCursor
void SpellCheckerCore::giveSuggestionsForWordUnderCursor()
{
if( d->currentEditor.isNull() == true ) {
return;
}
Word word;
WordList wordsToReplace;
bool wordMistake = isWordUnderCursorMistake( word );
if( wordMistake == false ) {
return;
}
getAllOccurrencesOfWord( word, wordsToReplace );
SuggestionsDialog dialog( word.text, word.suggestions, wordsToReplace.count() );
SuggestionsDialog::ReturnCode code = static_cast<SuggestionsDialog::ReturnCode>( dialog.exec() );
switch( code ) {
case SuggestionsDialog::Rejected:
/* Cancel and exit */
return;
case SuggestionsDialog::Accepted:
/* Clear the list and only add the one to replace */
wordsToReplace.clear();
wordsToReplace.append( word );
break;
case SuggestionsDialog::AcceptAll:
/* Do nothing since the list of words is already valid */
break;
}
QString replacement = dialog.replacementWord();
replaceWordsInCurrentEditor( wordsToReplace, replacement );
}
示例3: ColouriseWord
static void ColouriseWord(StyleContext& sc, WordList& keywords, WordList& keywords2, WordList& keywords3, bool& apostropheStartsAttribute) {
apostropheStartsAttribute = true;
sc.SetState(SCE_SPICE_IDENTIFIER);
std::string word;
while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) {
word += static_cast<char>(tolower(sc.ch));
sc.Forward();
}
if (keywords.InList(word.c_str())) {
sc.ChangeState(SCE_SPICE_KEYWORD);
if (word != "all") {
apostropheStartsAttribute = false;
}
}
else if (keywords2.InList(word.c_str())) {
sc.ChangeState(SCE_SPICE_KEYWORD2);
if (word != "all") {
apostropheStartsAttribute = false;
}
}
else if (keywords3.InList(word.c_str())) {
sc.ChangeState(SCE_SPICE_KEYWORD3);
if (word != "all") {
apostropheStartsAttribute = false;
}
}
sc.SetState(SCE_SPICE_DEFAULT);
}
示例4: WordList
DictViewInstance::WordList *DictViewInstance::WordSuggestion(FarStringW &word)
{
WordList *wl = new WordList();
_current_color = -1;
_current_word = word;
DecisionTable::action_inst_t act_inst = logic.Execute();
Action *action = static_cast<Action *>(act_inst->client_context);
far_assert(action);
FarString suggestion_order = action->suggestions;
if (suggestion_order.IsEmpty())
for (int i = 0; i<DictCount(); i++)
suggestion_order += GetDict(i)->dict + ';';
if (suggestion_order.IsEmpty())
return wl;
FarStringTokenizer dicts(suggestion_order, ';');
for (int i = 0; i < DictCount() && dicts.HasNext(); i++)
{
const FarString &dict(dicts.NextToken());
for (int j = 0; j < DictCount(); j++)
if (GetDict(j)->dict == dict) {
far_assert(spell_factory);
SpellInstance *dict_inst = spell_factory->GetDictInstance(dict);
far_assert(dict_inst);
wl->Add(dict_inst->Suggest(word));
}
}
return wl;
}
示例5: isWordUnderCursorMistake
bool SpellCheckerCore::isWordUnderCursorMistake(Word& word) const
{
if(d->currentEditor.isNull() == true) {
return false;
}
unsigned int column = d->currentEditor->currentColumn();
unsigned int line = d->currentEditor->currentLine();
QString currentFileName = d->currentEditor->document()->filePath().toString();
WordList wl;
wl = d->spellingMistakesModel->mistakesForFile(currentFileName);
if(wl.isEmpty() == true) {
return false;
}
WordList::ConstIterator iter = wl.constBegin();
while(iter != wl.constEnd()) {
const Word& currentWord = iter.value();
if((currentWord.lineNumber == line)
&& ((currentWord.columnNumber <= column)
&& (currentWord.columnNumber + currentWord.length) >= column)) {
word = currentWord;
return true;
}
++iter;
}
return false;
}
示例6: generateRandomName
QString RandomNameProvider::generateRandomName()
{
static WordList words;
return words.at(std::abs(iscore::random_id_generator::getRandomId() % (words.size() - 1))) +
QString::number(std::abs(iscore::random_id_generator::getRandomId() % 99)) +
words.at(std::abs(iscore::random_id_generator::getRandomId() % (words.size() - 1))) +
QString::number(std::abs(iscore::random_id_generator::getRandomId() % 99));
}
示例7:
const WordList layprop::ViewProperties::getAllLayers(void)
{
//drawprop._layset
WordList listLayers;
laySetList::const_iterator it;
for( it = _drawprop._layset.begin(); it != _drawprop._layset.end(); ++it)
{
listLayers.push_back((*it).first);
}
return listLayers;
}
示例8: WordListSet
int SCI_METHOD LexerBase::WordListSet(int n, const char *wl) {
if (n < numWordLists) {
WordList wlNew;
wlNew.Set(wl);
if (*keyWordLists[n] != wlNew) {
keyWordLists[n]->Set(wl);
return 0;
}
}
return -1;
}
示例9:
void laydata::tdtlibrary::collect_usedlays(WordList& laylist) const
{
for (cellList::const_iterator CC = _cells.begin(); CC != _cells.end(); CC++)
{
CC->second->collect_usedlays(NULL, false,laylist);
}
laylist.sort();
laylist.unique();
if ( (0 < laylist.size()) && (0 == laylist.front()) )
laylist.pop_front();
}
示例10: main
int main(int argc, char *argv[])
{
WordList wordlist;
if (argc == 2) {
wordlist.read_lyrics(argv[1],false);
wordlist.search();
}
else {
cout << "Usage: songsearch database.txt\n";
}
return 0;
}
示例11: isWordUnderCursorMistake
void SpellCheckerCore::updateContextMenu()
{
if( d->contextMenuHolderCommands.isEmpty() == true ) {
/* Populate the internal vector with the holder actions to speed up the process
* of updating the context menu when requested again. */
QVector<const char*> holderActionIds { Constants::ACTION_HOLDER1_ID, Constants::ACTION_HOLDER2_ID, Constants::ACTION_HOLDER3_ID, Constants::ACTION_HOLDER4_ID, Constants::ACTION_HOLDER5_ID };
/* Iterate the commands and */
for( int count = 0; count < holderActionIds.size(); ++count ) {
Core::Command* cmd = Core::ActionManager::command( holderActionIds[count] );
d->contextMenuHolderCommands.push_back( cmd );
}
}
Word word;
bool isMistake = isWordUnderCursorMistake( word );
/* Do nothing if the context menu is not a mistake.
* The context menu will in this case already be disabled so there
* is no need to update it. */
if( isMistake == false ) {
return;
}
QStringList list = word.suggestions;
/* Iterate the commands and */
for( Core::Command* cmd: qAsConst( d->contextMenuHolderCommands ) ) {
Q_ASSERT( cmd != nullptr );
if( list.size() > 0 ) {
/* Disconnect the previous connection made, otherwise it will also trigger */
cmd->action()->disconnect();
/* Set the text on the action for the word to use*/
QString replacementWord = list.takeFirst();
cmd->action()->setText( replacementWord );
/* Show the action */
cmd->action()->setVisible( true );
/* Connect to lambda function to call to replace the words if the
* action is triggered. */
connect( cmd->action(), &QAction::triggered, this, [this, word, replacementWord]() {
WordList wordsToReplace;
if( d->settings->replaceAllFromRightClick == true ) {
this->getAllOccurrencesOfWord( word, wordsToReplace );
} else {
wordsToReplace.append( word );
}
this->replaceWordsInCurrentEditor( wordsToReplace, replacementWord );
} );
} else {
/* Hide the action since there are less than 5 suggestions for the word. */
cmd->action()->setVisible( false );
}
}
}
示例12: getBoolValue
int tellstdfunc::stdREPORTLAY::execute() {
bool recursive = getBoolValue();
std::string cellname = getStringValue();
WordList ull;
DATC->lockDB();
bool success = DATC->TEDLIB()->collect_usedlays(cellname, recursive, ull);
DATC->unlockDB();
telldata::ttlist* tllull = DEBUG_NEW telldata::ttlist(telldata::tn_int);
if (success) {
ull.sort();ull.unique();
std::ostringstream ost;
ost << "used layers: {";
for(WordList::const_iterator CL = ull.begin() ; CL != ull.end();CL++ )
ost << " " << *CL << " ";
ost << "}";
tell_log(console::MT_INFO, ost.str());
for(WordList::const_iterator CL = ull.begin() ; CL != ull.end();CL++ )
tllull->add(DEBUG_NEW telldata::ttint(*CL));
ull.clear();
}
else {
std::string news = "cell \"";
news += cellname; news += "\" doesn't exists";
tell_log(console::MT_ERROR,news);
}
OPstack.push(tllull);
return EXEC_NEXT;
}
示例13: HighlightBuilderException
void HighlightStateBuilder::build(StringListLangElem *elem,
HighlightState *state) {
const string &name = elem->getName();
StringDefs *alternatives = elem->getAlternatives();
WordList wordList;
bool doubleQuoted = false, nonDoubleQuoted = false, buildAsWordList = true;
for (StringDefs::const_iterator it = alternatives->begin(); it
!= alternatives->end(); ++it) {
const string &rep = (*it)->toString();
// double quoted strings generate WordListRules, otherwise simple ListRules
// we don't allow double quoted strings mixed with non double quoted
if (((*it)->isDoubleQuoted() && nonDoubleQuoted)
|| (!(*it)->isDoubleQuoted() && doubleQuoted)) {
throw HighlightBuilderException(
"cannot mix double quoted and non double quoted", elem);
}
doubleQuoted = (*it)->isDoubleQuoted();
nonDoubleQuoted = !(*it)->isDoubleQuoted();
wordList.push_back(rep);
// now check whether we must build a word list rule (word boundary) or an
// ordinary list; as soon as we find something that is not to be isolated
// we set buildAsWordList as false
if (buildAsWordList && (!doubleQuoted || !is_to_isolate(rep))) {
buildAsWordList = false;
}
}
HighlightRulePtr rule;
if (buildAsWordList)
rule = HighlightRulePtr(highlightRuleFactory->createWordListRule(name,
wordList, elem->isCaseSensitive()));
else
rule = HighlightRulePtr(highlightRuleFactory->createListRule(name,
wordList, elem->isCaseSensitive()));
rule->setAdditionalInfo(elem->toStringParserInfo());
state->addRule(rule);
setExitLevel(elem, rule.get());
}
示例14: clear
void HalfDictionary::read( std::istream& is )
{
clear();
while (!is.eof())
{
WordList ph;
Hunglish::read(ph,is);
if (ph.empty())
continue;
push_back(ph);
}
}
示例15: remove
void FrequencyMap::remove( const WordList& wordList )
{
for ( int j=0; j<wordList.size(); ++j )
{
remove(wordList[j]);
}
}