diff --git a/include/eepp/core/string.hpp b/include/eepp/core/string.hpp index 87c280390..dc5fcb7b8 100644 --- a/include/eepp/core/string.hpp +++ b/include/eepp/core/string.hpp @@ -334,7 +334,6 @@ class EE_API String { static std::string toString( const Uint16& i ); static std::string toString( const Uint32& i ); static std::string toString( const Uint64& i ); - static std::string toString( const std::size_t& i ); static std::string toString( const float& i ); static std::string toString( const double& i ); @@ -353,7 +352,6 @@ class EE_API String { static bool fromString( Uint16& t, const std::string& s, int base = 10 ); static bool fromString( Uint32& t, const std::string& s, int base = 10 ); static bool fromString( Uint64& t, const std::string& s, int base = 10 ); - static bool fromString( std::size_t& t, const std::string& s, int base = 10 ); static bool fromString( float& t, const std::string& s ); static bool fromString( double& t, const std::string& s ); @@ -366,7 +364,6 @@ class EE_API String { static bool fromString( Uint16& t, const String& s, int base = 10 ); static bool fromString( Uint32& t, const String& s, int base = 10 ); static bool fromString( Uint64& t, const String& s, int base = 10 ); - static bool fromString( std::size_t& t, const String& s, int base = 10 ); static bool fromString( float& t, const String& s ); static bool fromString( double& t, const String& s ); diff --git a/include/eepp/system/translator.hpp b/include/eepp/system/translator.hpp index 4fe3f805b..930af796f 100644 --- a/include/eepp/system/translator.hpp +++ b/include/eepp/system/translator.hpp @@ -2,7 +2,6 @@ #define EE_SYSTEM_STRINGLOCALERESOURCE_HPP #include -#include namespace pugi { class xml_node; @@ -18,7 +17,7 @@ class EE_API Translator { typedef std::unordered_map StringDictionary; typedef std::unordered_map StringLocaleDictionary; - Translator( const std::locale& locale = std::locale() ); + Translator(); bool loadFromDirectory( std::string dirPath, std::string ext = "xml" ); @@ -42,8 +41,6 @@ class EE_API Translator { FormatArg>::get( std::forward( args ) )... ); } - void setLanguageFromLocale( std::locale locale ); - std::string getDefaultLanguage() const; void setDefaultLanguage( const std::string& defaultLanguage ); diff --git a/src/eepp/core/string.cpp b/src/eepp/core/string.cpp index 03b82c28e..7c1e4eafb 100644 --- a/src/eepp/core/string.cpp +++ b/src/eepp/core/string.cpp @@ -90,10 +90,6 @@ bool String::fromString( Uint64& t, const std::string& s, int base ) { return _fromString<>( t, s, base ); } -bool String::fromString( std::size_t& t, const std::string& s, int base ) { - return _fromString<>( t, s, base ); -} - bool String::fromString( float& t, const std::string& s ) { return _fromString<>( t, s ); } @@ -134,10 +130,6 @@ bool String::fromString( Uint64& t, const String& s, int base ) { return _fromString<>( t, s, base ); } -bool String::fromString( std::size_t& t, const String& s, int base ) { - return _fromString<>( t, s, base ); -} - bool String::fromString( float& t, const String& s ) { return _fromString<>( t, s ); } @@ -184,10 +176,6 @@ std::string String::toString( const Uint64& i ) { return _toString<>( i ); } -std::string String::toString( const std::size_t& i ) { - return _toString<>( i ); -} - std::string String::toString( const float& i ) { return _toString<>( i ); } diff --git a/src/eepp/network/http.cpp b/src/eepp/network/http.cpp index 41f8d918c..ffb887e57 100644 --- a/src/eepp/network/http.cpp +++ b/src/eepp/network/http.cpp @@ -841,7 +841,7 @@ Http::Response Http::downloadRequest( const Http::Request& request, IOStream& wr requestHead.setContinue( false ); requestHead.setMethod( Request::Head ); Response responseHead = downloadRequest( requestHead, responseHeadBody ); - std::size_t contentLength = 0; + Uint64 contentLength = 0; if ( responseHead.hasField( "Accept-Ranges" ) && responseHead.hasField( "Content-Length" ) && @@ -887,7 +887,7 @@ Http::Response Http::downloadRequest( const Http::Request& request, IOStream& wr bool isnheader = false; bool chunked = false; bool compressed = false; - std::size_t contentLength = 0; + Uint64 contentLength = 0; std::string headerBuffer; HttpStreamChunked* chunkedStream = NULL; IOStreamInflate* inflateStream = NULL; diff --git a/src/eepp/network/http/httpstreamchunked.cpp b/src/eepp/network/http/httpstreamchunked.cpp index f08a12439..154543bfe 100644 --- a/src/eepp/network/http/httpstreamchunked.cpp +++ b/src/eepp/network/http/httpstreamchunked.cpp @@ -35,7 +35,7 @@ ios_size HttpStreamChunked::write( const char* data, ios_size size ) { if ( lenEnd != std::string::npos ) { std::string::size_type firstCharPos = lenEnd + 2; - std::size_t length; + Uint64 length; // Get the length of the chunk bool res = String::fromString( length, mChunkBuffer.substr( 0, lenEnd ), 16 ); diff --git a/src/eepp/system/translator.cpp b/src/eepp/system/translator.cpp index 90b57c367..a27e1943d 100644 --- a/src/eepp/system/translator.cpp +++ b/src/eepp/system/translator.cpp @@ -7,12 +7,36 @@ #define PUGIXML_HEADER_ONLY #include +#include + namespace EE { namespace System { -Translator::Translator( const std::locale& locale ) : mDefaultLanguage( "en" ) { - setLanguageFromLocale( locale ); +static std::string getLanguageFromLocale( std::locale locale ) { + std::string name = locale.name(); + + if ( "C" == name ) { +#if defined( EE_SUPPORT_EXCEPTIONS ) && EE_PLATFORM != EE_PLATFORM_WIN + try { + const char* loc = setlocale( LC_CTYPE, "" ); + locale = std::locale( loc ); + name = locale.name(); + } catch ( ... ) { + } +#endif + + if ( "C" == name ) { + return "en"; + } else { + return name.substr( 0, 2 ); + } + } else { + return name.substr( 0, 2 ); + } } +Translator::Translator() : + mDefaultLanguage( "en" ), mCurrentLanguage( getLanguageFromLocale( std::locale() ) ) {} + bool Translator::loadFromDirectory( std::string dirPath, std::string ext ) { FileSystem::dirAddSlashAtEnd( dirPath ); bool someFailed = false; @@ -192,29 +216,6 @@ void Translator::setString( const std::string& lang, const std::string& key, con mDictionary[lang][key] = val; } -void Translator::setLanguageFromLocale( std::locale locale ) { - std::string name = locale.name(); - - if ( "C" == name ) { -#if defined( EE_SUPPORT_EXCEPTIONS ) && EE_PLATFORM != EE_PLATFORM_WIN - try { - const char* loc = setlocale( LC_CTYPE, "" ); - locale = std::locale( loc ); - name = locale.name(); - } catch ( ... ) { - } -#endif - - if ( "C" == name ) { - mCurrentLanguage = "en"; - } else { - mCurrentLanguage = name.substr( 0, 2 ); - } - } else { - mCurrentLanguage = name.substr( 0, 2 ); - } -} - std::string Translator::getDefaultLanguage() const { return mDefaultLanguage; } diff --git a/src/tools/ecode/appconfig.hpp b/src/tools/ecode/appconfig.hpp index 6910ba1aa..704e29ad5 100644 --- a/src/tools/ecode/appconfig.hpp +++ b/src/tools/ecode/appconfig.hpp @@ -164,7 +164,7 @@ struct TerminalConfig { StyleSheetLength fontSize{ 11, StyleSheetLength::Dp }; NewTerminalOrientation::Orientation newTerminalOrientation{ NewTerminalOrientation::Horizontal }; - size_t scrollback{ 10000 }; + Uint64 scrollback{ 10000 }; bool unsupportedOSWarnDisabled{ false }; }; diff --git a/src/tools/ecode/plugins/lsp/lspclientserver.cpp b/src/tools/ecode/plugins/lsp/lspclientserver.cpp index 33140e79e..985492f60 100644 --- a/src/tools/ecode/plugins/lsp/lspclientserver.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientserver.cpp @@ -1401,7 +1401,8 @@ LSPClientServer::LSPRequestHandle LSPClientServer::write( json&& msg, const Json try { std::string sjson( msg.dump() ); - sjson.insert( 0, "Content-Length: " + String::toString( sjson.size() ) + "\r\n\r\n" ); + sjson.insert( 0, + "Content-Length: " + String::toString( (Uint64)sjson.size() ) + "\r\n\r\n" ); if ( mReady || ( msg.contains( MEMBER_METHOD ) && msg[MEMBER_METHOD] == "initialize" ) ) { if ( !isSilent() ) { diff --git a/src/tools/ecode/settingsmenu.cpp b/src/tools/ecode/settingsmenu.cpp index 12d492b9e..4c3e4061f 100644 --- a/src/tools/ecode/settingsmenu.cpp +++ b/src/tools/ecode/settingsmenu.cpp @@ -364,7 +364,7 @@ UIMenu* SettingsMenu::createDocumentMenu() { UIPopUpMenu* indentWidthMenu = UIPopUpMenu::New(); for ( size_t w = 2; w <= 12; w++ ) indentWidthMenu - ->addRadioButton( String::toString( w ), + ->addRadioButton( String::toString( (Uint64)w ), mSplitter->curEditorExistsAndFocused() && mSplitter->getCurEditor()->getDocument().getIndentWidth() == w ) ->setId( String::format( "indent_width_%zu", w ) ) @@ -381,7 +381,7 @@ UIMenu* SettingsMenu::createDocumentMenu() { UIPopUpMenu* tabWidthMenu = UIPopUpMenu::New(); for ( size_t w = 2; w <= 12; w++ ) tabWidthMenu - ->addRadioButton( String::toString( w ), + ->addRadioButton( String::toString( (Uint64)w ), mSplitter->curEditorExistsAndFocused() && mSplitter->getCurEditor()->getTabWidth() == w ) ->setId( String::format( "tab_width_%zu", w ) ) diff --git a/src/tools/ecode/uibuildsettings.cpp b/src/tools/ecode/uibuildsettings.cpp index a6a3613d5..e574083d0 100644 --- a/src/tools/ecode/uibuildsettings.cpp +++ b/src/tools/ecode/uibuildsettings.cpp @@ -210,10 +210,10 @@ class UIBuildStep : public UILinearLayout { void updateStep( size_t stepNum, ProjectBuildStep* buildStep ) { clearBindings(); - removeClass( String::toString( mStepNum ) ); + removeClass( String::toString( (Uint64)mStepNum ) ); mStepNum = stepNum; mStep = buildStep; - addClass( String::toString( mStepNum ) ); + addClass( String::toString( (Uint64)mStepNum ) ); forEachChild( [buildStep]( Node* node ) { node->setEnabled( buildStep != nullptr ); } ); if ( buildStep == nullptr ) @@ -250,7 +250,7 @@ class UIBuildStep : public UILinearLayout { mStep( buildStep ) { setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); addClass( "build_step" ); - addClass( String::toString( stepNum ) ); + addClass( String::toString( (Uint64)stepNum ) ); static const auto BUILD_STEP_XML = R"xml( @@ -802,7 +802,7 @@ void UIBuildSettings::moveStepDir( size_t stepNum, bool isClean, int dir ) { isClean ? find( "build_clean_steps_cont" ) : find( "build_steps_cont" ); int newStep = (int)stepNum + dir; std::swap( steps[stepNum], steps[newStep] ); - auto bs1 = cont->findByClass( String::toString( stepNum ) ); + auto bs1 = cont->findByClass( String::toString( (Uint64)stepNum ) ); auto bs2 = cont->findByClass( String::toString( newStep ) ); bs1->updateStep( stepNum, &steps[stepNum] ); bs2->updateStep( newStep, &steps[newStep] ); @@ -813,11 +813,11 @@ void UIBuildSettings::deleteStep( size_t stepNum, bool isClean ) { UIWidget* cont = isClean ? find( "build_clean_steps_cont" ) : find( "build_steps_cont" ); for ( auto step = stepNum; step < steps.size(); step++ ) - cont->findByClass( String::toString( step ) )->clearBindings(); + cont->findByClass( String::toString( (Uint64)step ) )->clearBindings(); steps.erase( steps.begin() + stepNum ); - cont->findByClass( String::toString( stepNum ) )->close(); + cont->findByClass( String::toString( (Uint64)stepNum ) )->close(); for ( auto step = stepNum + 1; step <= steps.size(); step++ ) - cont->findByClass( String::toString( step ) ) + cont->findByClass( String::toString( (Uint64)step ) ) ->updateStep( step - 1, &steps[step - 1] ); }