Merge branch 'staged' into dev

This commit is contained in:
Xiao YiFang 2022-06-04 16:12:14 +08:00
commit c26a8cfd90
49 changed files with 456 additions and 551 deletions

View file

@ -1,28 +1,30 @@
# Format Style Options - Created with Clang Power Tools
--- ---
BasedOnStyle: LLVM
AlignAfterOpenBracket: Align AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: AcrossComments
AlignEscapedNewlines: Left AlignEscapedNewlines: Left
AllowAllArgumentsOnNextLine: 'false' AlignOperands: Align
AllowShortBlocksOnASingleLine: 'false' AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: None AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never AllowShortIfStatementsOnASingleLine: Never
BinPackArguments: 'false' BasedOnStyle: LLVM
BinPackParameters: 'false' BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman BreakBeforeBraces: Allman
BreakConstructorInitializers: AfterColon BreakConstructorInitializers: AfterColon
ColumnLimit: '120' ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: '2' ConstructorInitializerIndentWidth : 2
ContinuationIndentWidth: '2' ContinuationIndentWidth: 2
MaxEmptyLinesToKeep: '1' MaxEmptyLinesToKeep: 1
PointerAlignment: Middle PointerAlignment: Middle
SortIncludes: 'false' SortIncludes: false
SortUsingDeclarations: 'false' SortUsingDeclarations: false
SpaceBeforeParens: Never SpaceBeforeParens: Never
SpacesInAngles: 'true' SpacesInAngles: true
SpacesInParentheses: 'true' SpacesInParentheses: true
SpacesInSquareBrackets: 'true' SpacesInSquareBrackets: true
UseTab: Never UseTab: Never
AlignConsecutiveAssignments: AcrossComments
... ...

12
aard.cc
View file

@ -239,16 +239,16 @@ class AardDictionary: public BtreeIndexing::BtreeDictionary
~AardDictionary(); ~AardDictionary();
virtual string getName() throw() virtual string getName() noexcept
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
@ -284,7 +284,7 @@ class AardDictionary: public BtreeIndexing::BtreeDictionary
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
private: private:
@ -338,7 +338,7 @@ AardDictionary::~AardDictionary()
df.close(); df.close();
} }
void AardDictionary::loadIcon() throw() void AardDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -95,7 +95,6 @@ body
.gddictnamebodyseparator .gddictnamebodyseparator
{ {
display: inline-block; clear: both;
width: 100%;
border-top: 1px solid #92b0dd; border-top: 1px solid #92b0dd;
} }

View file

@ -41,6 +41,11 @@ pre
/*background: #ffffdd;*/ /*background: #ffffdd;*/
} }
.gddictnamebodyseparator
{
clear: both;
}
/* The 'From ' string which precedes dictionary name in the heading */ /* The 'From ' string which precedes dictionary name in the heading */
.gdfromprefix .gdfromprefix
{ {
@ -58,8 +63,8 @@ pre
background: #fefdeb; background: #fefdeb;
/*fix for invalid blg*/ /*fix for invalid blg*/
font-style:normal; font-style:normal;
content-visibility:auto; content-visibility: auto;
contain-intrinsic-size:400px; contain-intrinsic-size: 600px;
} }
/* CSS trick to prevent the floating elements to overflow /* CSS trick to prevent the floating elements to overflow
@ -525,7 +530,7 @@ div.xdxf
/************* MDict dictionaries **************/ /************* MDict dictionaries **************/
.mdict .mdict
{ {
margin-top: 1em; /* margin-top: 1em; */
} }
.mdict a[name] .mdict a[name]

View file

