mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Replace sptr with std::shared_ptr
* Make sptr an alias of std::shared_ptr * Make old sptr's implicit conversion explict through std::make_shared
This commit is contained in:
parent
732def3945
commit
4452c06c3e
6
aard.cc
6
aard.cc
|
@ -642,7 +642,7 @@ sptr< Dictionary::DataRequest > AardDictionary::getSearchResults( QString const
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
/// AardDictionary::getArticle()
|
||||
|
@ -829,7 +829,7 @@ sptr< Dictionary::DataRequest > AardDictionary::getArticle( wstring const & word
|
|||
bool ignoreDiacritics )
|
||||
|
||||
{
|
||||
return new AardArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<AardArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -1070,7 +1070,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
} // if need to rebuild
|
||||
try
|
||||
{
|
||||
dictionaries.push_back( new AardDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<AardDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles ) );
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeDefinitionFor(
|
|||
|
||||
string header = makeHtmlHeader( phrase.phrase, QString(), true );
|
||||
|
||||
return new ArticleRequest( phrase, "",
|
||||
return std::make_shared<ArticleRequest>( phrase, "",
|
||||
contexts, ftsDicts, header,
|
||||
-1, true );
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeDefinitionFor(
|
|||
|
||||
result += "</body></html>";
|
||||
|
||||
sptr< Dictionary::DataRequestInstant > r = new Dictionary::DataRequestInstant( true );
|
||||
sptr< Dictionary::DataRequestInstant > r = std::make_shared<Dictionary::DataRequestInstant>( true );
|
||||
|
||||
r->getData().resize( result.size() );
|
||||
memcpy( &( r->getData().front() ), result.data(), result.size() );
|
||||
|
@ -318,13 +318,13 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeDefinitionFor(
|
|||
QString::fromStdString( activeDicts[ x ]->getId() ) ) )
|
||||
unmutedDicts.push_back( activeDicts[ x ] );
|
||||
|
||||
return new ArticleRequest( phrase, activeGroup ? activeGroup->name : "",
|
||||
return std::make_shared<ArticleRequest>( phrase, activeGroup ? activeGroup->name : "",
|
||||
contexts, unmutedDicts, header,
|
||||
collapseBigArticles ? articleLimitSize : -1,
|
||||
needExpandOptionalParts, ignoreDiacritics );
|
||||
}
|
||||
else
|
||||
return new ArticleRequest( phrase, activeGroup ? activeGroup->name : "",
|
||||
return std::make_shared<ArticleRequest>( phrase, activeGroup ? activeGroup->name : "",
|
||||
contexts, activeDicts, header,
|
||||
collapseBigArticles ? articleLimitSize : -1,
|
||||
needExpandOptionalParts, ignoreDiacritics );
|
||||
|
@ -336,7 +336,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeNotFoundTextFor(
|
|||
string result = makeHtmlHeader( word, QString(), true ) + makeNotFoundBody( word, group ) +
|
||||
"</body></html>";
|
||||
|
||||
sptr< Dictionary::DataRequestInstant > r = new Dictionary::DataRequestInstant( true );
|
||||
sptr< Dictionary::DataRequestInstant > r = std::make_shared<Dictionary::DataRequestInstant>( true );
|
||||
|
||||
r->getData().resize( result.size() );
|
||||
memcpy( &( r->getData().front() ), result.data(), result.size() );
|
||||
|
@ -350,7 +350,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeEmptyPage() const
|
|||
"</body></html>";
|
||||
|
||||
sptr< Dictionary::DataRequestInstant > r =
|
||||
new Dictionary::DataRequestInstant( true );
|
||||
std::make_shared<Dictionary::DataRequestInstant>( true );
|
||||
|
||||
r->getData().resize( result.size() );
|
||||
memcpy( &( r->getData().front() ), result.data(), result.size() );
|
||||
|
@ -366,7 +366,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makePicturePage( string const & ur
|
|||
+ "</body></html>";
|
||||
|
||||
sptr< Dictionary::DataRequestInstant > r =
|
||||
new Dictionary::DataRequestInstant( true );
|
||||
std::make_shared<Dictionary::DataRequestInstant>( true );
|
||||
|
||||
r->getData().resize( result.size() );
|
||||
memcpy( &( r->getData().front() ), result.data(), result.size() );
|
||||
|
@ -713,7 +713,7 @@ void ArticleRequest::bodyFinished()
|
|||
footer += ArticleMaker::makeNotFoundBody( word.size() < 40 ? word : "", group );
|
||||
|
||||
// When there were no definitions, we run stemmed search.
|
||||
stemmedWordFinder = new WordFinder( this );
|
||||
stemmedWordFinder = std::make_shared<WordFinder>( this );
|
||||
|
||||
connect( stemmedWordFinder.get(), SIGNAL( finished() ),
|
||||
this, SLOT( stemmedSearchFinished() ), Qt::QueuedConnection );
|
||||
|
|
|
@ -263,7 +263,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
|
|||
if( !url.host().isEmpty() && url.host() != "localhost" )
|
||||
{
|
||||
// Strange request - ignore it
|
||||
return new Dictionary::DataRequestInstant( false );
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false );
|
||||
}
|
||||
|
||||
contentType = "text/html";
|
||||
|
@ -339,7 +339,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
|
|||
buffer.open(QIODevice::WriteOnly);
|
||||
dictionaries[ x ]->getIcon().pixmap( 64 ).save(&buffer, "PNG");
|
||||
buffer.close();
|
||||
sptr< Dictionary::DataRequestInstant > ico = new Dictionary::DataRequestInstant( true );
|
||||
sptr< Dictionary::DataRequestInstant > ico = std::make_shared<Dictionary::DataRequestInstant>( true );
|
||||
ico->getData().resize( bytes.size() );
|
||||
memcpy( &( ico->getData().front() ), bytes.data(), bytes.size() );
|
||||
return ico;
|
||||
|
|
|
@ -1217,7 +1217,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
|
|||
if ( Dictionary::WebMultimediaDownload::isAudioUrl( url ) )
|
||||
{
|
||||
sptr< Dictionary::DataRequest > req =
|
||||
new Dictionary::WebMultimediaDownload( url, articleNetMgr );
|
||||
std::make_shared<Dictionary::WebMultimediaDownload>( url, articleNetMgr );
|
||||
|
||||
resourceDownloadRequests.push_back( req );
|
||||
|
||||
|
@ -1552,7 +1552,7 @@ ResourceToSaveHandler * ArticleView::saveResource( const QUrl & url, const QUrl
|
|||
}
|
||||
else
|
||||
{
|
||||
req = new Dictionary::WebMultimediaDownload( url, articleNetMgr );
|
||||
req = std::make_shared<Dictionary::WebMultimediaDownload>( url, articleNetMgr );
|
||||
|
||||
handler->addRequest( req );
|
||||
}
|
||||
|
@ -2550,7 +2550,7 @@ void ArticleView::highlightFTSResults()
|
|||
|
||||
if( regexp.pattern().isEmpty() || !regexp.isValid() )
|
||||
return;
|
||||
sptr< AccentMarkHandler > marksHandler = ignoreDiacritics ? new DiacriticsHandler : new AccentMarkHandler;
|
||||
sptr< AccentMarkHandler > marksHandler = ignoreDiacritics ? std::make_shared<DiacriticsHandler>() : std::make_shared<AccentMarkHandler>();
|
||||
|
||||
marksHandler->setText( pageText );
|
||||
|
||||
|
|
|
@ -413,13 +413,13 @@ std::vector< sptr< Dictionary::Class > > makeDictionaries()
|
|||
static BelarusianSchoolToClassicTable t2;
|
||||
std::vector< sptr< Dictionary::Class > > dicts;
|
||||
|
||||
dicts.push_back( new Transliteration::TransliterationDictionary( "c31b24abf412abc9b23bb40a898f1040",
|
||||
dicts.push_back( std::make_shared<Transliteration::TransliterationDictionary>( "c31b24abf412abc9b23bb40a898f1040",
|
||||
QCoreApplication::translate( "BelarusianTranslit", "Belarusian transliteration from latin to cyrillic (classic orthography)" ).toUtf8().data(),
|
||||
QIcon( ":/flags/by.png" ), t0, false ) );
|
||||
dicts.push_back( new Transliteration::TransliterationDictionary( "c31b24abf412abc9b23bb40a898f1041",
|
||||
dicts.push_back( std::make_shared<Transliteration::TransliterationDictionary>( "c31b24abf412abc9b23bb40a898f1041",
|
||||
QCoreApplication::translate( "BelarusianTranslit", "Belarusian transliteration from latin to cyrillic (school orthography)" ).toUtf8().data(),
|
||||
QIcon( ":/flags/by.png" ), t1, false ) );
|
||||
dicts.push_back( new Transliteration::TransliterationDictionary( "c31b24abf412abc9b23bb40a898f1042",
|
||||
dicts.push_back( std::make_shared<Transliteration::TransliterationDictionary>( "c31b24abf412abc9b23bb40a898f1042",
|
||||
QCoreApplication::translate( "BelarusianTranslit", "Belarusian transliteration (smoothes out the difference\n"
|
||||
"between classic and school orthography in cyrillic)" ).toUtf8().data(),
|
||||
QIcon( ":/flags/by.png" ), t2, false ) );
|
||||
|
|
12
bgl.cc
12
bgl.cc
|
@ -602,7 +602,7 @@ sptr< Dictionary::WordSearchRequest >
|
|||
BglDictionary::findHeadwordsForSynonym( wstring const & word )
|
||||
|
||||
{
|
||||
return synonymSearchEnabled ? new BglHeadwordsRequest( word, *this ) :
|
||||
return synonymSearchEnabled ? std::make_shared<BglHeadwordsRequest>( word, *this ) :
|
||||
Class::findHeadwordsForSynonym( word );
|
||||
}
|
||||
|
||||
|
@ -926,7 +926,7 @@ sptr< Dictionary::DataRequest > BglDictionary::getArticle( wstring const & word,
|
|||
bool ignoreDiacritics )
|
||||
|
||||
{
|
||||
return new BglArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<BglArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1070,8 +1070,8 @@ void BglResourceRequest::run()
|
|||
sptr< Dictionary::DataRequest > BglDictionary::getResource( string const & name )
|
||||
|
||||
{
|
||||
return new BglResourceRequest( idxMutex, idx, idxHeader.resourceListOffset,
|
||||
idxHeader.resourcesCount, name );
|
||||
return std::shared_ptr<BglResourceRequest>(new BglResourceRequest(idxMutex, idx, idxHeader.resourceListOffset,
|
||||
idxHeader.resourcesCount, name ));
|
||||
}
|
||||
|
||||
/// Replaces <CHARSET c="t">1234;</CHARSET> occurrences with ሴ
|
||||
|
@ -1161,7 +1161,7 @@ sptr< Dictionary::DataRequest > BglDictionary::getSearchResults( QString const &
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1347,7 +1347,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
|
||||
try
|
||||
{
|
||||
dictionaries.push_back( new BglDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<BglDictionary>( dictId,
|
||||
indexFile,
|
||||
*i ) );
|
||||
}
|
||||
|
|
|
@ -450,7 +450,7 @@ sptr< Dictionary::WordSearchRequest > BtreeDictionary::prefixMatch(
|
|||
wstring const & str, unsigned long maxResults )
|
||||
|
||||
{
|
||||
return new BtreeWordSearchRequest( *this, str, 0, -1, true, maxResults );
|
||||
return std::make_shared<BtreeWordSearchRequest>( *this, str, 0, -1, true, maxResults );
|
||||
}
|
||||
|
||||
sptr< Dictionary::WordSearchRequest > BtreeDictionary::stemmedMatch(
|
||||
|
@ -458,7 +458,7 @@ sptr< Dictionary::WordSearchRequest > BtreeDictionary::stemmedMatch(
|
|||
unsigned long maxResults )
|
||||
|
||||
{
|
||||
return new BtreeWordSearchRequest( *this, str, minLength, (int)maxSuffixVariation,
|
||||
return std::make_shared<BtreeWordSearchRequest>( *this, str, minLength, (int)maxSuffixVariation,
|
||||
false, maxResults );
|
||||
}
|
||||
|
||||
|
|
|
@ -125,21 +125,21 @@ std::vector< sptr< Dictionary::Class > > makeDictionaries( Config::Chinese const
|
|||
{
|
||||
if ( cfg.enableSCToTWConversion )
|
||||
{
|
||||
result.push_back( new CharacterConversionDictionary( "bf1c33a59cbacea8f39b5b5475787cfd",
|
||||
result.push_back( std::make_shared<CharacterConversionDictionary>( "bf1c33a59cbacea8f39b5b5475787cfd",
|
||||
QCoreApplication::translate( "ChineseConversion", "Simplified to traditional Chinese (Taiwan variant) conversion" ).toUtf8().data(),
|
||||
QIcon( ":/flags/tw.png" ), configDir + "s2tw.json" ) );
|
||||
}
|
||||
|
||||
if ( cfg.enableSCToHKConversion )
|
||||
{
|
||||
result.push_back( new CharacterConversionDictionary( "9e0681fb9e1c0b6c90e6fb46111d96b5",
|
||||
result.push_back( std::make_shared<CharacterConversionDictionary>( "9e0681fb9e1c0b6c90e6fb46111d96b5",
|
||||
QCoreApplication::translate( "ChineseConversion", "Simplified to traditional Chinese (Hong Kong variant) conversion" ).toUtf8().data(),
|
||||
QIcon( ":/flags/hk.png" ), configDir + "s2hk.json" ) );
|
||||
}
|
||||
|
||||
if ( cfg.enableTCToSCConversion )
|
||||
{
|
||||
result.push_back( new CharacterConversionDictionary( "0db536ce0bdc52ea30d11a82c5db4a27",
|
||||
result.push_back( std::make_shared<CharacterConversionDictionary>( "0db536ce0bdc52ea30d11a82c5db4a27",
|
||||
QCoreApplication::translate( "ChineseConversion", "Traditional to simplified Chinese conversion" ).toUtf8().data(),
|
||||
QIcon( ":/flags/cn.png" ), configDir + "t2s.json" ) );
|
||||
}
|
||||
|
|
|
@ -418,7 +418,7 @@ sptr< Dictionary::DataRequest > DictdDictionary::getArticle( wstring const & wor
|
|||
}
|
||||
|
||||
if ( mainArticles.empty() && alternateArticles.empty() )
|
||||
return new Dictionary::DataRequestInstant( false );
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false );
|
||||
|
||||
string result;
|
||||
|
||||
|
@ -431,7 +431,7 @@ sptr< Dictionary::DataRequest > DictdDictionary::getArticle( wstring const & wor
|
|||
result += i->second;
|
||||
|
||||
sptr< Dictionary::DataRequestInstant > ret =
|
||||
new Dictionary::DataRequestInstant( true );
|
||||
std::make_shared<Dictionary::DataRequestInstant>( true );
|
||||
|
||||
ret->getData().resize( result.size() );
|
||||
|
||||
|
@ -441,7 +441,7 @@ sptr< Dictionary::DataRequest > DictdDictionary::getArticle( wstring const & wor
|
|||
}
|
||||
catch( std::exception & e )
|
||||
{
|
||||
return new Dictionary::DataRequestInstant( QString( e.what() ) );
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( QString( e.what() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,7 @@ sptr< Dictionary::DataRequest > DictdDictionary::getSearchResults( QString const
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -771,7 +771,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
idx.write( &idxHeader, sizeof( idxHeader ) );
|
||||
}
|
||||
|
||||
dictionaries.push_back( new DictdDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<DictdDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles ) );
|
||||
}
|
||||
|
|
|
@ -147,13 +147,13 @@ sptr< WordSearchRequest > Class::stemmedMatch( wstring const & /*str*/,
|
|||
unsigned long /*maxResults*/ )
|
||||
|
||||
{
|
||||
return new WordSearchRequestInstant();
|
||||
return std::make_shared<WordSearchRequestInstant>();
|
||||
}
|
||||
|
||||
sptr< WordSearchRequest > Class::findHeadwordsForSynonym( wstring const & )
|
||||
|
||||
{
|
||||
return new WordSearchRequestInstant();
|
||||
return std::make_shared<WordSearchRequestInstant>();
|
||||
}
|
||||
|
||||
vector< wstring > Class::getAlternateWritings( wstring const & )
|
||||
|
@ -165,12 +165,12 @@ vector< wstring > Class::getAlternateWritings( wstring const & )
|
|||
sptr< DataRequest > Class::getResource( string const & /*name*/ )
|
||||
|
||||
{
|
||||
return new DataRequestInstant( false );
|
||||
return std::make_shared<DataRequestInstant>( false );
|
||||
}
|
||||
|
||||
sptr< DataRequest > Class::getSearchResults(const QString &, int, bool, int, int, bool, bool )
|
||||
{
|
||||
return new DataRequestInstant( false );
|
||||
return std::make_shared<DataRequestInstant>( false );
|
||||
}
|
||||
|
||||
QString const& Class::getDescription()
|
||||
|
|
|
@ -925,10 +925,10 @@ sptr< WordSearchRequest > DictServerDictionary::prefixMatch( wstring const & wor
|
|||
{
|
||||
// Don't make excessively large queries -- they're fruitless anyway
|
||||
|
||||
return new WordSearchRequestInstant();
|
||||
return std::make_shared<WordSearchRequestInstant>();
|
||||
}
|
||||
else
|
||||
return new DictServerWordSearchRequest( word, *this );
|
||||
return std::make_shared<DictServerWordSearchRequest>( word, *this );
|
||||
}
|
||||
|
||||
sptr< DataRequest > DictServerDictionary::getArticle( wstring const & word,
|
||||
|
@ -940,10 +940,10 @@ sptr< DataRequest > DictServerDictionary::getArticle( wstring const & word,
|
|||
{
|
||||
// Don't make excessively large queries -- they're fruitless anyway
|
||||
|
||||
return new DataRequestInstant( false );
|
||||
return std::make_shared<DataRequestInstant>( false );
|
||||
}
|
||||
else
|
||||
return new DictServerArticleRequest( word, *this );
|
||||
return std::make_shared<DictServerArticleRequest>( word, *this );
|
||||
}
|
||||
|
||||
} // Anonimuos namespace
|
||||
|
@ -956,7 +956,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::DictServers const
|
|||
for( int x = 0; x < servers.size(); ++x )
|
||||
{
|
||||
if ( servers[ x ].enabled )
|
||||
result.push_back( new DictServerDictionary( servers[ x ].id.toStdString(),
|
||||
result.push_back( std::make_shared<DictServerDictionary>( servers[ x ].id.toStdString(),
|
||||
servers[ x ].name.toUtf8().data(),
|
||||
servers[ x ].url,
|
||||
servers[ x ].databases,
|
||||
|
|
10
dsl.cc
10
dsl.cc
|
@ -386,7 +386,7 @@ void DslDictionary::doDeferredInit()
|
|||
// the init is complete.
|
||||
//Mutex::Lock _( idxMutex );
|
||||
|
||||
chunks = new ChunkedStorage::Reader( idx, idxHeader.chunksOffset );
|
||||
chunks = std::shared_ptr<ChunkedStorage::Reader>(new ChunkedStorage::Reader(idx, idxHeader.chunksOffset));
|
||||
|
||||
// Open the .dsl file
|
||||
|
||||
|
@ -1727,7 +1727,7 @@ sptr< Dictionary::DataRequest > DslDictionary::getArticle( wstring const & word,
|
|||
bool ignoreDiacritics )
|
||||
|
||||
{
|
||||
return new DslArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<DslArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
//// DslDictionary::getResource()
|
||||
|
@ -1861,7 +1861,7 @@ void DslResourceRequest::run()
|
|||
sptr< Dictionary::DataRequest > DslDictionary::getResource( string const & name )
|
||||
|
||||
{
|
||||
return new DslResourceRequest( *this, name );
|
||||
return std::make_shared<DslResourceRequest>( *this, name );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1872,7 +1872,7 @@ sptr< Dictionary::DataRequest > DslDictionary::getSearchResults( QString const &
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -2389,7 +2389,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
|
||||
} // if need to rebuild
|
||||
|
||||
dictionaries.push_back( new DslDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<DslDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles,
|
||||
maxPictureWidth ) );
|
||||
|
|
|
@ -240,7 +240,7 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups )
|
|||
if ( rebuildGroups )
|
||||
{
|
||||
orderAndProps = new OrderAndProps( this, savedOrder, savedInactive, dictionaries );
|
||||
groups = new Groups( this, dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() );
|
||||
groups = std::make_shared<Groups>( this, dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() );
|
||||
|
||||
ui.tabs->removeTab( 1 );
|
||||
ui.tabs->removeTab( 1 );
|
||||
|
|
12
epwing.cc
12
epwing.cc
|
@ -653,7 +653,7 @@ sptr< Dictionary::DataRequest > EpwingDictionary::getArticle( wstring const & wo
|
|||
bool ignoreDiacritics )
|
||||
|
||||
{
|
||||
return new EpwingArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<EpwingArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
//// EpwingDictionary::getResource()
|
||||
|
@ -781,7 +781,7 @@ void EpwingResourceRequest::run()
|
|||
sptr< Dictionary::DataRequest > EpwingDictionary::getResource( string const & name )
|
||||
|
||||
{
|
||||
return new EpwingResourceRequest( *this, name );
|
||||
return std::make_shared<EpwingResourceRequest>( *this, name );
|
||||
}
|
||||
|
||||
|
||||
|
@ -792,7 +792,7 @@ sptr< Dictionary::DataRequest > EpwingDictionary::getSearchResults( QString cons
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
int EpwingDictionary::japaneseWriting( gd::wchar ch )
|
||||
|
@ -928,7 +928,7 @@ sptr< Dictionary::WordSearchRequest > EpwingDictionary::prefixMatch(
|
|||
wstring const & str, unsigned long maxResults )
|
||||
|
||||
{
|
||||
return new EpwingWordSearchRequest( *this, str, 0, -1, true, maxResults );
|
||||
return std::make_shared<EpwingWordSearchRequest>( *this, str, 0, -1, true, maxResults );
|
||||
}
|
||||
|
||||
sptr< Dictionary::WordSearchRequest > EpwingDictionary::stemmedMatch(
|
||||
|
@ -936,7 +936,7 @@ sptr< Dictionary::WordSearchRequest > EpwingDictionary::stemmedMatch(
|
|||
unsigned long maxResults )
|
||||
|
||||
{
|
||||
return new EpwingWordSearchRequest( *this, str, minLength, (int)maxSuffixVariation,
|
||||
return std::make_shared<EpwingWordSearchRequest>( *this, str, minLength, (int)maxSuffixVariation,
|
||||
false, maxResults );
|
||||
}
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
|
||||
} // If need to rebuild
|
||||
|
||||
dictionaries.push_back( new EpwingDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<EpwingDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles,
|
||||
sb ) );
|
||||
|
|
10
forvo.cc
10
forvo.cc
|
@ -57,7 +57,7 @@ public:
|
|||
virtual sptr< WordSearchRequest > prefixMatch( wstring const & /*word*/,
|
||||
unsigned long /*maxResults*/ )
|
||||
{
|
||||
sptr< WordSearchRequestInstant > sr = new WordSearchRequestInstant;
|
||||
sptr< WordSearchRequestInstant > sr = std::make_shared<WordSearchRequestInstant>();
|
||||
|
||||
sr->setUncertain( true );
|
||||
|
||||
|
@ -83,11 +83,11 @@ sptr< DataRequest > ForvoDictionary::getArticle( wstring const & word,
|
|||
{
|
||||
// Don't make excessively large queries -- they're fruitless anyway
|
||||
|
||||
return new DataRequestInstant( false );
|
||||
return std::make_shared<DataRequestInstant>( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ForvoArticleRequest( word, alts, apiKey, languageCode, getId(),
|
||||
return std::make_shared<ForvoArticleRequest>( word, alts, apiKey, languageCode, getId(),
|
||||
netMgr );
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ void ForvoArticleRequest::addQuery( QNetworkAccessManager & mgr,
|
|||
|
||||
// GD_DPRINTF( "req: %s\n", reqUrl.toEncoded().data() );
|
||||
|
||||
sptr< QNetworkReply > netReply = mgr.get( QNetworkRequest( reqUrl ) );
|
||||
sptr< QNetworkReply > netReply = std::shared_ptr<QNetworkReply>(mgr.get( QNetworkRequest( reqUrl ) ));
|
||||
|
||||
netReplies.push_back( NetReply( netReply, Utf8::encode( str ) ) );
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
displayedCode[ 0 ] = displayedCode[ 0 ].toUpper();
|
||||
|
||||
result.push_back(
|
||||
new ForvoDictionary( hash.result().toHex().data(),
|
||||
std::make_shared<ForvoDictionary>( hash.result().toHex().data(),
|
||||
QString( "Forvo (%1)" ).arg( displayedCode ).toUtf8().data(),
|
||||
forvo.apiKey, code, mgr ) );
|
||||
|
||||
|
|
|
@ -1247,7 +1247,7 @@ void FTSResultsRequest::run()
|
|||
ftsIdxHeader.indexRootOffset ),
|
||||
ftsIdx, dict.getFtsMutex() );
|
||||
|
||||
chunks = new ChunkedStorage::Reader( ftsIdx, ftsIdxHeader.chunksOffset );
|
||||
chunks = std::shared_ptr<ChunkedStorage::Reader>(new ChunkedStorage::Reader(ftsIdx, ftsIdxHeader.chunksOffset));
|
||||
}
|
||||
|
||||
if( hasCJK )
|
||||
|
|
|
@ -44,7 +44,7 @@ sptr< Dictionary::Class > makeDictionary()
|
|||
{
|
||||
static GermanTable t;
|
||||
|
||||
return new Transliteration::TransliterationDictionary( "cf1b74acd98adea9b2bba16af38f1081",
|
||||
return std::make_shared<Transliteration::TransliterationDictionary>( "cf1b74acd98adea9b2bba16af38f1081",
|
||||
QCoreApplication::translate( "GermanTranslit", "German Transliteration" ).toUtf8().data(),
|
||||
QIcon( ":/flags/de.png" ), t );
|
||||
}
|
||||
|
|
12
gls.cc
12
gls.cc
|
@ -979,8 +979,8 @@ sptr< Dictionary::WordSearchRequest >
|
|||
GlsDictionary::findHeadwordsForSynonym( wstring const & word )
|
||||
|
||||
{
|
||||
return synonymSearchEnabled ? new GlsHeadwordsRequest( word, *this ) :
|
||||
Class::findHeadwordsForSynonym( word );
|
||||
return synonymSearchEnabled ? std::make_shared<GlsHeadwordsRequest>( word, *this ) :
|
||||
Class::findHeadwordsForSynonym( word );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1161,7 +1161,7 @@ sptr< Dictionary::DataRequest > GlsDictionary::getArticle( wstring const & word,
|
|||
bool ignoreDiacritics )
|
||||
|
||||
{
|
||||
return new GlsArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<GlsArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
//////////////// GlsDictionary::getResource()
|
||||
|
@ -1355,7 +1355,7 @@ void GlsResourceRequest::run()
|
|||
sptr< Dictionary::DataRequest > GlsDictionary::getResource( string const & name )
|
||||
|
||||
{
|
||||
return new GlsResourceRequest( *this, name );
|
||||
return std::make_shared<GlsResourceRequest>( *this, name );
|
||||
}
|
||||
|
||||
sptr< Dictionary::DataRequest > GlsDictionary::getSearchResults( QString const & searchString,
|
||||
|
@ -1365,7 +1365,7 @@ sptr< Dictionary::DataRequest > GlsDictionary::getSearchResults( QString const &
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -1594,7 +1594,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
}
|
||||
|
||||
} // if need to rebuild
|
||||
dictionaries.push_back( new GlsDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<GlsDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles ) );
|
||||
}
|
||||
|
|
|
@ -835,7 +835,7 @@ sptr< Dictionary::Class > makeDictionary()
|
|||
{
|
||||
static GreekTable t;
|
||||
|
||||
return new Transliteration::TransliterationDictionary( "baa9e37a1aa69cdb5daca14a48ffe5ae",
|
||||
return std::make_shared<Transliteration::TransliterationDictionary>( "baa9e37a1aa69cdb5daca14a48ffe5ae",
|
||||
QCoreApplication::translate( "GreekTranslit", "Greek Transliteration" ).toUtf8().data(),
|
||||
QIcon( ":/flags/gr.png" ), t );
|
||||
}
|
||||
|
|
|
@ -339,7 +339,7 @@ sptr< DataRequest > HunspellDictionary::getArticle( wstring const & word,
|
|||
wstring const &, bool )
|
||||
|
||||
{
|
||||
return new HunspellArticleRequest( word, getHunspellMutex(), hunspell );
|
||||
return std::make_shared<HunspellArticleRequest>( word, getHunspellMutex(), hunspell );
|
||||
}
|
||||
|
||||
/// HunspellDictionary::findHeadwordsForSynonym()
|
||||
|
@ -513,7 +513,7 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu
|
|||
sptr< WordSearchRequest > HunspellDictionary::findHeadwordsForSynonym( wstring const & word )
|
||||
|
||||
{
|
||||
return new HunspellHeadwordsRequest( word, getHunspellMutex(), hunspell );
|
||||
return std::make_shared<HunspellHeadwordsRequest>( word, getHunspellMutex(), hunspell );
|
||||
}
|
||||
|
||||
|
||||
|
@ -628,7 +628,7 @@ sptr< WordSearchRequest > HunspellDictionary::prefixMatch( wstring const & word,
|
|||
unsigned long /*maxResults*/ )
|
||||
|
||||
{
|
||||
return new HunspellPrefixMatchRequest( word, getHunspellMutex(), hunspell );
|
||||
return std::make_shared<HunspellPrefixMatchRequest>( word, getHunspellMutex(), hunspell );
|
||||
}
|
||||
|
||||
void getSuggestionsForExpression( wstring const & expression,
|
||||
|
@ -787,7 +787,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::Hunspell const & c
|
|||
FsEncoding::encode( QDir::toNativeSeparators( dataFiles[ d ].dicFileName ) ) );
|
||||
|
||||
result.push_back(
|
||||
new HunspellDictionary( Dictionary::makeDictionaryId( dictFiles ),
|
||||
std::make_shared<HunspellDictionary>( Dictionary::makeDictionaryId( dictFiles ),
|
||||
dataFiles[ d ].dictName.toUtf8().data(),
|
||||
dictFiles ) );
|
||||
break;
|
||||
|
|
12
lsa.cc
12
lsa.cc
|
@ -266,7 +266,7 @@ sptr< Dictionary::DataRequest > LsaDictionary::getArticle( wstring const & word,
|
|||
}
|
||||
|
||||
if ( mainArticles.empty() && alternateArticles.empty() )
|
||||
return new Dictionary::DataRequestInstant( false ); // No such word
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false ); // No such word
|
||||
|
||||
string result;
|
||||
|
||||
|
@ -318,7 +318,7 @@ sptr< Dictionary::DataRequest > LsaDictionary::getArticle( wstring const & word,
|
|||
|
||||
memcpy( &(ret->getData().front()), result.data(), result.size() );
|
||||
|
||||
return ret;
|
||||
return std::shared_ptr<Dictionary::DataRequestInstant>(ret);
|
||||
}
|
||||
|
||||
/// This wraps around file operations
|
||||
|
@ -410,7 +410,7 @@ sptr< Dictionary::DataRequest > LsaDictionary::getResource( string const & name
|
|||
vector< WordArticleLink > chain = findArticles( Utf8::decode( strippedName ) );
|
||||
|
||||
if ( chain.empty() )
|
||||
return new Dictionary::DataRequestInstant( false ); // No such resource
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false ); // No such resource
|
||||
|
||||
File::Class f( getDictionaryFilenames()[ 0 ], "rb" );
|
||||
|
||||
|
@ -440,8 +440,8 @@ sptr< Dictionary::DataRequest > LsaDictionary::getResource( string const & name
|
|||
throw exFailedToRetrieveVorbisInfo();
|
||||
}
|
||||
|
||||
sptr< Dictionary::DataRequestInstant > dr = new
|
||||
Dictionary::DataRequestInstant( true );
|
||||
sptr< Dictionary::DataRequestInstant > dr = std::make_shared<
|
||||
Dictionary::DataRequestInstant>( true );
|
||||
|
||||
vector< char > & data = dr->getData();
|
||||
|
||||
|
@ -633,7 +633,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
idx.write( &idxHeader, sizeof( idxHeader ) );
|
||||
}
|
||||
|
||||
dictionaries.push_back( new LsaDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<LsaDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles ) );
|
||||
}
|
||||
|
|
|
@ -1170,7 +1170,7 @@ QPrinter & MainWindow::getPrinter()
|
|||
if ( printer.get() )
|
||||
return *printer;
|
||||
|
||||
printer = new QPrinter( QPrinter::HighResolution );
|
||||
printer = std::make_shared<QPrinter>( QPrinter::HighResolution );
|
||||
|
||||
return *printer;
|
||||
}
|
||||
|
@ -1527,7 +1527,7 @@ void MainWindow::makeScanPopup()
|
|||
{
|
||||
scanPopup.reset();
|
||||
|
||||
scanPopup = new ScanPopup( 0, cfg, articleNetMgr, audioPlayerFactory.player(),
|
||||
scanPopup = std::make_shared<ScanPopup>( nullptr, cfg, articleNetMgr, audioPlayerFactory.player(),
|
||||
dictionaries, groupInstances, history );
|
||||
|
||||
scanPopup->setStyleSheet( styleSheet() );
|
||||
|
@ -2995,7 +2995,7 @@ void MainWindow::installHotKeys()
|
|||
{
|
||||
try
|
||||
{
|
||||
hotkeyWrapper = new HotkeyWrapper( this );
|
||||
hotkeyWrapper = std::make_shared<HotkeyWrapper>( this );
|
||||
}
|
||||
catch( HotkeyWrapper::exInit & )
|
||||
{
|
||||
|
|
14
mdx.cc
14
mdx.cc
|
@ -453,7 +453,7 @@ void MdxDictionary::doDeferredInit()
|
|||
if ( fi.fileName() != mddFileName || !fi.exists() )
|
||||
continue;
|
||||
|
||||
sptr< IndexedMdd > mdd = new IndexedMdd( idxMutex, chunks );
|
||||
sptr< IndexedMdd > mdd = std::make_shared<IndexedMdd>( idxMutex, chunks );
|
||||
mdd->openIndex( mddIndexInfos[ i - 1 ], idx, idxMutex );
|
||||
mdd->open( dictFiles[ i ].c_str() );
|
||||
mddResources.push_back( mdd );
|
||||
|
@ -525,7 +525,7 @@ sptr< Dictionary::DataRequest > MdxDictionary::getSearchResults( QString const &
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
/// MdxDictionary::getArticle
|
||||
|
@ -686,7 +686,7 @@ void MdxArticleRequest::run()
|
|||
sptr<Dictionary::DataRequest> MdxDictionary::getArticle( const wstring & word, const vector<wstring> & alts,
|
||||
const wstring &, bool ignoreDiacritics )
|
||||
{
|
||||
return new MdxArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<MdxArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
/// MdxDictionary::getResource
|
||||
|
@ -868,7 +868,7 @@ void MddResourceRequest::run()
|
|||
|
||||
sptr<Dictionary::DataRequest> MdxDictionary::getResource( const string & name )
|
||||
{
|
||||
return new MddResourceRequest( *this, name );
|
||||
return std::make_shared<MddResourceRequest>( *this, name );
|
||||
}
|
||||
|
||||
const QString & MdxDictionary::getDescription()
|
||||
|
@ -1453,7 +1453,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
{
|
||||
if ( File::exists( *mddIter ) )
|
||||
{
|
||||
sptr< MdictParser > mddParser = new MdictParser();
|
||||
sptr< MdictParser > mddParser = std::make_shared<MdictParser>();
|
||||
if ( !mddParser->open( mddIter->c_str() ) )
|
||||
{
|
||||
gdWarning( "Broken mdd (resource) file: %s\n", mddIter->c_str() );
|
||||
|
@ -1514,7 +1514,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
while ( !mddParsers.empty() )
|
||||
{
|
||||
sptr< MdictParser > mddParser = mddParsers.front();
|
||||
sptr< IndexedWords > mddIndexedWords = new IndexedWords();
|
||||
sptr< IndexedWords > mddIndexedWords = std::make_shared<IndexedWords>();
|
||||
MdictParser::HeadWordIndex resourcesIndex;
|
||||
ResourceHandler resourceHandler( chunks, *mddIndexedWords );
|
||||
|
||||
|
@ -1610,7 +1610,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
idx.write( &idxHeader, sizeof( idxHeader ) );
|
||||
}
|
||||
|
||||
dictionaries.push_back( new MdxDictionary( dictId, indexFile, dictFiles ) );
|
||||
dictionaries.push_back( std::make_shared<MdxDictionary>( dictId, indexFile, dictFiles ) );
|
||||
}
|
||||
|
||||
return dictionaries;
|
||||
|
|
12
mediawiki.cc
12
mediawiki.cc
|
@ -130,7 +130,7 @@ MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str,
|
|||
|
||||
Utils::Url::addQueryItem( reqUrl, "apfrom", gd::toQString( str ).replace( '+', "%2B" ) );
|
||||
|
||||
netReply = mgr.get( QNetworkRequest( reqUrl ) );
|
||||
netReply = std::shared_ptr<QNetworkReply>(mgr.get( QNetworkRequest( reqUrl ) ));
|
||||
|
||||
connect( netReply.get(), SIGNAL( finished() ),
|
||||
this, SLOT( downloadFinished() ) );
|
||||
|
@ -534,10 +534,10 @@ sptr< WordSearchRequest > MediaWikiDictionary::prefixMatch( wstring const & word
|
|||
{
|
||||
// Don't make excessively large queries -- they're fruitless anyway
|
||||
|
||||
return new WordSearchRequestInstant();
|
||||
return std::make_shared<WordSearchRequestInstant>();
|
||||
}
|
||||
else
|
||||
return new MediaWikiWordSearchRequest( word, url, netMgr );
|
||||
return std::make_shared< MediaWikiWordSearchRequest>( word, url, netMgr );
|
||||
}
|
||||
|
||||
sptr< DataRequest > MediaWikiDictionary::getArticle( wstring const & word,
|
||||
|
@ -549,10 +549,10 @@ sptr< DataRequest > MediaWikiDictionary::getArticle( wstring const & word,
|
|||
{
|
||||
// Don't make excessively large queries -- they're fruitless anyway
|
||||
|
||||
return new DataRequestInstant( false );
|
||||
return std::make_shared<DataRequestInstant>( false );
|
||||
}
|
||||
else
|
||||
return new MediaWikiArticleRequest( word, alts, url, netMgr, this );
|
||||
return std::make_shared<MediaWikiArticleRequest>( word, alts, url, netMgr, this );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
for( int x = 0; x < wikis.size(); ++x )
|
||||
{
|
||||
if ( wikis[ x ].enabled )
|
||||
result.push_back( new MediaWikiDictionary( wikis[ x ].id.toStdString(),
|
||||
result.push_back( std::make_shared<MediaWikiDictionary>( wikis[ x ].id.toStdString(),
|
||||
wikis[ x ].name.toUtf8().data(),
|
||||
wikis[ x ].url,
|
||||
wikis[ x ].icon,
|
||||
|
|
12
programs.cc
12
programs.cc
|
@ -61,10 +61,10 @@ sptr< WordSearchRequest > ProgramsDictionary::prefixMatch( wstring const & word,
|
|||
|
||||
{
|
||||
if ( prg.type == Config::Program::PrefixMatch )
|
||||
return new ProgramWordSearchRequest( gd::toQString( word ), prg );
|
||||
return std::make_shared<ProgramWordSearchRequest>( gd::toQString( word ), prg );
|
||||
else
|
||||
{
|
||||
sptr< WordSearchRequestInstant > sr = new WordSearchRequestInstant;
|
||||
sptr< WordSearchRequestInstant > sr = std::make_shared<WordSearchRequestInstant>();
|
||||
|
||||
sr->setUncertain( true );
|
||||
|
||||
|
@ -101,7 +101,7 @@ sptr< Dictionary::DataRequest > ProgramsDictionary::getArticle(
|
|||
Html::escape( wordUtf8 ) + "</a></td>";
|
||||
result += "</tr></table>";
|
||||
|
||||
sptr< DataRequestInstant > ret = new DataRequestInstant( true );
|
||||
sptr< DataRequestInstant > ret = std::make_shared<DataRequestInstant>( true );
|
||||
|
||||
ret->getData().resize( result.size() );
|
||||
|
||||
|
@ -111,10 +111,10 @@ sptr< Dictionary::DataRequest > ProgramsDictionary::getArticle(
|
|||
|
||||
case Config::Program::Html:
|
||||
case Config::Program::PlainText:
|
||||
return new ProgramDataRequest( gd::toQString( word ), prg );
|
||||
return std::make_shared<ProgramDataRequest>( gd::toQString( word ), prg );
|
||||
|
||||
default:
|
||||
return new DataRequestInstant( false );
|
||||
return std::make_shared<DataRequestInstant>( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
for( Config::Programs::const_iterator i = programs.begin();
|
||||
i != programs.end(); ++i )
|
||||
if ( i->enabled )
|
||||
result.push_back( new ProgramsDictionary( *i ) );
|
||||
result.push_back( std::make_shared<ProgramsDictionary>( *i ) );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::Romaji const & r )
|
|||
{
|
||||
static HepburnHiragana t;
|
||||
|
||||
result.push_back( new Transliteration::TransliterationDictionary( "94eae5a5aaf5b0a900490f4d6b36aac0",
|
||||
result.push_back( std::make_shared<Transliteration::TransliterationDictionary>( "94eae5a5aaf5b0a900490f4d6b36aac0",
|
||||
QCoreApplication::translate( "Romaji", "Hepburn Romaji for Hiragana" ).toUtf8().data(),
|
||||
QIcon( ":/flags/jp.png" ), t, false ) );
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::Romaji const & r )
|
|||
{
|
||||
static HepburnKatakana t;
|
||||
|
||||
result.push_back( new Transliteration::TransliterationDictionary( "3252a35767d3f6e85e3e39069800dd2f",
|
||||
result.push_back( std::make_shared< Transliteration::TransliterationDictionary>( "3252a35767d3f6e85e3e39069800dd2f",
|
||||
QCoreApplication::translate( "Romaji", "Hepburn Romaji for Katakana" ).toUtf8().data(),
|
||||
QIcon( ":/flags/jp.png" ), t, false ) );
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ sptr< Dictionary::Class > makeDictionary()
|
|||
{
|
||||
static RussianTable t;
|
||||
|
||||
return new Transliteration::TransliterationDictionary( "cf1b74acd98adea9b2bba16af38f1086",
|
||||
return std::make_shared<Transliteration::TransliterationDictionary>( "cf1b74acd98adea9b2bba16af38f1086",
|
||||
QCoreApplication::translate( "RussianTranslit", "Russian Transliteration" ).toUtf8().data(),
|
||||
QIcon( ":/flags/ru.png" ), t );
|
||||
}
|
||||
|
|
6
sdict.cc
6
sdict.cc
|
@ -476,7 +476,7 @@ sptr< Dictionary::DataRequest > SdictDictionary::getSearchResults( QString const
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
/// SdictDictionary::getArticle()
|
||||
|
@ -669,7 +669,7 @@ sptr< Dictionary::DataRequest > SdictDictionary::getArticle( wstring const & wor
|
|||
bool ignoreDiacritics )
|
||||
|
||||
{
|
||||
return new SdictArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<SdictArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
QString const& SdictDictionary::getDescription()
|
||||
|
@ -890,7 +890,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
} // if need to rebuild
|
||||
try
|
||||
{
|
||||
dictionaries.push_back( new SdictDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<SdictDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles ) );
|
||||
}
|
||||
|
|
8
slob.cc
8
slob.cc
|
@ -1304,7 +1304,7 @@ sptr< Dictionary::DataRequest > SlobDictionary::getSearchResults( QString const
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString, searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString, searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1494,7 +1494,7 @@ sptr< Dictionary::DataRequest > SlobDictionary::getArticle( wstring const & word
|
|||
bool ignoreDiacritics )
|
||||
|
||||
{
|
||||
return new SlobArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<SlobArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
//// SlobDictionary::getResource()
|
||||
|
@ -1619,7 +1619,7 @@ void SlobResourceRequest::run()
|
|||
sptr< Dictionary::DataRequest > SlobDictionary::getResource( string const & name )
|
||||
|
||||
{
|
||||
return new SlobResourceRequest( *this, name );
|
||||
return std::make_shared<SlobResourceRequest>( *this, name );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1752,7 +1752,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
idx.write( &idxHeader, sizeof( idxHeader ) );
|
||||
|
||||
}
|
||||
dictionaries.push_back( new SlobDictionary( dictId,
|
||||
dictionaries.push_back(std::make_shared<SlobDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles ) );
|
||||
}
|
||||
|
|
16
sounddir.cc
16
sounddir.cc
|
@ -178,7 +178,7 @@ sptr< Dictionary::DataRequest > SoundDirDictionary::getArticle( wstring const &
|
|||
}
|
||||
|
||||
if ( mainArticles.empty() && alternateArticles.empty() )
|
||||
return new Dictionary::DataRequestInstant( false ); // No such word
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false ); // No such word
|
||||
|
||||
string result;
|
||||
|
||||
|
@ -286,7 +286,7 @@ sptr< Dictionary::DataRequest > SoundDirDictionary::getArticle( wstring const &
|
|||
|
||||
memcpy( &(ret->getData().front()), result.data(), result.size() );
|
||||
|
||||
return ret;
|
||||
return std::shared_ptr<Dictionary::DataRequestInstant>(ret);
|
||||
}
|
||||
|
||||
void SoundDirDictionary::loadIcon() noexcept
|
||||
|
@ -313,7 +313,7 @@ sptr< Dictionary::DataRequest > SoundDirDictionary::getResource( string const &
|
|||
uint32_t articleOffset = QString::fromUtf8( name.c_str() ).toULong( &isNumber );
|
||||
|
||||
if ( !isNumber )
|
||||
return new Dictionary::DataRequestInstant( false ); // No such resource
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false ); // No such resource
|
||||
|
||||
vector< char > chunk;
|
||||
char * articleData;
|
||||
|
@ -334,7 +334,7 @@ sptr< Dictionary::DataRequest > SoundDirDictionary::getResource( string const &
|
|||
catch( ChunkedStorage::exAddressOutOfRange & )
|
||||
{
|
||||
// Bad address
|
||||
return new Dictionary::DataRequestInstant( false ); // No such resource
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false ); // No such resource
|
||||
}
|
||||
|
||||
chunk.back() = 0; // It must end with 0 anyway, but just in case
|
||||
|
@ -349,8 +349,8 @@ sptr< Dictionary::DataRequest > SoundDirDictionary::getResource( string const &
|
|||
{
|
||||
File::Class f( FsEncoding::encode( fileName ), "rb" );
|
||||
|
||||
sptr< Dictionary::DataRequestInstant > dr = new
|
||||
Dictionary::DataRequestInstant( true );
|
||||
sptr< Dictionary::DataRequestInstant > dr =
|
||||
std::make_shared<Dictionary::DataRequestInstant>( true );
|
||||
|
||||
vector< char > & data = dr->getData();
|
||||
|
||||
|
@ -365,7 +365,7 @@ sptr< Dictionary::DataRequest > SoundDirDictionary::getResource( string const &
|
|||
}
|
||||
catch( File::Ex & )
|
||||
{
|
||||
return new Dictionary::DataRequestInstant( false ); // No such resource
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false ); // No such resource
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -481,7 +481,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::SoundDirs const &
|
|||
idx.write( &idxHeader, sizeof( idxHeader ) );
|
||||
}
|
||||
|
||||
dictionaries.push_back( new SoundDirDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<SoundDirDictionary>( dictId,
|
||||
i->name.toUtf8().data(),
|
||||
indexFile,
|
||||
dictFiles,
|
||||
|
|
149
sptr.hh
149
sptr.hh
|
@ -4,150 +4,9 @@
|
|||
#ifndef __SPTR_HH_INCLUDED__
|
||||
#define __SPTR_HH_INCLUDED__
|
||||
|
||||
// A generic non-intrusive smart-pointer template. We could use boost::, tr1::
|
||||
// or whatever, but since there's no standard solution yet, it isn't worth
|
||||
// the dependency given the simplicity of the template.
|
||||
|
||||
template< class T >
|
||||
class sptr_base
|
||||
{
|
||||
template< class TT > friend class sptr_base;
|
||||
|
||||
T * p;
|
||||
unsigned * count;
|
||||
|
||||
|
||||
void increment()
|
||||
{
|
||||
if ( count )
|
||||
++*count;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
sptr_base(): p( 0 ), count( 0 ) {}
|
||||
|
||||
sptr_base( T * p_ ): p( p_ ), count( p ? new unsigned( 1 ) : 0 )
|
||||
{
|
||||
}
|
||||
|
||||
sptr_base( sptr_base< T > const & other ): p( other.p ), count( other.count )
|
||||
{ increment(); }
|
||||
|
||||
// TT is meant to be a derivative of T
|
||||
template< class TT >
|
||||
sptr_base( sptr_base< TT > const & other ): p( ( T * ) other.p ),
|
||||
count( other.count )
|
||||
{ increment(); }
|
||||
|
||||
void reset()
|
||||
{
|
||||
if ( count )
|
||||
{
|
||||
if ( ! -- *count )
|
||||
{
|
||||
delete count;
|
||||
|
||||
count = 0;
|
||||
|
||||
if ( p )
|
||||
{
|
||||
T * p_ = p;
|
||||
|
||||
p = 0;
|
||||
|
||||
delete p_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p = 0;
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sptr_base & operator = ( sptr_base const & other )
|
||||
{ if ( &other != this ) { reset(); p = other.p; count = other.count; increment(); }
|
||||
return * this; }
|
||||
|
||||
bool operator ! ( void ) const
|
||||
{ return !p; }
|
||||
|
||||
bool operator == ( sptr_base const & other ) const
|
||||
{ return p == other.p; }
|
||||
|
||||
bool operator != ( sptr_base const & other ) const
|
||||
{ return p != other.p; }
|
||||
|
||||
~sptr_base()
|
||||
{ reset(); }
|
||||
|
||||
protected:
|
||||
|
||||
T * get_base( void ) const
|
||||
{ return p; }
|
||||
};
|
||||
|
||||
template< class T >
|
||||
class sptr: public sptr_base< T >
|
||||
{
|
||||
public:
|
||||
|
||||
sptr() {}
|
||||
|
||||
sptr( T * p ): sptr_base< T >( p ) {}
|
||||
|
||||
// TT is meant to be a derivative of T
|
||||
template< class TT >
|
||||
sptr( sptr< TT > const & other ): sptr_base< T >( other ) {}
|
||||
|
||||
// Retrieval
|
||||
T * get( void ) const
|
||||
{ return sptr_base< T > :: get_base(); }
|
||||
|
||||
T * operator -> ( void ) const
|
||||
{ return get(); }
|
||||
|
||||
T & operator * ( void ) const
|
||||
{ return * get(); }
|
||||
|
||||
// Check
|
||||
|
||||
operator bool( void ) const
|
||||
{ return get(); }
|
||||
|
||||
bool operator ! ( void ) const
|
||||
{ return !get(); }
|
||||
};
|
||||
|
||||
template< class T >
|
||||
class const_sptr: public sptr_base< T >
|
||||
{
|
||||
public:
|
||||
|
||||
const_sptr() {}
|
||||
|
||||
const_sptr( T * p_ ): sptr_base< T >( p_ ) {}
|
||||
|
||||
const_sptr( sptr< T > const & other ): sptr_base< T >( other ) {}
|
||||
|
||||
// TT is meant to be a derivative of T
|
||||
template< class TT >
|
||||
const_sptr( sptr_base< TT > const & other ): sptr_base< T >( other ) {}
|
||||
|
||||
// Retrieval
|
||||
|
||||
T const * get( void ) const
|
||||
{ return sptr_base< T > :: get_base(); }
|
||||
|
||||
T const * operator -> ( void ) const
|
||||
{ return get(); }
|
||||
|
||||
T const & operator * ( void ) const
|
||||
{ return * get(); }
|
||||
};
|
||||
|
||||
|
||||
#include <memory>
|
||||
// A shorthand for std::shared_ptr
|
||||
template <class T>
|
||||
using sptr = std::shared_ptr<T>;
|
||||
#endif
|
||||
|
||||
|
|
10
stardict.cc
10
stardict.cc
|
@ -1202,7 +1202,7 @@ sptr< Dictionary::DataRequest > StardictDictionary::getSearchResults( QString co
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
/// StardictDictionary::findHeadwordsForSynonym()
|
||||
|
@ -1319,7 +1319,7 @@ sptr< Dictionary::WordSearchRequest >
|
|||
StardictDictionary::findHeadwordsForSynonym( wstring const & word )
|
||||
|
||||
{
|
||||
return synonymSearchEnabled ? new StardictHeadwordsRequest( word, *this ) :
|
||||
return synonymSearchEnabled ? std::make_shared<StardictHeadwordsRequest>( word, *this ) :
|
||||
Class::findHeadwordsForSynonym( word );
|
||||
}
|
||||
|
||||
|
@ -1524,7 +1524,7 @@ sptr< Dictionary::DataRequest > StardictDictionary::getArticle( wstring const &
|
|||
bool ignoreDiacritics )
|
||||
|
||||
{
|
||||
return new StardictArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<StardictArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1806,7 +1806,7 @@ void StardictResourceRequest::run()
|
|||
sptr< Dictionary::DataRequest > StardictDictionary::getResource( string const & name )
|
||||
|
||||
{
|
||||
return new StardictResourceRequest( *this, name );
|
||||
return std::make_shared<StardictResourceRequest>( *this, name );
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -2178,7 +2178,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
idx.write( &idxHeader, sizeof( idxHeader ) );
|
||||
}
|
||||
|
||||
dictionaries.push_back( new StardictDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<StardictDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles ) );
|
||||
}
|
||||
|
|
|
@ -36,18 +36,18 @@ unsigned long BaseTransliterationDictionary::getWordCount() noexcept
|
|||
|
||||
sptr< Dictionary::WordSearchRequest > BaseTransliterationDictionary::prefixMatch( wstring const &,
|
||||
unsigned long )
|
||||
{ return new Dictionary::WordSearchRequestInstant(); }
|
||||
{ return std::make_shared<Dictionary::WordSearchRequestInstant>(); }
|
||||
|
||||
sptr< Dictionary::DataRequest > BaseTransliterationDictionary::getArticle( wstring const &,
|
||||
vector< wstring > const &,
|
||||
wstring const &, bool )
|
||||
|
||||
{ return new Dictionary::DataRequestInstant( false ); }
|
||||
{ return std::make_shared<Dictionary::DataRequestInstant>( false ); }
|
||||
|
||||
sptr< Dictionary::WordSearchRequest > BaseTransliterationDictionary::findHeadwordsForSynonym( wstring const & str )
|
||||
|
||||
{
|
||||
sptr< Dictionary::WordSearchRequestInstant > result = new Dictionary::WordSearchRequestInstant();
|
||||
sptr< Dictionary::WordSearchRequestInstant > result = std::make_shared<Dictionary::WordSearchRequestInstant>();
|
||||
|
||||
vector< wstring > alts = getAlternateWritings( str );
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ sptr< WordSearchRequest > VoiceEnginesDictionary::prefixMatch( wstring const & /
|
|||
{
|
||||
WordSearchRequestInstant * sr = new WordSearchRequestInstant();
|
||||
sr->setUncertain( true );
|
||||
return sr;
|
||||
return std::shared_ptr<WordSearchRequestInstant>(sr);
|
||||
}
|
||||
|
||||
sptr< Dictionary::DataRequest > VoiceEnginesDictionary::getArticle(
|
||||
|
@ -104,7 +104,7 @@ sptr< Dictionary::DataRequest > VoiceEnginesDictionary::getArticle(
|
|||
result += "<td><a href=" + ref + ">" + Html::escape( wordUtf8 ) + "</a></td>";
|
||||
result += "</tr></table>";
|
||||
|
||||
sptr< DataRequestInstant > ret = new DataRequestInstant( true );
|
||||
sptr< DataRequestInstant > ret = std::make_shared<DataRequestInstant>( true );
|
||||
ret->getData().resize( result.size() );
|
||||
memcpy( &( ret->getData().front() ), result.data(), result.size() );
|
||||
return ret;
|
||||
|
@ -135,7 +135,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
for ( Config::VoiceEngines::const_iterator i = voiceEngines.begin(); i != voiceEngines.end(); ++i )
|
||||
{
|
||||
if ( i->enabled )
|
||||
result.push_back( new VoiceEnginesDictionary( *i ) );
|
||||
result.push_back( std::make_shared<VoiceEnginesDictionary>( *i ) );
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
10
website.cc
10
website.cc
|
@ -86,7 +86,7 @@ protected:
|
|||
sptr< WordSearchRequest > WebSiteDictionary::prefixMatch( wstring const & /*word*/,
|
||||
unsigned long )
|
||||
{
|
||||
sptr< WordSearchRequestInstant > sr = new WordSearchRequestInstant;
|
||||
sptr< WordSearchRequestInstant > sr = std::make_shared<WordSearchRequestInstant>();
|
||||
|
||||
sr->setUncertain( true );
|
||||
|
||||
|
@ -378,7 +378,7 @@ sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str,
|
|||
{
|
||||
// Just insert link in <iframe> tag
|
||||
|
||||
sptr< DataRequestInstant > dr = new DataRequestInstant( true );
|
||||
sptr< DataRequestInstant > dr = std::make_shared<DataRequestInstant>( true );
|
||||
|
||||
string result = "<div class=\"website_padding\"></div>";
|
||||
|
||||
|
@ -412,7 +412,7 @@ sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str,
|
|||
|
||||
// To load data from site
|
||||
|
||||
return new WebSiteArticleRequest( urlString, netMgr, this );
|
||||
return std::make_shared<WebSiteArticleRequest>( urlString, netMgr, this );
|
||||
}
|
||||
|
||||
class WebSiteResourceRequest: public WebSiteDataRequestSlots
|
||||
|
@ -523,7 +523,7 @@ sptr< Dictionary::DataRequest > WebSiteDictionary::getResource( string const & n
|
|||
int pos = link.indexOf( '/' );
|
||||
if( pos > 0 )
|
||||
link.replace( pos, 1, "://" );
|
||||
return new WebSiteResourceRequest( link, netMgr, this );
|
||||
return std::make_shared<WebSiteResourceRequest>( link, netMgr, this );
|
||||
}
|
||||
|
||||
void WebSiteDictionary::loadIcon() noexcept
|
||||
|
@ -553,7 +553,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::WebSites const & w
|
|||
for( int x = 0; x < ws.size(); ++x )
|
||||
{
|
||||
if ( ws[ x ].enabled )
|
||||
result.push_back( new WebSiteDictionary( ws[ x ].id.toUtf8().data(),
|
||||
result.push_back( std::make_shared<WebSiteDictionary>( ws[ x ].id.toUtf8().data(),
|
||||
ws[ x ].name.toUtf8().data(),
|
||||
ws[ x ].url,
|
||||
ws[ x ].iconFilename,
|
||||
|
|
10
xdxf.cc
10
xdxf.cc
|
@ -221,7 +221,7 @@ XdxfDictionary::XdxfDictionary( string const & id,
|
|||
{
|
||||
// Read the dictionary name
|
||||
|
||||
chunks = new ChunkedStorage::Reader( idx, idxHeader.chunksOffset );
|
||||
chunks = std::shared_ptr<ChunkedStorage::Reader>(new ChunkedStorage::Reader(idx, idxHeader.chunksOffset ));
|
||||
|
||||
if ( idxHeader.nameSize )
|
||||
{
|
||||
|
@ -430,7 +430,7 @@ sptr< Dictionary::DataRequest > XdxfDictionary::getSearchResults( QString const
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
/// XdxfDictionary::getArticle()
|
||||
|
@ -626,7 +626,7 @@ sptr< Dictionary::DataRequest > XdxfDictionary::getArticle( wstring const & word
|
|||
bool ignoreDiacritics )
|
||||
|
||||
{
|
||||
return new XdxfArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<XdxfArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
void XdxfDictionary::loadArticle( uint32_t address,
|
||||
|
@ -1112,7 +1112,7 @@ void XdxfResourceRequest::run()
|
|||
sptr< Dictionary::DataRequest > XdxfDictionary::getResource( string const & name )
|
||||
|
||||
{
|
||||
return new XdxfResourceRequest( *this, name );
|
||||
return std::make_shared<XdxfResourceRequest>( *this, name );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1452,7 +1452,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
}
|
||||
}
|
||||
|
||||
dictionaries.push_back( new XdxfDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<XdxfDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles ) );
|
||||
}
|
||||
|
|
8
zim.cc
8
zim.cc
|
@ -1251,7 +1251,7 @@ sptr< Dictionary::DataRequest > ZimDictionary::getSearchResults( QString const &
|
|||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return std::make_shared<FtsHelpers::FTSResultsRequest>( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
}
|
||||
|
||||
/// ZimDictionary::getArticle()
|
||||
|
@ -1428,7 +1428,7 @@ sptr< Dictionary::DataRequest > ZimDictionary::getArticle( wstring const & word,
|
|||
bool ignoreDiacritics )
|
||||
|
||||
{
|
||||
return new ZimArticleRequest( word, alts, *this, ignoreDiacritics );
|
||||
return std::make_shared<ZimArticleRequest>( word, alts, *this, ignoreDiacritics );
|
||||
}
|
||||
|
||||
//// ZimDictionary::getResource()
|
||||
|
@ -1521,7 +1521,7 @@ void ZimResourceRequest::run()
|
|||
sptr< Dictionary::DataRequest > ZimDictionary::getResource( string const & name )
|
||||
{
|
||||
auto formatedName = QString::fromStdString(name).remove(QRegularExpression("^\\.*\\/[A-Z]\\/", QRegularExpression::CaseInsensitiveOption));
|
||||
return new ZimResourceRequest( *this, formatedName.toStdString() );
|
||||
return std::make_shared<ZimResourceRequest>( *this, formatedName.toStdString() );
|
||||
}
|
||||
|
||||
//} // anonymous namespace
|
||||
|
@ -1768,7 +1768,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
idx.write( &idxHeader, sizeof( idxHeader ) );
|
||||
}
|
||||
|
||||
dictionaries.push_back( new ZimDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<ZimDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles ) );
|
||||
}
|
||||
|
|
16
zipsounds.cc
16
zipsounds.cc
|
@ -146,7 +146,7 @@ ZipSoundsDictionary::ZipSoundsDictionary( string const & id,
|
|||
idx( indexFile, "rb" ),
|
||||
idxHeader( idx.read< IdxHeader >() )
|
||||
{
|
||||
chunks = new ChunkedStorage::Reader( idx, idxHeader.chunksOffset );
|
||||
chunks = std::shared_ptr<ChunkedStorage::Reader>(new ChunkedStorage::Reader( idx, idxHeader.chunksOffset ));
|
||||
|
||||
// Initialize the index
|
||||
|
||||
|
@ -227,7 +227,7 @@ sptr< Dictionary::DataRequest > ZipSoundsDictionary::getArticle( wstring const &
|
|||
}
|
||||
|
||||
if ( mainArticles.empty() && alternateArticles.empty() )
|
||||
return new Dictionary::DataRequestInstant( false ); // No such word
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false ); // No such word
|
||||
|
||||
string result;
|
||||
|
||||
|
@ -339,7 +339,7 @@ sptr< Dictionary::DataRequest > ZipSoundsDictionary::getArticle( wstring const &
|
|||
|
||||
memcpy( &(ret->getData().front()), result.data(), result.size() );
|
||||
|
||||
return ret;
|
||||
return std::shared_ptr<Dictionary::DataRequestInstant>(ret);
|
||||
}
|
||||
|
||||
sptr< Dictionary::DataRequest > ZipSoundsDictionary::getResource( string const & name )
|
||||
|
@ -352,7 +352,7 @@ sptr< Dictionary::DataRequest > ZipSoundsDictionary::getResource( string const &
|
|||
vector< WordArticleLink > chain = findArticles( strippedName );
|
||||
|
||||
if ( chain.empty() )
|
||||
return new Dictionary::DataRequestInstant( false ); // No such resource
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false ); // No such resource
|
||||
|
||||
// Find sound
|
||||
|
||||
|
@ -375,13 +375,13 @@ sptr< Dictionary::DataRequest > ZipSoundsDictionary::getResource( string const &
|
|||
break;
|
||||
}
|
||||
|
||||
sptr< Dictionary::DataRequestInstant > dr = new
|
||||
Dictionary::DataRequestInstant( true );
|
||||
sptr< Dictionary::DataRequestInstant > dr =
|
||||
std::make_shared<Dictionary::DataRequestInstant>( true );
|
||||
|
||||
if ( zipsFile.loadFile( dataOffset, dr->getData() ) )
|
||||
return dr;
|
||||
|
||||
return new Dictionary::DataRequestInstant( false );
|
||||
return std::make_shared<Dictionary::DataRequestInstant>( false );
|
||||
}
|
||||
|
||||
void ZipSoundsDictionary::loadIcon() noexcept
|
||||
|
@ -506,7 +506,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
}
|
||||
}
|
||||
|
||||
dictionaries.push_back( new ZipSoundsDictionary( dictId,
|
||||
dictionaries.push_back( std::make_shared<ZipSoundsDictionary>( dictId,
|
||||
indexFile,
|
||||
dictFiles ) );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue