1 /** @file lexicon.cpp Lexicon containing terms and grammatical rules. 2 * 3 * @authors Copyright © 2013-2017 Jaakko Keränen <jaakko.keranen@iki.fi> 4 * 5 * @par License 6 * LGPL: http://www.gnu.org/licenses/lgpl.html 7 * 8 * <small>This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as published by 10 * the Free Software Foundation; either version 3 of the License, or (at your 11 * option) any later version. This program is distributed in the hope that it 12 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 * General Public License for more details. You should have received a copy of 15 * the GNU Lesser General Public License along with this program; if not, see: 16 * http://www.gnu.org/licenses</small> 17 */ 18 19 #include "de/shell/Lexicon" 20 21 namespace de { namespace shell { 22 DENG2_PIMPL_NOREF(Lexicon)23DENG2_PIMPL_NOREF(Lexicon) 24 { 25 Terms terms; 26 String extraChars; 27 bool caseSensitive; 28 29 Impl() : caseSensitive(false) {} 30 }; 31 Lexicon()32Lexicon::Lexicon() : d(new Impl) 33 {} 34 Lexicon(Lexicon const & other)35Lexicon::Lexicon(Lexicon const &other) : d(new Impl(*other.d)) 36 {} 37 operator =(Lexicon const & other)38Lexicon &Lexicon::operator = (Lexicon const &other) 39 { 40 d.reset(new Impl(*other.d)); 41 return *this; 42 } 43 setAdditionalWordChars(String const & chars)44void Lexicon::setAdditionalWordChars(String const &chars) 45 { 46 d->extraChars = chars; 47 } 48 setCaseSensitive(bool sensitive)49void Lexicon::setCaseSensitive(bool sensitive) 50 { 51 d->caseSensitive = sensitive; 52 } 53 addTerm(String const & term)54void Lexicon::addTerm(String const &term) 55 { 56 d->terms.insert(term); 57 } 58 terms() const59Lexicon::Terms Lexicon::terms() const 60 { 61 return d->terms; 62 } 63 additionalWordChars() const64String Lexicon::additionalWordChars() const 65 { 66 return d->extraChars; 67 } 68 isWordChar(QChar ch) const69bool Lexicon::isWordChar(QChar ch) const 70 { 71 // Default word characters. 72 if (ch.isLetterOrNumber()) return true; 73 return d->extraChars.contains(ch); 74 } 75 isCaseSensitive() const76bool Lexicon::isCaseSensitive() const 77 { 78 return d->caseSensitive; 79 } 80 81 }} // namespace de::shell 82