@ -402,8 +402,11 @@ void ArticleView::showDefinition( Config::InputPhrase const & phrase, unsigned g
if ( scrollTo.size() ) if ( scrollTo.size() )
Utils::Url::addQueryItem( req, "scrollto", scrollTo ); Utils::Url::addQueryItem( req, "scrollto", scrollTo );
if(delayedHighlightText.size()) if( delayedHighlightText.size() )
{
Utils::Url::addQueryItem( req, "regexp", delayedHighlightText ); Utils::Url::addQueryItem( req, "regexp", delayedHighlightText );
delayedHighlightText.clear();
}
Contexts::Iterator pos = contexts.find( "gdanchor" ); Contexts::Iterator pos = contexts.find( "gdanchor" );
if( pos != contexts.end() ) if( pos != contexts.end() )
@ -582,12 +585,6 @@ void ArticleView::loadFinished( bool result )
} }
if( Utils::Url::hasQueryItem( ui.definition->url(), "regexp" ) ) if( Utils::Url::hasQueryItem( ui.definition->url(), "regexp" ) )
highlightFTSResults(); highlightFTSResults();
if( !delayedHighlightText.isEmpty() )
{
// findText( delayedHighlightText, QWebEnginePage::FindCaseSensitively ,[](bool){});
delayedHighlightText.clear();
}
} }
void ArticleView::loadProgress(int ){ void ArticleView::loadProgress(int ){
@ -2572,7 +2569,7 @@ void ArticleView::highlightFTSResults()
if( !allMatches.isEmpty() ) if( !allMatches.isEmpty() )
{ {
highlightAllFtsOccurences( flags ); // highlightAllFtsOccurences( flags );
ui.definition->findText( allMatches.at( 0 ), flags ); ui.definition->findText( allMatches.at( 0 ), flags );
// if( ui.definition->findText( allMatches.at( 0 ), flags ) ) // if( ui.definition->findText( allMatches.at( 0 ), flags ) )
{ {

12
bgl.cc
View file

@ -198,16 +198,16 @@ namespace
BglDictionary( string const & id, string const & indexFile, BglDictionary( string const & id, string const & indexFile,
string const & dictionaryFile ); string const & dictionaryFile );
virtual string getName() throw() virtual string getName() noexcept
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
@ -249,7 +249,7 @@ namespace
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
private: private:
@ -302,7 +302,7 @@ namespace
FTS_index_completed.ref(); FTS_index_completed.ref();
} }
void BglDictionary::loadIcon() throw() void BglDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -1399,15 +1399,18 @@ void BtreeIndex::getHeadwordsFromOffsets( QList<uint32_t> & offsets,
for( unsigned i = 0; i < result.size(); i++ ) for( unsigned i = 0; i < result.size(); i++ )
{ {
uint32_t articleOffset = result.at(i).articleOffset; uint32_t articleOffset = result.at(i).articleOffset;
QList<uint32_t>::Iterator it = std::lower_bound( begOffsets, endOffsets, QList<uint32_t>::Iterator it = std::lower_bound( begOffsets, endOffsets,
articleOffset ); articleOffset );
if( it!=offsets.end()) if( it != offsets.end() && *it == articleOffset )
{ {
if( isCancelled && Utils::AtomicInt::loadAcquire( *isCancelled ) ) if( isCancelled && Utils::AtomicInt::loadAcquire( *isCancelled ) )
return; return;
headwords.append( QString::fromUtf8( ( result[ i ].prefix + result[ i ].word ).c_str() ) ); auto word = QString::fromUtf8( ( result[ i ].prefix + result[ i ].word ).c_str() );
headwords.append( word );
offsets.erase( it); offsets.erase( it);
begOffsets = offsets.begin(); begOffsets = offsets.begin();
endOffsets = offsets.end(); endOffsets = offsets.end();

View file

@ -155,7 +155,7 @@ public:
BtreeDictionary( string const & id, vector< string > const & dictionaryFiles ); BtreeDictionary( string const & id, vector< string > const & dictionaryFiles );
/// Btree-indexed dictionaries are usually a good source for compound searches. /// Btree-indexed dictionaries are usually a good source for compound searches.
virtual Dictionary::Features getFeatures() const throw() virtual Dictionary::Features getFeatures() const noexcept
{ return Dictionary::SuitableForCompoundSearching; } { return Dictionary::SuitableForCompoundSearching; }
/// This function does the search using the btree index. Derivatives usually /// This function does the search using the btree index. Derivatives usually

View file

@ -31,7 +31,7 @@ public:
~CharacterConversionDictionary(); ~CharacterConversionDictionary();
std::vector< gd::wstring > getAlternateWritings( gd::wstring const & ) std::vector< gd::wstring > getAlternateWritings( gd::wstring const & )
throw(); noexcept;
}; };
CharacterConversionDictionary::CharacterConversionDictionary( std::string const & id, CharacterConversionDictionary::CharacterConversionDictionary( std::string const & id,
@ -70,7 +70,7 @@ CharacterConversionDictionary::~CharacterConversionDictionary()
} }
std::vector< gd::wstring > CharacterConversionDictionary::getAlternateWritings( gd::wstring const & str ) std::vector< gd::wstring > CharacterConversionDictionary::getAlternateWritings( gd::wstring const & str )
throw() noexcept
{ {
std::vector< gd::wstring > results; std::vector< gd::wstring > results;

View file

@ -2252,7 +2252,7 @@ QString getUserQtCssFileName()
return getHomeDir().filePath( "qt-style.css" ); return getHomeDir().filePath( "qt-style.css" );
} }
QString getProgramDataDir() throw() QString getProgramDataDir() noexcept
{ {
if ( isPortableVersion() ) if ( isPortableVersion() )
return QCoreApplication::applicationDirPath(); return QCoreApplication::applicationDirPath();
@ -2264,12 +2264,12 @@ QString getProgramDataDir() throw()
#endif #endif
} }
QString getEmbedLocDir() throw() QString getEmbedLocDir() noexcept
{ {
return ":/locale"; return ":/locale";
} }
QString getLocDir() throw() QString getLocDir() noexcept
{ {
if ( QDir( getProgramDataDir() ).cd( "locale" ) ) if ( QDir( getProgramDataDir() ).cd( "locale" ) )
return getProgramDataDir() + "/locale"; return getProgramDataDir() + "/locale";
@ -2277,7 +2277,7 @@ QString getLocDir() throw()
return QCoreApplication::applicationDirPath() + "/locale"; return QCoreApplication::applicationDirPath() + "/locale";
} }
QString getHelpDir() throw() QString getHelpDir() noexcept
{ {
if ( QDir( getProgramDataDir() ).cd( "help" ) ) if ( QDir( getProgramDataDir() ).cd( "help" ) )
return getProgramDataDir() + "/help"; return getProgramDataDir() + "/help";
@ -2286,7 +2286,7 @@ QString getHelpDir() throw()
} }
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT #ifdef MAKE_CHINESE_CONVERSION_SUPPORT
QString getOpenCCDir() throw() QString getOpenCCDir() noexcept
{ {
#if defined( Q_OS_WIN ) #if defined( Q_OS_WIN )
if ( QDir( "opencc" ).exists() ) if ( QDir( "opencc" ).exists() )
@ -2305,7 +2305,7 @@ QString getOpenCCDir() throw()
} }
#endif #endif
bool isPortableVersion() throw() bool isPortableVersion() noexcept
{ {
struct IsPortable struct IsPortable
{ {
@ -2320,7 +2320,7 @@ bool isPortableVersion() throw()
return p.isPortable; return p.isPortable;
} }
QString getPortableVersionDictionaryDir() throw() QString getPortableVersionDictionaryDir() noexcept
{ {
if ( isPortableVersion() ) if ( isPortableVersion() )
return getProgramDataDir() + "/content"; return getProgramDataDir() + "/content";
@ -2328,7 +2328,7 @@ QString getPortableVersionDictionaryDir() throw()
return QString(); return QString();
} }
QString getPortableVersionMorphoDir() throw() QString getPortableVersionMorphoDir() noexcept
{ {
if ( isPortableVersion() ) if ( isPortableVersion() )
return getPortableVersionDictionaryDir() + "/morphology"; return getPortableVersionDictionaryDir() + "/morphology";
@ -2348,7 +2348,7 @@ QString getStylesDir()
return result.path() + QDir::separator(); return result.path() + QDir::separator();
} }
QString getCacheDir() throw() QString getCacheDir() noexcept
{ {
return isPortableVersion() ? portableHomeDirPath() + "/cache" return isPortableVersion() ? portableHomeDirPath() + "/cache"
#ifdef HAVE_X11 #ifdef HAVE_X11
@ -2358,7 +2358,7 @@ QString getCacheDir() throw()
#endif #endif
} }
QString getNetworkCacheDir() throw() QString getNetworkCacheDir() noexcept
{ {
return getCacheDir() + "/network"; return getCacheDir() + "/network";
} }

View file

@ -808,40 +808,40 @@ QString getUserQtCssFileName() ;
/// Returns the program's data dir. Under Linux that would be something like /// Returns the program's data dir. Under Linux that would be something like
/// /usr/share/apps/goldendict, under Windows C:/Program Files/GoldenDict. /// /usr/share/apps/goldendict, under Windows C:/Program Files/GoldenDict.
QString getProgramDataDir() throw(); QString getProgramDataDir() noexcept;
/// Returns the directory storing program localizized files (.qm). /// Returns the directory storing program localizized files (.qm).
QString getEmbedLocDir() throw(); QString getEmbedLocDir() noexcept;
QString getLocDir() throw(); QString getLocDir() noexcept;
/// Returns the directory storing program help files (.qch). /// Returns the directory storing program help files (.qch).
QString getHelpDir() throw(); QString getHelpDir() noexcept;
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT #ifdef MAKE_CHINESE_CONVERSION_SUPPORT
/// Returns the directory storing OpenCC configuration and dictionary files (.json and .ocd). /// Returns the directory storing OpenCC configuration and dictionary files (.json and .ocd).
QString getOpenCCDir() throw(); QString getOpenCCDir() noexcept;
#endif #endif
/// Returns true if the program is configured as a portable version. In that /// Returns true if the program is configured as a portable version. In that
/// mode, all the settings and indices are kept in the program's directory. /// mode, all the settings and indices are kept in the program's directory.
bool isPortableVersion() throw(); bool isPortableVersion() noexcept;
/// Returns directory with dictionaries for portable version. It is content/ /// Returns directory with dictionaries for portable version. It is content/
/// in the application's directory. /// in the application's directory.
QString getPortableVersionDictionaryDir() throw(); QString getPortableVersionDictionaryDir() noexcept;
/// Returns directory with morpgologies for portable version. It is /// Returns directory with morpgologies for portable version. It is
/// content/morphology in the application's directory. /// content/morphology in the application's directory.
QString getPortableVersionMorphoDir() throw(); QString getPortableVersionMorphoDir() noexcept;
/// Returns the add-on styles directory. /// Returns the add-on styles directory.
QString getStylesDir(); QString getStylesDir();
/// Returns the directory where user-specific non-essential (cached) data should be written. /// Returns the directory where user-specific non-essential (cached) data should be written.
QString getCacheDir() throw(); QString getCacheDir() noexcept;
/// Returns the article network disk cache directory. /// Returns the article network disk cache directory.
QString getNetworkCacheDir() throw(); QString getNetworkCacheDir() noexcept;
} }

View file

@ -100,19 +100,19 @@ public:
~DictdDictionary(); ~DictdDictionary();
virtual string getName() throw() virtual string getName() noexcept
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
{ return idxHeader.langFrom; } { return idxHeader.langFrom; }
@ -215,7 +215,7 @@ string nameFromFileName( string const & indexFileName )
return Utf8::encode( FsEncoding::decode( string( sep + 1, dot - sep - 1 ) ) ); return Utf8::encode( FsEncoding::decode( string( sep + 1, dot - sep - 1 ) ) );
} }
void DictdDictionary::loadIcon() throw() void DictdDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -159,7 +159,7 @@ sptr< WordSearchRequest > Class::findHeadwordsForSynonym( wstring const & )
} }
vector< wstring > Class::getAlternateWritings( wstring const & ) vector< wstring > Class::getAlternateWritings( wstring const & )
throw() noexcept
{ {
return vector< wstring >(); return vector< wstring >();
} }
@ -185,21 +185,21 @@ QString Class::getMainFilename()
return QString(); return QString();
} }
QIcon const & Class::getIcon() throw() QIcon const & Class::getIcon() noexcept
{ {
if( !dictionaryIconLoaded ) if( !dictionaryIconLoaded )
loadIcon(); loadIcon();
return dictionaryIcon; return dictionaryIcon;
} }
QIcon const & Class::getNativeIcon() throw() QIcon const & Class::getNativeIcon() noexcept
{ {
if( !dictionaryIconLoaded ) if( !dictionaryIconLoaded )
loadIcon(); loadIcon();
return dictionaryNativeIcon; return dictionaryNativeIcon;
} }
void Class::loadIcon() throw() void Class::loadIcon() noexcept
{ {
dictionaryIconLoaded = true; dictionaryIconLoaded = true;
} }
@ -424,7 +424,7 @@ void Class::isolateCSS( QString & css, QString const & wrapperSelector )
css = newCSS; css = newCSS;
} }
string makeDictionaryId( vector< string > const & dictionaryFiles ) throw() string makeDictionaryId( vector< string > const & dictionaryFiles ) noexcept
{ {
std::vector< string > sortedList; std::vector< string > sortedList;
@ -470,7 +470,7 @@ string makeDictionaryId( vector< string > const & dictionaryFiles ) throw()
// of a timestamp of the file, so we use here Qt anyway. It is supposed to // of a timestamp of the file, so we use here Qt anyway. It is supposed to
// be fixed in the future when it's needed. // be fixed in the future when it's needed.
bool needToRebuildIndex( vector< string > const & dictionaryFiles, bool needToRebuildIndex( vector< string > const & dictionaryFiles,
string const & indexFile ) throw() string const & indexFile ) noexcept
{ {
unsigned long lastModified = 0; unsigned long lastModified = 0;

View file

@ -270,7 +270,7 @@ protected:
// Load user icon if it exist // Load user icon if it exist
// By default set icon to empty // By default set icon to empty
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
// Load icon from filename directly if isFullName == true // Load icon from filename directly if isFullName == true
// else treat filename as name without extension // else treat filename as name without extension
@ -295,39 +295,39 @@ public:
virtual void deferredInit(); virtual void deferredInit();
/// Returns the dictionary's id. /// Returns the dictionary's id.
string getId() throw() string getId() noexcept
{ return id; } { return id; }
/// Returns the list of file names the dictionary consists of. /// Returns the list of file names the dictionary consists of.
vector< string > const & getDictionaryFilenames() throw() vector< string > const & getDictionaryFilenames() noexcept
{ return dictionaryFiles; } { return dictionaryFiles; }
/// Returns the dictionary's full name, utf8. /// Returns the dictionary's full name, utf8.
virtual string getName() throw()=0; virtual string getName() noexcept=0;
/// Returns all the available properties, like the author's name, copyright, /// Returns all the available properties, like the author's name, copyright,
/// description etc. All strings are in utf8. /// description etc. All strings are in utf8.
virtual map< Property, string > getProperties() throw()=0; virtual map< Property, string > getProperties() noexcept=0;
/// Returns the features the dictionary possess. See the Feature enum for /// Returns the features the dictionary possess. See the Feature enum for
/// their list. /// their list.
virtual Features getFeatures() const throw() virtual Features getFeatures() const noexcept
{ return NoFeatures; } { return NoFeatures; }
/// Returns the number of articles in the dictionary. /// Returns the number of articles in the dictionary.
virtual unsigned long getArticleCount() throw()=0; virtual unsigned long getArticleCount() noexcept=0;
/// Returns the number of words in the dictionary. This can be equal to /// Returns the number of words in the dictionary. This can be equal to
/// the number of articles, or can be larger if some synonyms are present. /// the number of articles, or can be larger if some synonyms are present.
virtual unsigned long getWordCount() throw()=0; virtual unsigned long getWordCount() noexcept=0;
/// Returns the dictionary's icon. /// Returns the dictionary's icon.
virtual QIcon const & getIcon() throw(); virtual QIcon const & getIcon() noexcept;
/// Returns the dictionary's native icon. Dsl icons are usually rectangular, /// Returns the dictionary's native icon. Dsl icons are usually rectangular,
/// and are adapted by getIcon() to be square. This function allows getting /// and are adapted by getIcon() to be square. This function allows getting
/// the original icon with no geometry transformations applied. /// the original icon with no geometry transformations applied.
virtual QIcon const & getNativeIcon() throw(); virtual QIcon const & getNativeIcon() noexcept;
/// Returns the dictionary's source language. /// Returns the dictionary's source language.
virtual quint32 getLangFrom() const virtual quint32 getLangFrom() const
@ -371,7 +371,7 @@ public:
/// supposed to be very fast and simple, and the results are thus returned /// supposed to be very fast and simple, and the results are thus returned
/// synchronously. /// synchronously.
virtual vector< wstring > getAlternateWritings( wstring const & ) virtual vector< wstring > getAlternateWritings( wstring const & )
throw(); noexcept;
/// Returns a definition for the given word. The definition should /// Returns a definition for the given word. The definition should
/// be an html fragment (without html/head/body tags) in an utf8 encoding. /// be an html fragment (without html/head/body tags) in an utf8 encoding.
@ -454,7 +454,7 @@ public:
/// dictionary is being indexed. Since indexing can take some time, this /// dictionary is being indexed. Since indexing can take some time, this
/// is useful to show in some kind of a splash screen. /// is useful to show in some kind of a splash screen.
/// The dictionaryName is in utf8. /// The dictionaryName is in utf8.
virtual void indexingDictionary( string const & dictionaryName ) throw()=0; virtual void indexingDictionary( string const & dictionaryName ) noexcept=0;
virtual ~Initializing() virtual ~Initializing()
{} {}
@ -465,7 +465,7 @@ public:
/// hashing the file names. This id should be used to identify dictionary /// hashing the file names. This id should be used to identify dictionary
/// and for the index file name, if one is needed. /// and for the index file name, if one is needed.
/// This function is supposed to be used by dictionary implementations. /// This function is supposed to be used by dictionary implementations.
string makeDictionaryId( vector< string > const & dictionaryFiles ) throw(); string makeDictionaryId( vector< string > const & dictionaryFiles ) noexcept;
/// Checks if it is needed to regenerate index file based on its timestamp /// Checks if it is needed to regenerate index file based on its timestamp
/// and the timestamps of the dictionary files. If some files are newer than /// and the timestamps of the dictionary files. If some files are newer than
@ -473,7 +473,7 @@ string makeDictionaryId( vector< string > const & dictionaryFiles ) throw();
/// dictionary files don't exist, returns true, too. /// dictionary files don't exist, returns true, too.
/// This function is supposed to be used by dictionary implementations. /// This function is supposed to be used by dictionary implementations.
bool needToRebuildIndex( vector< string > const & dictionaryFiles, bool needToRebuildIndex( vector< string > const & dictionaryFiles,
string const & indexFile ) throw(); string const & indexFile ) noexcept;
/// Returns a random dictionary id useful for interactively created /// Returns a random dictionary id useful for interactively created
/// dictionaries. /// dictionaries.

View file

@ -209,16 +209,16 @@ public:
strategies.append( "prefix" ); strategies.append( "prefix" );
} }
virtual string getName() throw() virtual string getName() noexcept
{ return name; } { return name; }
virtual map< Property, string > getProperties() throw() virtual map< Property, string > getProperties() noexcept
{ return map< Property, string >(); } { return map< Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return 0; } { return 0; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return 0; } { return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const &, virtual sptr< WordSearchRequest > prefixMatch( wstring const &,
@ -237,7 +237,7 @@ public:
virtual QString const & getDescription(); virtual QString const & getDescription();
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
void getServerDatabases(); void getServerDatabases();
@ -245,7 +245,7 @@ protected:
friend class DictServerArticleRequest; friend class DictServerArticleRequest;
}; };
void DictServerDictionary::loadIcon() throw() void DictServerDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

12
dsl.cc
View file

@ -183,16 +183,16 @@ public:
~DslDictionary(); ~DslDictionary();
virtual string getName() throw() virtual string getName() noexcept
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
@ -247,7 +247,7 @@ public:
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
private: private:
@ -466,7 +466,7 @@ void DslDictionary::doDeferredInit()
} }
void DslDictionary::loadIcon() throw() void DslDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -983,7 +983,7 @@ DslScanner::DslScanner( string const & fileName ) :
readBufferLeft = 0; readBufferLeft = 0;
} }
DslScanner::~DslScanner() throw() DslScanner::~DslScanner() noexcept
{ {
gzclose( f ); gzclose( f );
} }

