mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Compare commits
1 commit
8c9d84f5db
...
95b57a1a3c
Author | SHA1 | Date | |
---|---|---|---|
95b57a1a3c |
|
@ -4,6 +4,9 @@
|
|||
#include <QStyle>
|
||||
#include <QMessageBox>
|
||||
#include <string>
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
#include <QBuffer>
|
||||
#include <QTextCodec>
|
||||
|
||||
|
@ -28,10 +31,10 @@ std::string c_string( const QString & str )
|
|||
return std::string( str.toUtf8().constData() );
|
||||
}
|
||||
|
||||
bool endsWithIgnoreCase( QByteArrayView str, QByteArrayView extension )
|
||||
bool endsWithIgnoreCase( const string & str1, string str2 )
|
||||
{
|
||||
return ( str.size() >= extension.size() )
|
||||
&& ( str.last( extension.size() ).compare( extension, Qt::CaseInsensitive ) == 0 );
|
||||
return ( str1.size() >= (unsigned)str2.size() )
|
||||
&& ( strcasecmp( str1.c_str() + ( str1.size() - str2.size() ), str2.data() ) == 0 );
|
||||
}
|
||||
|
||||
QString escapeAmps( QString const & str )
|
||||
|
|
|
@ -40,7 +40,7 @@ inline QString rstrip( const QString & str )
|
|||
}
|
||||
|
||||
std::string c_string( const QString & str );
|
||||
bool endsWithIgnoreCase( QByteArrayView str, QByteArrayView extension );
|
||||
bool endsWithIgnoreCase( const string & str1, string str2 );
|
||||
/**
|
||||
* remove punctuation , space, symbol
|
||||
*
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include <QString>
|
||||
#include <QSemaphore>
|
||||
|
@ -292,7 +295,11 @@ AardDictionary::AardDictionary( string const & id, string const & indexFile, vec
|
|||
// Read dictionary name
|
||||
|
||||
idx.seek( sizeof( idxHeader ) );
|
||||
idx.readU32SizeAndData<>( dictionaryName );
|
||||
vector< char > dName( idx.read< quint32 >() );
|
||||
if ( dName.size() ) {
|
||||
idx.read( &dName.front(), dName.size() );
|
||||
dictionaryName = string( &dName.front(), dName.size() );
|
||||
}
|
||||
|
||||
// Initialize the index
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
#include <string.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include <QAtomicInt>
|
||||
#include <QPainter>
|
||||
|
@ -255,7 +258,15 @@ BglDictionary::BglDictionary( string const & id, string const & indexFile, strin
|
|||
|
||||
// Read the dictionary's name
|
||||
|
||||
idx.readU32SizeAndData<>( dictionaryName );
|
||||
size_t len = idx.read< uint32_t >();
|
||||
|
||||
if ( len ) {
|
||||
vector< char > nameBuf( len );
|
||||
|
||||
idx.read( &nameBuf.front(), len );
|
||||
|
||||
dictionaryName = string( &nameBuf.front(), len );
|
||||
}
|
||||
|
||||
// Initialize the index
|
||||
|
||||
|
@ -888,8 +899,8 @@ void BglResourceRequest::run()
|
|||
break;
|
||||
}
|
||||
|
||||
vector< char > nameData;
|
||||
idx.readU32SizeAndData<>( nameData );
|
||||
vector< char > nameData( idx.read< uint32_t >() );
|
||||
idx.read( &nameData.front(), nameData.size() );
|
||||
|
||||
for ( size_t x = nameData.size(); x--; ) {
|
||||
nameData[ x ] = tolower( nameData[ x ] );
|
||||
|
@ -906,9 +917,9 @@ void BglResourceRequest::run()
|
|||
|
||||
data.resize( idx.read< uint32_t >() );
|
||||
|
||||
vector< unsigned char > compressedData;
|
||||
vector< unsigned char > compressedData( idx.read< uint32_t >() );
|
||||
|
||||
idx.readU32SizeAndData<>( compressedData );
|
||||
idx.read( &compressedData.front(), compressedData.size() );
|
||||
|
||||
unsigned long decompressedLength = data.size();
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
|
||||
#include <QRegularExpression>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
namespace DictdFiles {
|
||||
|
||||
using std::map;
|
||||
|
@ -92,6 +96,11 @@ public:
|
|||
|
||||
~DictdDictionary();
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return dictionaryName;
|
||||
}
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
return map< Dictionary::Property, string >();
|
||||
|
@ -154,7 +163,11 @@ DictdDictionary::DictdDictionary( string const & id,
|
|||
// Read the dictionary name
|
||||
idx.seek( sizeof( idxHeader ) );
|
||||
|
||||
idx.readU32SizeAndData<>( dictionaryName );
|
||||
vector< char > dName( idx.read< uint32_t >() );
|
||||
if ( dName.size() > 0 ) {
|
||||
idx.read( &dName.front(), dName.size() );
|
||||
dictionaryName = string( &dName.front(), dName.size() );
|
||||
}
|
||||
|
||||
// Open the .dict file
|
||||
|
||||
|
|
|
@ -176,6 +176,7 @@ class DictServerDictionary: public Dictionary::Class
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
string name;
|
||||
QString url, icon;
|
||||
quint32 langId;
|
||||
QString errorString;
|
||||
|
@ -195,13 +196,11 @@ public:
|
|||
QString const & strategies_,
|
||||
QString const & icon_ ):
|
||||
Dictionary::Class( id, vector< string >() ),
|
||||
name( name_ ),
|
||||
url( url_ ),
|
||||
icon( icon_ ),
|
||||
langId( 0 )
|
||||
{
|
||||
|
||||
dictionaryName = name_;
|
||||
|
||||
int pos = url.indexOf( "://" );
|
||||
if ( pos < 0 ) {
|
||||
url = "dict://" + url;
|
||||
|
@ -302,6 +301,11 @@ public:
|
|||
disconnectFromServer( socket );
|
||||
}
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
map< Property, string > getProperties() noexcept override
|
||||
{
|
||||
return {};
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#include <list>
|
||||
#include <wctype.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include <QSemaphore>
|
||||
#include <QThreadPool>
|
||||
#include <QAtomicInt>
|
||||
|
@ -172,6 +176,10 @@ public:
|
|||
|
||||
~DslDictionary();
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return dictionaryName;
|
||||
}
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
@ -295,9 +303,17 @@ DslDictionary::DslDictionary( string const & id, string const & indexFile, vecto
|
|||
|
||||
idx.seek( sizeof( idxHeader ) );
|
||||
|
||||
idx.readU32SizeAndData<>( dictionaryName );
|
||||
idx.readU32SizeAndData<>( preferredSoundDictionary );
|
||||
vector< char > dName( idx.read< uint32_t >() );
|
||||
if ( dName.size() > 0 ) {
|
||||
idx.read( &dName.front(), dName.size() );
|
||||
dictionaryName = string( &dName.front(), dName.size() );
|
||||
}
|
||||
|
||||
vector< char > sName( idx.read< uint32_t >() );
|
||||
if ( sName.size() > 0 ) {
|
||||
idx.read( &sName.front(), sName.size() );
|
||||
preferredSoundDictionary = string( &sName.front(), sName.size() );
|
||||
}
|
||||
|
||||
resourceDir1 = getDictionaryFilenames()[ 0 ] + ".files" + Utils::Fs::separator();
|
||||
QString s = QString::fromStdString( getDictionaryFilenames()[ 0 ] );
|
||||
|
@ -1729,10 +1745,11 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
continue;
|
||||
}
|
||||
|
||||
// Make sure it's not an abbreviation file. extSize of ".dsl" or ".dsl.dz"
|
||||
// Make sure it's not an abbreviation file
|
||||
|
||||
if ( int extSize = ( uncompressedDsl ? 4 : 7 ); ( fileName.size() >= ( 5 + extSize ) )
|
||||
&& ( QByteArrayView( fileName ).chopped( extSize ).last( 5 ).compare( "_abrv", Qt::CaseInsensitive ) == 0 ) ) {
|
||||
int extSize = ( uncompressedDsl ? 4 : 7 );
|
||||
if ( fileName.size() - extSize >= 5
|
||||
&& strncasecmp( fileName.c_str() + fileName.size() - extSize - 5, "_abrv", 5 ) == 0 ) {
|
||||
// It is, skip it
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ class EpwingDictionary: public BtreeIndexing::BtreeDictionary
|
|||
QMutex idxMutex;
|
||||
File::Index idx;
|
||||
IdxHeader idxHeader;
|
||||
string bookName;
|
||||
ChunkedStorage::Reader chunks;
|
||||
Epwing::Book::EpwingBook eBook;
|
||||
QString cacheDirectory;
|
||||
|
@ -95,6 +96,15 @@ public:
|
|||
|
||||
~EpwingDictionary();
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return bookName;
|
||||
}
|
||||
|
||||
void setName( string _name ) noexcept override
|
||||
{
|
||||
bookName = _name;
|
||||
}
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
@ -217,7 +227,7 @@ EpwingDictionary::EpwingDictionary( string const & id,
|
|||
idx.seek( sizeof( idxHeader ) );
|
||||
if ( data.size() > 0 ) {
|
||||
idx.read( &data.front(), idxHeader.nameSize );
|
||||
dictionaryName = string( &data.front(), idxHeader.nameSize );
|
||||
bookName = string( &data.front(), idxHeader.nameSize );
|
||||
}
|
||||
|
||||
// Initialize eBook
|
||||
|
|
|
@ -18,12 +18,8 @@
|
|||
#include <QString>
|
||||
#include <QtCore5Compat/QTextCodec>
|
||||
|
||||
// POSIX symbol unavailable on Windows needed for eb headers
|
||||
#ifdef Q_OS_WIN
|
||||
#ifndef _SSIZE_T
|
||||
#define _SSIZE_T
|
||||
#define ssize_t long
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include <eb/eb.h>
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace {
|
|||
|
||||
class ForvoDictionary: public Dictionary::Class
|
||||
{
|
||||
string name;
|
||||
QString apiKey, languageCode;
|
||||
QNetworkAccessManager & netMgr;
|
||||
|
||||
|
@ -31,13 +32,17 @@ public:
|
|||
QString const & languageCode_,
|
||||
QNetworkAccessManager & netMgr_ ):
|
||||
Dictionary::Class( id, vector< string >() ),
|
||||
name( name_ ),
|
||||
apiKey( apiKey_ ),
|
||||
languageCode( languageCode_ ),
|
||||
netMgr( netMgr_ )
|
||||
{
|
||||
dictionaryName = name_;
|
||||
}
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
map< Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
namespace Gls {
|
||||
|
||||
|
@ -358,6 +361,11 @@ public:
|
|||
|
||||
~GlsDictionary();
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return dictionaryName;
|
||||
}
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
return map< Dictionary::Property, string >();
|
||||
|
@ -453,7 +461,11 @@ GlsDictionary::GlsDictionary( string const & id, string const & indexFile, vecto
|
|||
|
||||
idx.seek( sizeof( idxHeader ) );
|
||||
|
||||
idx.readU32SizeAndData<>( dictionaryName );
|
||||
vector< char > dName( idx.read< uint32_t >() );
|
||||
if ( dName.size() > 0 ) {
|
||||
idx.read( &dName.front(), dName.size() );
|
||||
dictionaryName = string( &dName.front(), dName.size() );
|
||||
}
|
||||
|
||||
// Initialize the index
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace {
|
|||
|
||||
class HunspellDictionary: public Dictionary::Class
|
||||
{
|
||||
string name;
|
||||
Hunspell hunspell;
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
@ -55,15 +56,19 @@ public:
|
|||
/// files[ 0 ] should be .aff file, files[ 1 ] should be .dic file.
|
||||
HunspellDictionary( string const & id, string const & name_, vector< string > const & files ):
|
||||
Dictionary::Class( id, files ),
|
||||
name( name_ ),
|
||||
#ifdef Q_OS_WIN32
|
||||
hunspell( Utf8ToLocal8Bit( files[ 0 ] ).c_str(), Utf8ToLocal8Bit( files[ 1 ] ).c_str() )
|
||||
#else
|
||||
hunspell( files[ 0 ].c_str(), files[ 1 ].c_str() )
|
||||
#endif
|
||||
{
|
||||
dictionaryName = name_;
|
||||
}
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
map< Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
|
|
@ -60,6 +60,7 @@ private slots:
|
|||
class LinguaDictionary: public Dictionary::Class
|
||||
{
|
||||
|
||||
string name;
|
||||
QString languageCode;
|
||||
QString langWikipediaID;
|
||||
QNetworkAccessManager & netMgr;
|
||||
|
@ -67,10 +68,10 @@ class LinguaDictionary: public Dictionary::Class
|
|||
public:
|
||||
LinguaDictionary( string const & id, string name_, QString languageCode_, QNetworkAccessManager & netMgr_ ):
|
||||
Dictionary::Class( id, vector< string >() ),
|
||||
name( std::move( name_ ) ),
|
||||
languageCode( std::move( languageCode_ ) ),
|
||||
netMgr( netMgr_ )
|
||||
{
|
||||
dictionaryName = name_;
|
||||
/* map of iso lang code to wikipedia lang id
|
||||
|
||||
Data was obtained by this query on https://commons-query.wikimedia.org/
|
||||
|
@ -165,6 +166,10 @@ WHERE {
|
|||
}
|
||||
}
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
map< Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#define OV_EXCLUDE_STATIC_CALLBACKS
|
||||
#include <vorbis/vorbisfile.h>
|
||||
#include <QDir>
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
#include <map>
|
||||
#include <set>
|
||||
#include <list>
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include "globalregex.hh"
|
||||
#include "tiff.hh"
|
||||
|
@ -215,6 +218,10 @@ public:
|
|||
|
||||
void deferredInit() override;
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return dictionaryName;
|
||||
}
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
@ -303,7 +310,12 @@ MdxDictionary::MdxDictionary( string const & id, string const & indexFile, vecto
|
|||
{
|
||||
// Read the dictionary's name
|
||||
idx.seek( sizeof( idxHeader ) );
|
||||
idx.readU32SizeAndData<>( dictionaryName );
|
||||
size_t len = idx.read< uint32_t >();
|
||||
vector< char > buf( len );
|
||||
if ( len > 0 ) {
|
||||
idx.read( &buf.front(), len );
|
||||
dictionaryName = string( &buf.front(), len );
|
||||
}
|
||||
|
||||
//fallback, use filename as dictionary name
|
||||
if ( dictionaryName.empty() ) {
|
||||
|
@ -312,7 +324,12 @@ MdxDictionary::MdxDictionary( string const & id, string const & indexFile, vecto
|
|||
}
|
||||
|
||||
// then read the dictionary's encoding
|
||||
idx.readU32SizeAndData<>( encoding );
|
||||
len = idx.read< uint32_t >();
|
||||
if ( len > 0 ) {
|
||||
buf.resize( len );
|
||||
idx.read( &buf.front(), len );
|
||||
encoding = string( &buf.front(), len );
|
||||
}
|
||||
|
||||
dictFile.setFileName( QString::fromUtf8( dictionaryFiles[ 0 ].c_str() ) );
|
||||
dictFile.open( QIODevice::ReadOnly );
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "utils.hh"
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
namespace Sdict {
|
||||
|
||||
|
@ -113,6 +119,10 @@ public:
|
|||
|
||||
~SdictDictionary();
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return dictionaryName;
|
||||
}
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
@ -186,7 +196,11 @@ SdictDictionary::SdictDictionary( string const & id,
|
|||
// Read dictionary name
|
||||
|
||||
idx.seek( sizeof( idxHeader ) );
|
||||
idx.readU32SizeAndData<>( dictionaryName );
|
||||
vector< char > dName( idx.read< uint32_t >() );
|
||||
if ( dName.size() > 0 ) {
|
||||
idx.read( &dName.front(), dName.size() );
|
||||
dictionaryName = string( &dName.front(), dName.size() );
|
||||
}
|
||||
|
||||
// Initialize the index
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
#include "tiff.hh"
|
||||
#include "utils.hh"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include "iconv.hh"
|
||||
|
||||
#include <QString>
|
||||
|
@ -614,6 +618,10 @@ public:
|
|||
|
||||
~SlobDictionary();
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return dictionaryName;
|
||||
}
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
|
|
@ -61,6 +61,7 @@ bool indexIsOldOrBad( string const & indexFile )
|
|||
|
||||
class SoundDirDictionary: public BtreeIndexing::BtreeDictionary
|
||||
{
|
||||
string name;
|
||||
QMutex idxMutex;
|
||||
File::Index idx;
|
||||
IdxHeader idxHeader;
|
||||
|
@ -75,6 +76,10 @@ public:
|
|||
vector< string > const & dictionaryFiles,
|
||||
QString const & iconFilename_ );
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
@ -108,13 +113,12 @@ SoundDirDictionary::SoundDirDictionary( string const & id,
|
|||
vector< string > const & dictionaryFiles,
|
||||
QString const & iconFilename_ ):
|
||||
BtreeDictionary( id, dictionaryFiles ),
|
||||
name( name_ ),
|
||||
idx( indexFile, QIODevice::ReadOnly ),
|
||||
idxHeader( idx.read< IdxHeader >() ),
|
||||
chunks( idx, idxHeader.chunksOffset ),
|
||||
iconFilename( iconFilename_ )
|
||||
{
|
||||
dictionaryName = name_;
|
||||
|
||||
// Initialize the index
|
||||
|
||||
openIndex( IndexInfo( idxHeader.indexBtreeMaxElements, idxHeader.indexRootOffset ), idx, idxMutex );
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include <QString>
|
||||
#include <QSemaphore>
|
||||
|
@ -128,6 +131,7 @@ class StardictDictionary: public BtreeIndexing::BtreeDictionary
|
|||
QMutex idxMutex;
|
||||
File::Index idx;
|
||||
IdxHeader idxHeader;
|
||||
string bookName;
|
||||
string sameTypeSequence;
|
||||
ChunkedStorage::Reader chunks;
|
||||
QMutex dzMutex;
|
||||
|
@ -141,6 +145,17 @@ public:
|
|||
|
||||
~StardictDictionary();
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return bookName;
|
||||
}
|
||||
|
||||
void setName( string _name ) noexcept override
|
||||
{
|
||||
bookName = _name;
|
||||
}
|
||||
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
return map< Dictionary::Property, string >();
|
||||
|
@ -224,10 +239,10 @@ StardictDictionary::StardictDictionary( string const & id,
|
|||
BtreeDictionary( id, dictionaryFiles ),
|
||||
idx( indexFile, QIODevice::ReadOnly ),
|
||||
idxHeader( idx.read< IdxHeader >() ),
|
||||
bookName( loadString( idxHeader.bookNameSize ) ),
|
||||
sameTypeSequence( loadString( idxHeader.sameTypeSequenceSize ) ),
|
||||
chunks( idx, idxHeader.chunksOffset )
|
||||
{
|
||||
dictionaryName = loadString( idxHeader.bookNameSize );
|
||||
// Open the .dict file
|
||||
|
||||
DZ_ERRORS error;
|
||||
|
|
|
@ -81,18 +81,6 @@ public:
|
|||
/// Like the above, but uses its own local internal buffer and strips newlines by default.
|
||||
std::string gets( bool stripNl = true );
|
||||
|
||||
/// Read 32bit as uint, then reading the subsequent data into a container
|
||||
template< typename T >
|
||||
void readU32SizeAndData( T & container )
|
||||
{
|
||||
uint32_t size = 0;
|
||||
read( &size, sizeof( uint32_t ) );
|
||||
if ( size > 0 ) {
|
||||
container.resize( size );
|
||||
read( container.data(), size );
|
||||
}
|
||||
};
|
||||
|
||||
/// export QFile::readall
|
||||
QByteArray readall();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace {
|
|||
|
||||
class WebSiteDictionary: public Dictionary::Class
|
||||
{
|
||||
string name;
|
||||
QByteArray urlTemplate;
|
||||
bool experimentalIframe;
|
||||
QString iconFilename;
|
||||
|
@ -37,13 +38,12 @@ public:
|
|||
bool inside_iframe_,
|
||||
QNetworkAccessManager & netMgr_ ):
|
||||
Dictionary::Class( id, vector< string >() ),
|
||||
name( name_ ),
|
||||
iconFilename( iconFilename_ ),
|
||||
inside_iframe( inside_iframe_ ),
|
||||
netMgr( netMgr_ ),
|
||||
experimentalIframe( false )
|
||||
{
|
||||
dictionaryName = name_;
|
||||
|
||||
if ( urlTemplate_.startsWith( "http://" ) || urlTemplate_.startsWith( "https://" ) ) {
|
||||
experimentalIframe = true;
|
||||
}
|
||||
|
@ -53,6 +53,10 @@ public:
|
|||
dictionaryDescription = urlTemplate_;
|
||||
}
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
map< Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
@ -474,8 +478,7 @@ void WebSiteDictionary::loadIcon() noexcept
|
|||
loadIconFromFile( fInfo.absoluteFilePath(), true );
|
||||
}
|
||||
}
|
||||
if ( dictionaryIcon.isNull()
|
||||
&& !loadIconFromText( ":/icons/webdict.svg", QString::fromStdString( dictionaryName ) ) ) {
|
||||
if ( dictionaryIcon.isNull() && !loadIconFromText( ":/icons/webdict.svg", QString::fromStdString( name ) ) ) {
|
||||
dictionaryIcon = QIcon( ":/icons/webdict.svg" );
|
||||
}
|
||||
dictionaryIconLoaded = true;
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#include "tiff.hh"
|
||||
#include "ftshelpers.hh"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include <QIODevice>
|
||||
#include <QXmlStreamReader>
|
||||
|
@ -149,6 +152,10 @@ public:
|
|||
|
||||
~XdxfDictionary();
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return dictionaryName;
|
||||
}
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
#include "ftshelpers.hh"
|
||||
#include "htmlescape.hh"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
|
@ -164,6 +168,10 @@ public:
|
|||
|
||||
~ZimDictionary() = default;
|
||||
|
||||
string getName() noexcept override
|
||||
{
|
||||
return dictionaryName;
|
||||
}
|
||||
|
||||
map< Dictionary::Property, string > getProperties() noexcept override
|
||||
{
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include "utils.hh"
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
#include <QLocale>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
// Language codes
|
||||
|
||||
QMap< QString, GDLangCode > LangCoder::LANG_CODE_MAP = {
|
||||
|
@ -228,10 +231,10 @@ QString LangCoder::intToCode2( quint32 val )
|
|||
|
||||
quint32 LangCoder::findIdForLanguage( gd::wstring const & lang )
|
||||
{
|
||||
const auto langFolded = QByteArrayView( Utf8::encode( lang ) );
|
||||
const auto langFolded = Utf8::encode( lang );
|
||||
|
||||
for ( auto const & lc : LANG_CODE_MAP ) {
|
||||
if ( langFolded.compare( lc.lang, Qt::CaseInsensitive ) == 0 ) {
|
||||
if ( strcasecmp( langFolded.c_str(), lc.lang.c_str() ) == 0 ) {
|
||||
return code2toInt( lc.code2.toStdString().c_str() );
|
||||
}
|
||||
}
|
||||
|
|
17
src/windows/stub_msvc.h
Normal file
17
src/windows/stub_msvc.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#ifdef _MSC_VER
|
||||
#if !defined(strcasecmp)
|
||||
# define strcasecmp _strcmpi
|
||||
#endif
|
||||
#if !defined(strncasecmp)
|
||||
# define strncasecmp _strnicmp
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T
|
||||
#define _SSIZE_T
|
||||
#define ssize_t long
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in a new issue