Fix Linux build.

This commit is contained in:
Martín Lucas Golini
2024-10-20 13:15:45 -03:00
parent 4c8965c876
commit b62668dc74
5 changed files with 16 additions and 87 deletions

View File

@@ -435,14 +435,10 @@ class EE_API String {
**/
String();
/** @brief Construct from a single ANSI character and a locale
** The source character is converted to UTF-32 according
** to the given locale. If you want to use the current global
** locale, rather use the other constructor.
/** @brief Construct from a single ANSI character
** @param ansiChar ANSI character to convert
** @param locale Locale to use for conversion
**/
String( char ansiChar, const std::locale& locale = std::locale() );
String( char ansiChar );
#ifndef EE_NO_WIDECHAR
/** @brief Construct from single wide character
@@ -476,24 +472,6 @@ class EE_API String {
**/
String( const std::string_view& utf8String );
/** @brief Construct from a null-terminated C-style ANSI string and a locale
** The source string is converted to UTF-32 according
** to the given locale. If you want to use the current global
** locale, rather use the other constructor.
** @param ansiString ANSI string to convert
** @param locale Locale to use for conversion
**/
String( const char* ansiString, const std::locale& locale );
/** @brief Construct from an ANSI string and a locale
** The source string is converted to UTF-32 according
** to the given locale. If you want to use the current global
** locale, rather use the other constructor.
** @param ansiString ANSI string to convert
** @param locale Locale to use for conversion
**/
String( const std::string& ansiString, const std::locale& locale );
#ifndef EE_NO_WIDECHAR
/** @brief Construct from null-terminated C-style wide string
** @param wideString Wide string to convert
@@ -545,19 +523,6 @@ class EE_API String {
**/
operator std::string() const;
/** @brief Convert the unicode string to an ANSI string
** The UTF-32 string is converted to an ANSI string in
** the encoding defined by \a locale. If you want to use
** the current global locale, see the other overload
** of toAnsiString.
** Characters that do not fit in the target encoding are
** discarded from the returned string.
** @param locale Locale to use for conversion
** @return Converted ANSI string
** @see toWideString, operator std::string
**/
std::string toAnsiString( const std::locale& locale = std::locale() ) const;
#ifndef EE_NO_WIDECHAR
/** @brief Convert the unicode string to a wide string
** Characters that do not fit in the target encoding are
@@ -1010,28 +975,19 @@ EE::String is a utility string class defined mainly for
convenience. It is a Unicode string (implemented using
UTF-32), thus it can store any character in the world
(european, chinese, arabic, hebrew, etc.).
It automatically handles conversions from/to ANSI and
It automatically handles conversions from/to UTF-8 and
wide strings, so that you can work with standard string
classes and still be compatible with functions taking a
EE::String.
@code
EE::String s;
std::string s1 = s; // automatically converted to ANSI string
std::string s1 = s; // automatically converted to UTF-8 string
String s2 = s; // automatically converted to wide string
s = "hello"; // automatically converted from ANSI string
s = "hello"; // automatically converted from UTF-8 string
s = L"hello"; // automatically converted from wide string
s += 'a'; // automatically converted from ANSI string
s += 'a'; // automatically converted from UTF-8 string
s += L'a'; // automatically converted from wide string
@endcode
Conversions involving ANSI strings use the default user locale. However
it is possible to use a custom locale if necessary:
@code
std::locale locale;
EE::String s;
...
std::string s1 = s.toAnsiString(locale);
s = EE::String("hello", locale);
@endcode
EE::String defines the most important functions of the
standard std::string class: removing, random access, iterating,

View File

@@ -2,6 +2,7 @@
#define EE_SYSTEM_STRINGLOCALERESOURCE_HPP
#include <eepp/core.hpp>
#include <locale>
namespace pugi {
class xml_node;

View File

@@ -1295,8 +1295,8 @@ void String::formatBuffer( char* Buffer, int BufferSize, const char* format, ...
String::String() {}
String::String( char ansiChar, const std::locale& locale ) {
mString += Utf32::decodeAnsi( ansiChar, locale );
String::String( char ansiChar ) {
mString += Utf32::decodeAnsi( ansiChar, std::locale() );
}
#ifndef EE_NO_WIDECHAR
@@ -1363,22 +1363,6 @@ String::String( const std::string_view& utf8String ) {
Utf8::toUtf32( utf8String.begin() + skip, utf8String.end(), std::back_inserter( mString ) );
}
String::String( const char* ansiString, const std::locale& locale ) {
if ( ansiString ) {
std::size_t length = strlen( ansiString );
if ( length > 0 ) {
mString.reserve( length + 1 );
Utf32::fromAnsi( ansiString, ansiString + length, std::back_inserter( mString ),
locale );
}
}
}
String::String( const std::string& ansiString, const std::locale& locale ) {
mString.reserve( ansiString.length() + 1 );
Utf32::fromAnsi( ansiString.begin(), ansiString.end(), std::back_inserter( mString ), locale );
}
#ifndef EE_NO_WIDECHAR
String::String( const wchar_t* wideString ) {
if ( wideString ) {
@@ -1502,17 +1486,6 @@ String::operator std::string() const {
return toUtf8();
}
std::string String::toAnsiString( const std::locale& locale ) const {
// Prepare the output string
std::string output;
output.reserve( mString.length() + 1 );
// Convert
Utf32::toAnsi( mString.begin(), mString.end(), std::back_inserter( output ), 0, locale );
return output;
}
#ifndef EE_NO_WIDECHAR
std::wstring String::toWideString() const {
// Prepare the output string

View File

@@ -1,6 +1,7 @@
#include <eepp/system/color.hpp>
#include <eepp/system/functionstring.hpp>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <iomanip>
@@ -606,8 +607,7 @@ Color Color::fromString( std::string str ) {
Float alphaVal = 1;
if ( functionString.getParameters().size() >= 4 ) {
if ( String::fromString( alphaVal,
functionString.getParameters().at( 3 ) ) ) {
if ( String::fromString( alphaVal, functionString.getParameters().at( 3 ) ) ) {
alphaVal = eemax( eemin( 1.f, alphaVal ), 0.f );
} else {
return Color::Transparent;
@@ -663,8 +663,7 @@ Color Color::fromString( std::string str ) {
Float alphaVal = 1;
if ( functionString.getParameters().size() >= 4 ) {
if ( String::fromString( alphaVal,
functionString.getParameters().at( 3 ) ) ) {
if ( String::fromString( alphaVal, functionString.getParameters().at( 3 ) ) ) {
alphaVal = eemax( eemin( 1.f, alphaVal ), 0.f );
} else {
return Color::Transparent;

View File

@@ -323,8 +323,8 @@ Git::CountResult Git::branchHistoryPosition( const std::string& localBranch,
String::trimInPlace( buf );
auto results = String::split( buf, '\t' );
if ( results.size() == 2 ) {
int64_t behind = 0;
int64_t ahead = 0;
Int64 behind = 0;
Int64 ahead = 0;
if ( String::fromString( ahead, results[0] ) &&
String::fromString( behind, results[1] ) ) {
res.ahead = ahead;
@@ -372,12 +372,12 @@ static void parseAheadBehind( std::string_view aheadBehind, Git::Branch& branch
s = String::trim( s );
if ( String::startsWith( s, BEHIND ) ) {
std::string numStr = std::string{ s.substr( BEHIND.size() ) };
int64_t val = 0;
Int64 val = 0;
if ( String::fromString( val, numStr ) )
branch.behind = val;
} else if ( String::startsWith( s, AHEAD ) ) {
std::string numStr = std::string{ s.substr( AHEAD.size() ) };
int64_t val = 0;
Int64 val = 0;
if ( String::fromString( val, numStr ) )
branch.ahead = val;
}