View file

@ -130,7 +130,7 @@ public:
DEF_EX( exEncodingError, "Encoding error", Ex ) // Should never happen really DEF_EX( exEncodingError, "Encoding error", Ex ) // Should never happen really
DslScanner( string const & fileName ) ; DslScanner( string const & fileName ) ;
~DslScanner() throw(); ~DslScanner() noexcept;
/// Returns the detected encoding of this file. /// Returns the detected encoding of this file.
Encoding getEncoding() const Encoding getEncoding() const

View file

@ -96,16 +96,16 @@ public:
~EpwingDictionary(); ~EpwingDictionary();
virtual string getName() throw() virtual string getName() noexcept
{ return bookName; } { return bookName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
@ -163,7 +163,7 @@ public:
protected: protected:
void loadIcon() throw(); void loadIcon() noexcept;
private: private:
@ -244,7 +244,7 @@ EpwingDictionary::~EpwingDictionary()
removeDirectory( cacheDirectory ); removeDirectory( cacheDirectory );
} }
void EpwingDictionary::loadIcon() throw() void EpwingDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

8
ex.hh
View file

@ -14,8 +14,8 @@
#define DEF_EX( exName, exDescription, exParent ) \ #define DEF_EX( exName, exDescription, exParent ) \
class exName: public exParent { \ class exName: public exParent { \
public: \ public: \
virtual const char * what() const throw() { return (exDescription); } \ virtual const char * what() const noexcept { return (exDescription); } \
virtual ~exName() throw() {} }; virtual ~exName() noexcept {} };
/// Same as DEF_EX, but takes a runtime string argument, which gets concatenated /// Same as DEF_EX, but takes a runtime string argument, which gets concatenated
/// with the description. /// with the description.
@ -31,7 +31,7 @@ class exName: public exParent { \
std::string value; \ std::string value; \
public: \ public: \
exName( std::string const & value_ ): value( std::string( exDescription ) + " " + value_ ) {} \ exName( std::string const & value_ ): value( std::string( exDescription ) + " " + value_ ) {} \
virtual const char * what() const throw() { return value.c_str(); } \ virtual const char * what() const noexcept { return value.c_str(); } \
virtual ~exName() throw() {} }; virtual ~exName() noexcept {} };
#endif #endif

View file

@ -65,7 +65,7 @@ void loadFromFile( std::string const & n, std::vector< char > & data )
f.read( &data.front(), data.size() ); f.read( &data.front(), data.size() );
} }
bool exists( char const * filename ) throw() bool exists( char const * filename ) noexcept
{ {
#ifdef __WIN32 #ifdef __WIN32
#if defined(__WIN64) || defined(_MSC_VER) #if defined(__WIN64) || defined(_MSC_VER)
@ -313,7 +313,7 @@ void Class::close()
f.close(); f.close();
} }
Class::~Class() throw() Class::~Class() noexcept
{ {
if ( f.isOpen() ) if ( f.isOpen() )
{ {

View file

@ -30,9 +30,9 @@ bool tryPossibleZipName( std::string const & name, std::string & copyTo );
void loadFromFile( std::string const & n, std::vector< char > & data ); void loadFromFile( std::string const & n, std::vector< char > & data );
bool exists( char const * filename ) throw(); bool exists( char const * filename ) noexcept;
inline bool exists( std::string const & filename ) throw() inline bool exists( std::string const & filename ) noexcept
{ return exists( filename.c_str() ); } { return exists( filename.c_str() ); }
class Class class Class
@ -116,7 +116,7 @@ public:
/// Closes the file. No further operations are valid. /// Closes the file. No further operations are valid.
void close() ; void close() ;
~Class() throw(); ~Class() noexcept;
private: private:

View file

@ -42,16 +42,16 @@ public:
{ {
} }
virtual string getName() throw() virtual string getName() noexcept
{ return name; } { return name; }
virtual map< Property, string > getProperties() throw() virtual map< Property, string > getProperties() noexcept
{ return map< Property, string >(); } { return map< Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return 0; } { return 0; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return 0; } { return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const & /*word*/, virtual sptr< WordSearchRequest > prefixMatch( wstring const & /*word*/,
@ -70,7 +70,7 @@ public:
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
}; };
@ -90,7 +90,7 @@ sptr< DataRequest > ForvoDictionary::getArticle( wstring const & word,
netMgr ); netMgr );
} }
void ForvoDictionary::loadIcon() throw() void ForvoDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -15,6 +15,7 @@
#include <QVector> #include <QVector>
#include <QRegularExpression> #include <QRegularExpression>
#include "wildcard.hh" #include "wildcard.hh"
using std::vector; using std::vector;
@ -38,96 +39,52 @@ bool ftsIndexIsOldOrBad( string const & indexFile,
} }
static QString makeHiliteRegExpString( QStringList const & words, static QString makeHiliteRegExpString( QStringList const & words,
int searchMode, int searchMode, int distanceBetweenWords, bool hasCJK = false, bool ignoreWordsOrder = false )
int distanceBetweenWords )
{ {
QString searchString( "(" ); QString searchString( "(" );
QString stripWords( "(?:\\W+\\w+){0," ); QString stripWords( "(?:\\W+\\w+){0," );
if( distanceBetweenWords >= 0 ) if( distanceBetweenWords >= 0 )
stripWords += QString::number( distanceBetweenWords ); stripWords += QString::number( distanceBetweenWords );
stripWords += "}\\W+"; stripWords += "}";
if(!hasCJK)
{
stripWords += "\\W+";
}
QString boundWord( searchMode == FTS::WholeWords ? "\\b" : "(?:\\w*)"); QString boundWord( searchMode == FTS::WholeWords ? "\\b" : "(?:\\w*)");
if(hasCJK)
{
//no boundary for CJK
boundWord.clear();
}
for( int x = 0; x < words.size(); x++ ) for( int x = 0; x < words.size(); x++ )
{ {
if( x ) if( x )
{
searchString += stripWords; searchString += stripWords;
if(ignoreWordsOrder)
searchString += "(";
}
searchString += boundWord + words[ x ] + boundWord; searchString += boundWord + words[ x ] + boundWord;
if( x )
{
if( ignoreWordsOrder )
searchString += ")?";
}
} }
searchString += ")"; searchString += ")";
return searchString; return searchString;
} }
bool parseSearchString( QString const & str, QStringList & indexWords, void tokenizeCJK( QStringList & indexWords, QRegularExpression wordRegExp, QStringList list )
QStringList & searchWords,
QRegExp & searchRegExp, int searchMode,
bool matchCase,
int distanceBetweenWords,
bool & hasCJK )
{ {
searchWords.clear();
indexWords.clear();
QRegularExpression spacesRegExp( "\\W+", QRegularExpression::UseUnicodePropertiesOption );
QRegularExpression wordRegExp( QString( "\\w{" ) + QString::number( FTS::MinimumWordSize ) + ",}", QRegularExpression::UseUnicodePropertiesOption );
QRegularExpression setsRegExp( "\\[[^\\]]+\\]", QRegularExpression::CaseInsensitiveOption );
QRegularExpression regexRegExp( "\\\\[afnrtvdDwWsSbB]|\\\\x([0-9A-Fa-f]{4})|\\\\0([0-7]{3})", QRegularExpression::CaseInsensitiveOption);
hasCJK = false;
for( int x = 0; x < str.size(); x++ )
if( isCJKChar( str.at( x ).unicode() ) )
{
hasCJK = true;
break;
}
if( searchMode == FTS::WholeWords || searchMode == FTS::PlainText )
{
if( hasCJK )
return false;
// Make words list for search in article text
searchWords = str.normalized( QString::NormalizationForm_C )
.split( spacesRegExp, Qt::SkipEmptyParts );
// Make words list for index search
QStringList list = str.normalized( QString::NormalizationForm_C )
.toLower().split( spacesRegExp, Qt::SkipEmptyParts );
indexWords = list.filter( wordRegExp );
indexWords.removeDuplicates();
// Make regexp for results hilite
QStringList allWords = str.split( spacesRegExp, Qt::SkipEmptyParts );
QString searchString = makeHiliteRegExpString( allWords, searchMode, distanceBetweenWords );
searchRegExp = QRegExp( searchString, matchCase ? Qt::CaseSensitive : Qt::CaseInsensitive,
QRegExp::RegExp2 );
searchRegExp.setMinimal( true );
return !indexWords.isEmpty();
}
else
{
// Make words list for index search
QString tmp = str;
// Remove RegExp commands
if( searchMode == FTS::RegExp )
tmp.replace( regexRegExp, " " );
// Remove all symbol sets
tmp.replace( setsRegExp, " " );
QStringList list = tmp.normalized( QString::NormalizationForm_C )
.toLower().split( spacesRegExp, Qt::SkipEmptyParts );
if( hasCJK )
{
QStringList wordList, hieroglyphList; QStringList wordList, hieroglyphList;
for( int i = 0; i < list.size(); i ++ ) for( int i = 0; i < list.size(); i ++ )
{ {
@ -160,6 +117,85 @@ bool parseSearchString( QString const & str, QStringList & indexWords,
hieroglyphList.removeDuplicates(); hieroglyphList.removeDuplicates();
indexWords += hieroglyphList; indexWords += hieroglyphList;
}
bool containCJK( QString const & str)
{
bool hasCJK = false;
for( int x = 0; x < str.size(); x++ )
if( isCJKChar( str.at( x ).unicode() ) )
{
hasCJK = true;
break;
}
return hasCJK;
}
bool parseSearchString( QString const & str, QStringList & indexWords,
QStringList & searchWords,
QRegExp & searchRegExp, int searchMode,
bool matchCase,
int distanceBetweenWords,
bool & hasCJK,
bool ignoreWordsOrder )
{
searchWords.clear();
indexWords.clear();
QRegularExpression spacesRegExp( "\\W+", QRegularExpression::UseUnicodePropertiesOption );
QRegularExpression wordRegExp( QString( "\\w{" ) + QString::number( FTS::MinimumWordSize ) + ",}", QRegularExpression::UseUnicodePropertiesOption );
QRegularExpression setsRegExp( "\\[[^\\]]+\\]", QRegularExpression::CaseInsensitiveOption );
QRegularExpression regexRegExp( "\\\\[afnrtvdDwWsSbB]|\\\\x([0-9A-Fa-f]{4})|\\\\0([0-7]{3})", QRegularExpression::CaseInsensitiveOption);
hasCJK = containCJK( str );
if( searchMode == FTS::WholeWords || searchMode == FTS::PlainText )
{
// Make words list for search in article text
searchWords = str.normalized( QString::NormalizationForm_C ).split( spacesRegExp, Qt::SkipEmptyParts );
// Make words list for index search
QStringList list =
str.normalized( QString::NormalizationForm_C ).toLower().split( spacesRegExp, Qt::SkipEmptyParts );
QString searchString;
if( hasCJK )
{
tokenizeCJK( indexWords, wordRegExp, list );
// QStringList allWords = str.split( spacesRegExp, Qt::SkipEmptyParts );
searchString = makeHiliteRegExpString( list, searchMode, distanceBetweenWords, hasCJK , ignoreWordsOrder);
}
else
{
indexWords = list.filter( wordRegExp );
indexWords.removeDuplicates();
// Make regexp for results hilite
QStringList allWords = str.split( spacesRegExp, Qt::SkipEmptyParts );
searchString = makeHiliteRegExpString( allWords, searchMode, distanceBetweenWords,false, ignoreWordsOrder );
}
searchRegExp = QRegExp( searchString, matchCase ? Qt::CaseSensitive : Qt::CaseInsensitive, QRegExp::RegExp2 );
searchRegExp.setMinimal( true );
return !indexWords.isEmpty();
}
else
{
// Make words list for index search
QString tmp = str;
// Remove RegExp commands
if( searchMode == FTS::RegExp )
tmp.replace( regexRegExp, " " );
// Remove all symbol sets
tmp.replace( setsRegExp, " " );
QStringList list = tmp.normalized( QString::NormalizationForm_C )
.toLower().split( spacesRegExp, Qt::SkipEmptyParts );
if( hasCJK )
{
tokenizeCJK( indexWords, wordRegExp, list );
} }
else else
{ {
@ -419,25 +455,23 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
QRegularExpression::UseUnicodePropertiesOption); QRegularExpression::UseUnicodePropertiesOption);
QRegularExpression regSplit( "[^\\w\\p{M}]+", QRegularExpression::UseUnicodePropertiesOption ); QRegularExpression regSplit( "[^\\w\\p{M}]+", QRegularExpression::UseUnicodePropertiesOption );
if( searchMode == FTS::Wildcards || searchMode == FTS::RegExp )
{
// RegExp mode // RegExp mode
QRegularExpression searchRegularExpression; QRegularExpression searchRegularExpression;
if( searchMode == FTS::Wildcards ) if( searchMode == FTS::Wildcards )
searchRegularExpression.setPattern( wildcardsToRegexp( searchRegexp.pattern() ) ); searchRegularExpression.setPattern( wildcardsToRegexp( searchRegexp.pattern() ) );
else else
searchRegularExpression.setPattern( searchRegexp.pattern() ); searchRegularExpression.setPattern( searchRegexp.pattern() );
QRegularExpression::PatternOptions patternOptions = QRegularExpression::DotMatchesEverythingOption QRegularExpression::PatternOptions patternOptions =
| QRegularExpression::UseUnicodePropertiesOption QRegularExpression::DotMatchesEverythingOption | QRegularExpression::UseUnicodePropertiesOption
| QRegularExpression::MultilineOption | QRegularExpression::MultilineOption | QRegularExpression::InvertedGreedinessOption;
| QRegularExpression::InvertedGreedinessOption;
if( searchRegexp.caseSensitivity() == Qt::CaseInsensitive ) if( searchRegexp.caseSensitivity() == Qt::CaseInsensitive )
patternOptions |= QRegularExpression::CaseInsensitiveOption; patternOptions |= QRegularExpression::CaseInsensitiveOption;
searchRegularExpression.setPatternOptions( patternOptions ); searchRegularExpression.setPatternOptions( patternOptions );
if( !searchRegularExpression.isValid() ) if( !searchRegularExpression.isValid() )
searchRegularExpression.setPattern( "" ); searchRegularExpression.setPattern( "" );
if( searchMode == FTS::Wildcards || searchMode == FTS::RegExp )
{
for( int i = 0; i < offsets.size(); i++ ) for( int i = 0; i < offsets.size(); i++ )
{ {
if( Utils::AtomicInt::loadAcquire( isCancelled ) ) if( Utils::AtomicInt::loadAcquire( isCancelled ) )
@ -503,239 +537,94 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
if( ignoreDiacritics ) if( ignoreDiacritics )
articleText = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( articleText ) ) ); articleText = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( articleText ) ) );
QStringList articleWords = articleText.split( needHandleBrackets ? splitWithBrackets : splitWithoutBrackets, //QStringList articleWords = articleText.split( needHandleBrackets ? splitWithBrackets : splitWithoutBrackets,
Qt::SkipEmptyParts ); // Qt::SkipEmptyParts );
int wordsNum = articleWords.length(); if(ignoreWordsOrder)
while ( pos < wordsNum )
{ {
QString s = articleWords[ pos ]; bool allMatch = true;
bool breakSearch = false; foreach( QString word, words )
QStringList parsedWords;
if( needHandleBrackets && ( s.indexOf( '(' ) >= 0 || s.indexOf( ')' ) >= 0 ) )
{ {
// Handle brackets if( containCJK( word ) || searchMode == FTS::PlainText )
QRegularExpressionMatch match_brackets = regBrackets.match( s );
if( match_brackets.hasMatch() )
{ {
QStringList parts = match_brackets.capturedTexts(); if( !articleText.contains( word ) )
// Add empty strings for compatibility with QRegExp behaviour
for( int i = match_brackets.lastCapturedIndex() + 1; i < 6; i++ )
parts.append( QString() );
QString word = parts[ 2 ] + parts[ 4 ]; // Brackets removed
parsedWords.append( word );
word = parts[ 1 ].remove( '(' ).remove( ')' )
+ parts[ 2 ]
+ parts[ 3 ].remove( '(' ).remove( ')' )
+ parts[ 4 ]
+ parts[ 5 ].remove( '(' ).remove( ')' ); // Brackets expansed
parsedWords.append( word );
}
else
parsedWords = s.split( regSplit, Qt::SkipEmptyParts );
}
else
parsedWords.append( s );
int n;
for( n = 0; n < parsedWords.size(); n++ )
{ {
if( ignoreWordsOrder ) allMatch = false;
{
int i;
for( i = 0; i < wordsList.size(); i++ )
{
if( wordsList.at( i ).second )
{
if( ( searchMode == FTS::WholeWords && parsedWords.at( n ).compare( wordsList.at( i ).first, cs ) == 0 )
|| ( searchMode == FTS::PlainText && parsedWords.at( n ).contains( wordsList.at( i ).first, cs ) ) )
{
wordsList[ i ].second = false;
if( parsedWords.size() > 1 )
{
QString wordToHilite = s;
while( !wordToHilite.isEmpty() && ( wordToHilite.at( 0 ) == '(' || wordToHilite.at( 0 ) == ')' ) )
wordToHilite.remove( 0, 1 );
while( !wordToHilite.isEmpty() && ( wordToHilite.endsWith( '(' ) || wordToHilite.endsWith( ')' ) ) )
wordToHilite.chop( 1 );
order.append( wordToHilite.replace( '(', "\\(" ).replace( ')', "\\)" ) );
}
else
order.append( wordsList.at( i ).first );
break; break;
} }
} }
} else if( searchMode == FTS::WholeWords)
if( i < wordsList.size() )
{ {
// Word found QRegularExpression tmpReg( QString( "\b%1\b" ).arg( word ),QRegularExpression::CaseInsensitiveOption|QRegularExpression::UseUnicodePropertiesOption );
if( !articleText.contains( tmpReg) )
matchWordNom += 1;
if( matchWordNom == 1 )
{ {
// Store position to remake search if sequence will not be found allMatch = false;
nextNotFoundPos = pos + 1;
}
if( matchWordNom >= words.size() )
{
// All words are found
// Store found words sequence and continue search
// It's nesessary for hilite search results
// Check if such sequence already presented
int x;
for( x = 0; x < allOrders.size(); x++ )
{
if( allOrders[ x ] == order )
break; break;
} }
if( x >= allOrders.size() ) }
allOrders.append( order );
order.clear(); }
matchWordNom = 0; if(!allMatch)
unmatchWordNom = 0; {
for( int i = 0; i < wordsList.size(); i++ ) continue;
wordsList[ i ].second = true; }
nextNotFoundPos = 0;
if( distanceBetweenWords >= 0 )
{
// the article text contains all the needed words.
// determine if distance restriction is meet
QRegularExpression replaceReg( QString( "(%1)" ).arg( words.join( '|' ) ),
QRegularExpression::CaseInsensitiveOption |
QRegularExpression::UseUnicodePropertiesOption );
// use a string that could not be presented in the article.
articleText = articleText.replace( replaceReg, "=@XXXXX@=" );
auto hasCJK = false;
foreach(QString word,words)
{
if(containCJK( word ))
{
hasCJK = true;
break; break;
} }
unmatchWordNom = 0;
break;
}
else
if( matchWordNom > 0 && n >= parsedWords.size() - 1 )
{
unmatchWordNom += 1;
if( distanceBetweenWords >= 0 && unmatchWordNom > distanceBetweenWords )
{
// Sequence broken, clear all counters
matchWordNom = 0;
unmatchWordNom = 0;
for( int i = 0; i < wordsList.size(); i++ )
wordsList[ i ].second = true;
order.clear();
}
}
}
else
{
if( ( searchMode == FTS::WholeWords && parsedWords.at( n ).compare( words.at( matchWordNom ), cs ) == 0 )
|| ( searchMode == FTS::PlainText && parsedWords.at( n ).contains( words.at( matchWordNom ), cs ) ) )
{
matchWordNom += 1;
if( matchWordNom == 1 )
{
// Store position to remake search if sequence will not be found
nextNotFoundPos = pos + 1;
} }
if( needHandleBrackets ) //hascjk value ,perhaps should depend on each word
auto searchRegStr = makeHiliteRegExpString( Utils::repeat( "=@XXXXX@=", words.size() ), searchMode, distanceBetweenWords,hasCJK );
QRegularExpression distanceOrderReg( searchRegStr,
QRegularExpression::CaseInsensitiveOption |
QRegularExpression::UseUnicodePropertiesOption );
// use a string that could not be presented in the article.
if(articleText.contains(distanceOrderReg))
{ {
if( parsedWords.size() > 1 )
{
QString wordToHilite = s;
while( !wordToHilite.isEmpty() && ( wordToHilite.at( 0 ) == '(' || wordToHilite.at( 0 ) == ')' ) )
wordToHilite.remove( 0, 1 );
while( !wordToHilite.isEmpty() && ( wordToHilite.endsWith( '(' ) || wordToHilite.endsWith( ')' ) ) )
wordToHilite.chop( 1 );
order.append( wordToHilite.replace( '(', "\\(" ).replace( ')', "\\)" ) );
}
else
order.append( words.at( matchWordNom - 1 ) );
}
if( matchWordNom >= words.size() )
{
// All words are found
if( needHandleBrackets )
{
if( allOrders.isEmpty() )
allOrders.append( words );
// Check if such sequence already presented
int x;
for( x = 0; x < allOrders.size(); x++ )
{
if( allOrders[ x ] == order )
break;
}
if( x >= allOrders.size() )
allOrders.append( order );
matchWordNom = 0;
unmatchWordNom = 0;
order.clear();
nextNotFoundPos = 0;
}
else
breakSearch = true;
break;
}
unmatchWordNom = 0;
break;
}
else
if( matchWordNom > 0 && n >= parsedWords.size() - 1 )
{
unmatchWordNom += 1;
if( distanceBetweenWords >= 0 && unmatchWordNom > distanceBetweenWords )
{
matchWordNom = 0;
unmatchWordNom = 0;
if( needHandleBrackets )
order.clear();
}
}
}
}
if( breakSearch )
break;
if( nextNotFoundPos > 0 && matchWordNom == 0 )
{
pos = nextNotFoundPos;
nextNotFoundPos = 0;
}
else
pos += 1;
}
if( !allOrders.isEmpty() || matchWordNom >= words.size() )
{
QStringList hiliteReg;
if( !allOrders.isEmpty() )
{
for( int i = 0; i < allOrders.size(); i++ )
{
QString hiliteStr = makeHiliteRegExpString( allOrders.at( i ), searchMode, distanceBetweenWords );
hiliteReg.append( hiliteStr );
}
allOrders.clear();
}
if( headword.isEmpty() ) if( headword.isEmpty() )
{
offsetsForHeadwords.append( offsets.at( i ) ); offsetsForHeadwords.append( offsets.at( i ) );
hiliteRegExps.append( hiliteReg );
}
else else
foundHeadwords->append( FTS::FtsHeadword( headword, id, hiliteReg, matchCase ) ); foundHeadwords->append( FTS::FtsHeadword( headword, id, QStringList(), matchCase ) );
results++; results++;
if( maxResults > 0 && results >= maxResults ) if( maxResults > 0 && results >= maxResults )
break; break;
} }
} }
}
else
{
if( articleText.contains( searchRegularExpression ) )
{
if( headword.isEmpty() )
offsetsForHeadwords.append( offsets.at( i ) );
else
foundHeadwords->append( FTS::FtsHeadword( headword, id, QStringList(), matchCase ) );
results++;
if( maxResults > 0 && results >= maxResults )
break;
}
}
}
} }
if( !offsetsForHeadwords.isEmpty() ) if( !offsetsForHeadwords.isEmpty() )
{ {
@ -1120,7 +1009,7 @@ void FTSResultsRequest::run()
QRegExp searchRegExp; QRegExp searchRegExp;
if( !FtsHelpers::parseSearchString( searchString, indexWords, searchWords, searchRegExp, if( !FtsHelpers::parseSearchString( searchString, indexWords, searchWords, searchRegExp,
searchMode, matchCase, distanceBetweenWords, hasCJK ) ) searchMode, matchCase, distanceBetweenWords, hasCJK, ignoreWordsOrder ) )
{ {
finish(); finish();
return; return;

View file

@ -55,7 +55,8 @@ bool parseSearchString( QString const & str, QStringList & IndexWords,
QRegExp & searchRegExp, int searchMode, QRegExp & searchRegExp, int searchMode,
bool matchCase, bool matchCase,
int distanceBetweenWords, int distanceBetweenWords,
bool & hasCJK ); bool & hasCJK,
bool ignoreWordsOrder = false );
void parseArticleForFts( uint32_t articleAddress, QString & articleText, void parseArticleForFts( uint32_t articleAddress, QString & articleText,
QMap< QString, QVector< uint32_t > > & words, QMap< QString, QVector< uint32_t > > & words,

View file

@ -351,18 +351,18 @@ void FullTextSearchDialog::accept()
searchRegExp, mode, searchRegExp, mode,
ui.matchCase->isChecked(), ui.matchCase->isChecked(),
distanceBetweenWords, distanceBetweenWords,
hasCJK ) ) hasCJK, ignoreWordsOrder ) )
{ {
if( hasCJK && ( mode == WholeWords || mode == PlainText ) ) // if( hasCJK && ( mode == WholeWords || mode == PlainText ) )
{ // {
QMessageBox message( QMessageBox::Warning, // QMessageBox message( QMessageBox::Warning,
"GoldenDict", // "GoldenDict",
tr( "CJK symbols in search string are not compatible with search modes \"Whole words\" and \"Plain text\"" ), // tr( "CJK symbols in search string are not compatible with search modes \"Whole words\" and \"Plain text\"" ),
QMessageBox::Ok, // QMessageBox::Ok,
this ); // this );
message.exec(); // message.exec();
} // }
else // else
{ {
QMessageBox message( QMessageBox::Warning, QMessageBox message( QMessageBox::Warning,
"GoldenDict", "GoldenDict",
@ -621,7 +621,7 @@ Q_UNUSED( parent );
for( int x = 0; x < hws.length(); x++ ) for( int x = 0; x < hws.length(); x++ )
{ {
QList< FtsHeadword >::iterator it = std::lower_bound( headwords.begin(), headwords.end(), hws.at( x ) ); QList< FtsHeadword >::iterator it = std::lower_bound( headwords.begin(), headwords.end(), hws.at( x ) );
if( it != headwords.end() ) if( it != headwords.end() && *it == hws.at( x ) )
{ {
it->dictIDs.push_back( hws.at( x ).dictIDs.front() ); it->dictIDs.push_back( hws.at( x ).dictIDs.front() );
for( QStringList::const_iterator itr = it->foundHiliteRegExps.constBegin(); for( QStringList::const_iterator itr = it->foundHiliteRegExps.constBegin();

16
gls.cc
View file

@ -88,7 +88,7 @@ public:
DEF_EX( exEncodingError, "Encoding error", Ex ) // Should never happen really DEF_EX( exEncodingError, "Encoding error", Ex ) // Should never happen really
GlsScanner( string const & fileName ) ; GlsScanner( string const & fileName ) ;
~GlsScanner() throw(); ~GlsScanner() noexcept;
/// Returns the detected encoding of this file. /// Returns the detected encoding of this file.
Encoding getEncoding() const Encoding getEncoding() const
@ -293,7 +293,7 @@ bool GlsScanner::readNextLine( wstring & out, size_t & offset )
} }
} }
GlsScanner::~GlsScanner() throw() GlsScanner::~GlsScanner() noexcept
{ {
gzclose( f ); gzclose( f );
} }
@ -372,16 +372,16 @@ public:
~GlsDictionary(); ~GlsDictionary();
virtual string getName() throw() virtual string getName() noexcept
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
@ -425,7 +425,7 @@ public:
} }
protected: protected:
void loadIcon() throw(); void loadIcon() noexcept;
private: private:
@ -517,7 +517,7 @@ GlsDictionary::~GlsDictionary()
dict_data_close( dz ); dict_data_close( dz );
} }
void GlsDictionary::loadIcon() throw() void GlsDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -15,11 +15,10 @@ system(git describe --tags --always --dirty): hasGit=1
win32{ win32{
# date /T output is locale aware. # date /T output is locale aware.
DD=$$system(date /T) DATE=$$system(date /T)
DATE =$$replace(DD, / , )
} }
else{ else{
DATE=$$system(date '+%y%m%d') DATE=$$system(date '+%Y/%m/%d')
} }
system(echo $${VERSION}.$${GIT_HASH} on $${DATE} > version.txt) system(echo $${VERSION}.$${GIT_HASH} on $${DATE} > version.txt)

View file

@ -63,16 +63,16 @@ public:
{ {
} }
virtual string getName() throw() virtual string getName() noexcept
{ return name; } { return name; }
virtual map< Property, string > getProperties() throw() virtual map< Property, string > getProperties() noexcept
{ return map< Property, string >(); } { return map< Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return 0; } { return 0; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return 0; } { return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const &, virtual sptr< WordSearchRequest > prefixMatch( wstring const &,
@ -91,11 +91,11 @@ public:
virtual bool isLocalDictionary() virtual bool isLocalDictionary()
{ return true; } { return true; }
virtual vector< wstring > getAlternateWritings( const wstring & word ) throw(); virtual vector< wstring > getAlternateWritings( const wstring & word ) noexcept;
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
private: private:
@ -142,7 +142,7 @@ bool containsWhitespace( wstring const & str )
return false; return false;
} }
void HunspellDictionary::loadIcon() throw() void HunspellDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;
@ -162,7 +162,7 @@ void HunspellDictionary::loadIcon() throw()
dictionaryIconLoaded = true; dictionaryIconLoaded = true;
} }
vector< wstring > HunspellDictionary::getAlternateWritings( wstring const & word ) throw() vector< wstring > HunspellDictionary::getAlternateWritings( wstring const & word ) noexcept
{ {
vector< wstring > results; vector< wstring > results;

View file

@ -240,7 +240,7 @@ void LoadDictionaries::handlePath( Config::Path const & path )
#endif #endif
} }
void LoadDictionaries::indexingDictionary( string const & dictionaryName ) throw() void LoadDictionaries::indexingDictionary( string const & dictionaryName ) noexcept
{ {
emit indexingDictionarySignal( QString::fromUtf8( dictionaryName.c_str() ) ); emit indexingDictionarySignal( QString::fromUtf8( dictionaryName.c_str() ) );
} }

View file

@ -46,7 +46,7 @@ signals:
public: public:
virtual void indexingDictionary( std::string const & dictionaryName ) throw(); virtual void indexingDictionary( std::string const & dictionaryName ) noexcept;
private: private:

14
lsa.cc
View file

@ -164,15 +164,15 @@ public:
LsaDictionary( string const & id, string const & indexFile, LsaDictionary( string const & id, string const & indexFile,
vector< string > const & dictionaryFiles ); vector< string > const & dictionaryFiles );
virtual string getName() throw(); virtual string getName() noexcept;
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.soundsCount; } { return idxHeader.soundsCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return getArticleCount(); } { return getArticleCount(); }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &, virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
@ -186,10 +186,10 @@ public:
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
}; };
string LsaDictionary::getName() throw() string LsaDictionary::getName() noexcept
{ {
string result = FsEncoding::basename( getDictionaryFilenames()[ 0 ] ); string result = FsEncoding::basename( getDictionaryFilenames()[ 0 ] );
@ -498,7 +498,7 @@ sptr< Dictionary::DataRequest > LsaDictionary::getResource( string const & name
return dr; return dr;
} }
void LsaDictionary::loadIcon() throw() void LsaDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

12
mdx.cc
View file

@ -266,22 +266,22 @@ public:
virtual void deferredInit(); virtual void deferredInit();
virtual string getName() throw() virtual string getName() noexcept
{ {
return dictionaryName; return dictionaryName;
} }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ {
return map< Dictionary::Property, string >(); return map< Dictionary::Property, string >();
} }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ {
return idxHeader.articleCount; return idxHeader.articleCount;
} }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ {
return idxHeader.wordCount; return idxHeader.wordCount;
} }
@ -327,7 +327,7 @@ public:
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
private: private:
@ -925,7 +925,7 @@ const QString & MdxDictionary::getDescription()
return dictionaryDescription; return dictionaryDescription;
} }
void MdxDictionary::loadIcon() throw() void MdxDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -47,16 +47,16 @@ public:
langId = LangCoder::code2toInt( url.mid( n - 2, 2 ).toLatin1().data() ); langId = LangCoder::code2toInt( url.mid( n - 2, 2 ).toLatin1().data() );
} }
virtual string getName() throw() virtual string getName() noexcept
{ return name; } { return name; }
virtual map< Property, string > getProperties() throw() virtual map< Property, string > getProperties() noexcept
{ return map< Property, string >(); } { return map< Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return 0; } { return 0; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return 0; } { return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const &, virtual sptr< WordSearchRequest > prefixMatch( wstring const &,
@ -73,11 +73,11 @@ public:
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
}; };
void MediaWikiDictionary::loadIcon() throw() void MediaWikiDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -30,16 +30,16 @@ public:
{ {
} }
virtual string getName() throw() virtual string getName() noexcept
{ return prg.name.toUtf8().data(); } { return prg.name.toUtf8().data(); }
virtual map< Property, string > getProperties() throw() virtual map< Property, string > getProperties() noexcept
{ return map< Property, string >(); } { return map< Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return 0; } { return 0; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return 0; } { return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const & word, virtual sptr< WordSearchRequest > prefixMatch( wstring const & word,
@ -53,7 +53,7 @@ public:
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
}; };
sptr< WordSearchRequest > ProgramsDictionary::prefixMatch( wstring const & word, sptr< WordSearchRequest > ProgramsDictionary::prefixMatch( wstring const & word,
@ -118,7 +118,7 @@ sptr< Dictionary::DataRequest > ProgramsDictionary::getArticle(
} }
} }
void ProgramsDictionary::loadIcon() throw() void ProgramsDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -143,16 +143,16 @@ class SdictDictionary: public BtreeIndexing::BtreeDictionary
~SdictDictionary(); ~SdictDictionary();
virtual string getName() throw() virtual string getName() noexcept
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
@ -187,7 +187,7 @@ class SdictDictionary: public BtreeIndexing::BtreeDictionary
} }
protected: protected:
void loadIcon() throw(); void loadIcon() noexcept;
private: private:
@ -240,7 +240,7 @@ SdictDictionary::~SdictDictionary()
df.close(); df.close();
} }
void SdictDictionary::loadIcon() throw() void SdictDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

12
slob.cc
View file

@ -587,16 +587,16 @@ class SlobDictionary: public BtreeIndexing::BtreeDictionary
~SlobDictionary(); ~SlobDictionary();
virtual string getName() throw() virtual string getName() noexcept
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
@ -643,7 +643,7 @@ class SlobDictionary: public BtreeIndexing::BtreeDictionary
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
private: private:
@ -746,7 +746,7 @@ void SlobDictionary::removeDirectory( QString const & directory )
dir.rmdir( directory ); dir.rmdir( directory );
} }
void SlobDictionary::loadIcon() throw() void SlobDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -79,16 +79,16 @@ public:
vector< string > const & dictionaryFiles, vector< string > const & dictionaryFiles,
QString const & iconFilename_ ); QString const & iconFilename_ );
virtual string getName() throw() virtual string getName() noexcept
{ return name; } { return name; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.soundsCount; } { return idxHeader.soundsCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return getArticleCount(); } { return getArticleCount(); }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &, virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
@ -102,7 +102,7 @@ public:
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
}; };
SoundDirDictionary::SoundDirDictionary( string const & id, SoundDirDictionary::SoundDirDictionary( string const & id,
@ -289,7 +289,7 @@ sptr< Dictionary::DataRequest > SoundDirDictionary::getArticle( wstring const &
return ret; return ret;
} }
void SoundDirDictionary::loadIcon() throw() void SoundDirDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -155,16 +155,16 @@ public:
~StardictDictionary(); ~StardictDictionary();
virtual string getName() throw() virtual string getName() noexcept
{ return bookName; } { return bookName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount + idxHeader.synWordCount; } { return idxHeader.wordCount + idxHeader.synWordCount; }
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
@ -207,7 +207,7 @@ public:
} }
protected: protected:
void loadIcon() throw(); void loadIcon() noexcept;
private: private:
@ -292,7 +292,7 @@ StardictDictionary::~StardictDictionary()
dict_data_close( dz ); dict_data_close( dz );
} }
void StardictDictionary::loadIcon() throw() void StardictDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -22,16 +22,16 @@ BaseTransliterationDictionary::BaseTransliterationDictionary( string const & id,
dictionaryIconLoaded = true; dictionaryIconLoaded = true;
} }
string BaseTransliterationDictionary::getName() throw() string BaseTransliterationDictionary::getName() noexcept
{ return name; } { return name; }
map< Dictionary::Property, string > BaseTransliterationDictionary::getProperties() throw() map< Dictionary::Property, string > BaseTransliterationDictionary::getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
unsigned long BaseTransliterationDictionary::getArticleCount() throw() unsigned long BaseTransliterationDictionary::getArticleCount() noexcept
{ return 0; } { return 0; }
unsigned long BaseTransliterationDictionary::getWordCount() throw() unsigned long BaseTransliterationDictionary::getWordCount() noexcept
{ return 0; } { return 0; }
sptr< Dictionary::WordSearchRequest > BaseTransliterationDictionary::prefixMatch( wstring const &, sptr< Dictionary::WordSearchRequest > BaseTransliterationDictionary::prefixMatch( wstring const &,
@ -83,7 +83,7 @@ TransliterationDictionary::TransliterationDictionary( string const & id,
} }
vector< wstring > TransliterationDictionary::getAlternateWritings( wstring const & str ) vector< wstring > TransliterationDictionary::getAlternateWritings( wstring const & str )
throw() noexcept
{ {
vector< wstring > results; vector< wstring > results;

View file

@ -28,16 +28,16 @@ public:
BaseTransliterationDictionary( string const & id, string const & name, BaseTransliterationDictionary( string const & id, string const & name,
QIcon icon, bool caseSensitive = true ); QIcon icon, bool caseSensitive = true );
virtual string getName() throw(); virtual string getName() noexcept;
virtual map< Dictionary::Property, string > getProperties() throw(); virtual map< Dictionary::Property, string > getProperties() noexcept;
virtual unsigned long getArticleCount() throw(); virtual unsigned long getArticleCount() noexcept;
virtual unsigned long getWordCount() throw(); virtual unsigned long getWordCount() noexcept;
virtual vector< wstring > getAlternateWritings( wstring const & ) virtual vector< wstring > getAlternateWritings( wstring const & )
throw() = 0; noexcept = 0;
virtual sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & ) virtual sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & )
; ;
@ -85,7 +85,7 @@ public:
bool caseSensitive = true ); bool caseSensitive = true );
virtual vector< wstring > getAlternateWritings( wstring const & ) virtual vector< wstring > getAlternateWritings( wstring const & )
throw(); noexcept;
}; };
} }

View file

@ -132,7 +132,7 @@ long decode( char const * in_, size_t inSize, wchar * out_ )
return out - out_; return out - out_;
} }
string encode( wstring const & in ) throw() string encode( wstring const & in ) noexcept
{ {
if( in.size() == 0 ) if( in.size() == 0 )
return string(); return string();

View file

@ -44,7 +44,7 @@ size_t encode( wchar const * in, size_t inSize, char * out );
long decode( char const * in, size_t inSize, wchar * out ); long decode( char const * in, size_t inSize, wchar * out );
/// Versions for non time-critical code. /// Versions for non time-critical code.
string encode( wstring const & ) throw(); string encode( wstring const & ) noexcept;
wstring decode( string const & ) ; wstring decode( string const & ) ;
/// Since the standard isspace() is locale-specific, we need something /// Since the standard isspace() is locale-specific, we need something

View file

@ -118,6 +118,16 @@ inline QString json2String( const QJsonObject & json )
return QString( QJsonDocument( json ).toJson( QJsonDocument::Compact ) ); return QString( QJsonDocument( json ).toJson( QJsonDocument::Compact ) );
} }
inline QStringList repeat( const QString str, const int times )
{
QStringList list;
for( int i = 0; i < times; i++ )
{
list << str;
}
return list;
}
namespace AtomicInt namespace AtomicInt
{ {

View file

@ -44,16 +44,16 @@ public:
{ {
} }
virtual string getName() throw() virtual string getName() noexcept
{ return voiceEngine.name.toUtf8().data(); } { return voiceEngine.name.toUtf8().data(); }
virtual map< Property, string > getProperties() throw() virtual map< Property, string > getProperties() noexcept
{ return map< Property, string >(); } { return map< Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return 0; } { return 0; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return 0; } { return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const & word, virtual sptr< WordSearchRequest > prefixMatch( wstring const & word,
@ -67,7 +67,7 @@ public:
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
}; };
sptr< WordSearchRequest > VoiceEnginesDictionary::prefixMatch( wstring const & /*word*/, sptr< WordSearchRequest > VoiceEnginesDictionary::prefixMatch( wstring const & /*word*/,
@ -110,7 +110,7 @@ sptr< Dictionary::DataRequest > VoiceEnginesDictionary::getArticle(
return ret; return ret;
} }
void VoiceEnginesDictionary::loadIcon() throw() void VoiceEnginesDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -53,16 +53,16 @@ public:
dictionaryDescription = temp; dictionaryDescription = temp;
} }
virtual string getName() throw() virtual string getName() noexcept
{ return name; } { return name; }
virtual map< Property, string > getProperties() throw() virtual map< Property, string > getProperties() noexcept
{ return map< Property, string >(); } { return map< Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return 0; } { return 0; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return 0; } { return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const & word, virtual sptr< WordSearchRequest > prefixMatch( wstring const & word,
@ -79,7 +79,7 @@ public:
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
}; };
sptr< WordSearchRequest > WebSiteDictionary::prefixMatch( wstring const & /*word*/, sptr< WordSearchRequest > WebSiteDictionary::prefixMatch( wstring const & /*word*/,
@ -526,7 +526,7 @@ sptr< Dictionary::DataRequest > WebSiteDictionary::getResource( string const & n
return new WebSiteResourceRequest( link, netMgr, this ); return new WebSiteResourceRequest( link, netMgr, this );
} }
void WebSiteDictionary::loadIcon() throw() void WebSiteDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

12
xdxf.cc
View file

@ -147,16 +147,16 @@ public:
~XdxfDictionary(); ~XdxfDictionary();
virtual string getName() throw() virtual string getName() noexcept
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
@ -200,7 +200,7 @@ public:
protected: protected:
void loadIcon() throw(); void loadIcon() noexcept;
private: private:
@ -312,7 +312,7 @@ XdxfDictionary::~XdxfDictionary()
dict_data_close( dz ); dict_data_close( dz );
} }
void XdxfDictionary::loadIcon() throw() void XdxfDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

12
zim.cc
View file

@ -669,16 +669,16 @@ class ZimDictionary: public BtreeIndexing::BtreeDictionary
~ZimDictionary(); ~ZimDictionary();
virtual string getName() throw() virtual string getName() noexcept
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline virtual quint32 getLangFrom() const
@ -725,7 +725,7 @@ class ZimDictionary: public BtreeIndexing::BtreeDictionary
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
private: private:
@ -792,7 +792,7 @@ ZimDictionary::~ZimDictionary()
df.close(); df.close();
} }
void ZimDictionary::loadIcon() throw() void ZimDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;

View file

@ -114,15 +114,15 @@ public:
ZipSoundsDictionary( string const & id, string const & indexFile, ZipSoundsDictionary( string const & id, string const & indexFile,
vector< string > const & dictionaryFiles ); vector< string > const & dictionaryFiles );
virtual string getName() throw(); virtual string getName() noexcept;
virtual map< Dictionary::Property, string > getProperties() throw() virtual map< Dictionary::Property, string > getProperties() noexcept
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() throw() virtual unsigned long getArticleCount() noexcept
{ return idxHeader.soundsCount; } { return idxHeader.soundsCount; }
virtual unsigned long getWordCount() throw() virtual unsigned long getWordCount() noexcept
{ return getArticleCount(); } { return getArticleCount(); }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &, virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
@ -136,7 +136,7 @@ public:
protected: protected:
virtual void loadIcon() throw(); virtual void loadIcon() noexcept;
}; };
ZipSoundsDictionary::ZipSoundsDictionary( string const & id, ZipSoundsDictionary::ZipSoundsDictionary( string const & id,
@ -164,7 +164,7 @@ ZipSoundsDictionary::ZipSoundsDictionary( string const & id,
} }
string ZipSoundsDictionary::getName() throw() string ZipSoundsDictionary::getName() noexcept
{ {
string result = FsEncoding::basename( getDictionaryFilenames()[ 0 ] ); string result = FsEncoding::basename( getDictionaryFilenames()[ 0 ] );
@ -384,7 +384,7 @@ sptr< Dictionary::DataRequest > ZipSoundsDictionary::getResource( string const &
return new Dictionary::DataRequestInstant( false ); return new Dictionary::DataRequestInstant( false );
} }
void ZipSoundsDictionary::loadIcon() throw() void ZipSoundsDictionary::loadIcon() noexcept
{ {
if ( dictionaryIconLoaded ) if ( dictionaryIconLoaded )
return; return;