mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
Allow multiple fallback fonts.
Reduced allocations and improved logs in LSP Plugin. Added String::split for std::string_view. Added support for std::string_view in Log.
This commit is contained in:
@@ -21,11 +21,20 @@ template <typename Key> using UnorderedSet = std::unordered_set<Key>;
|
||||
template <typename Key, typename Value>
|
||||
using UnorderedMap = robin_hood::unordered_flat_map<Key, Value>;
|
||||
|
||||
template <typename Key>
|
||||
using UnorderedSet = robin_hood::unordered_flat_set<Key>;
|
||||
template <typename Key> using UnorderedSet = robin_hood::unordered_flat_set<Key>;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace EE
|
||||
|
||||
template <typename... T>
|
||||
inline std::size_t hashCombine( std::size_t h1, std::size_t h2, T... other ) noexcept {
|
||||
if constexpr ( sizeof...( other ) == 0 ) {
|
||||
h1 ^= h2 + 0x9e3779b9 + ( h1 << 6 ) + ( h1 >> 2 );
|
||||
return h1;
|
||||
} else {
|
||||
return hashCombine( h1, hashCombine( h2, other... ) );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // EE_CONTAINERS_HPP
|
||||
|
||||
@@ -133,6 +133,11 @@ class EE_API String {
|
||||
const bool& pushEmptyString = false,
|
||||
const bool& keepDelim = false );
|
||||
|
||||
/** Split a string and hold it on a vector */
|
||||
static std::vector<std::string_view> split( const std::string_view& str,
|
||||
const Int8& delim = '\n',
|
||||
const bool& pushEmptyString = false );
|
||||
|
||||
/** Split a string and hold it on a vector. This function is meant to be used for code
|
||||
* splitting, detects functions, arrays, braces and quotes for the splitting. */
|
||||
static std::vector<std::string> split( const std::string& str, const std::string& delims,
|
||||
@@ -404,6 +409,11 @@ class EE_API String {
|
||||
**/
|
||||
String( const std::string& utf8String );
|
||||
|
||||
/** @brief Construct from an UTF-8 string to UTF-32 according
|
||||
** @param utf8String UTF-8 string to convert
|
||||
**/
|
||||
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
|
||||
|
||||
@@ -31,9 +31,13 @@ class EE_API FontManager : public ResourceManager<Font> {
|
||||
|
||||
void setEmojiFont( Font* newEmojiFont );
|
||||
|
||||
Font* getFallbackFont() const;
|
||||
const std::vector<Font*>& getFallbackFonts() const;
|
||||
|
||||
void setFallbackFont( Font* fallbackFont );
|
||||
bool hasFallbackFonts() const;
|
||||
|
||||
bool addFallbackFont( Font* fallbackFont );
|
||||
|
||||
bool removeFallbackFont( Font* fallbackFont );
|
||||
|
||||
FontHinting getHinting() const;
|
||||
|
||||
@@ -46,7 +50,7 @@ class EE_API FontManager : public ResourceManager<Font> {
|
||||
protected:
|
||||
Font* mColorEmojiFont{ nullptr };
|
||||
Font* mEmojiFont{ nullptr };
|
||||
Font* mFallbackFont{ nullptr };
|
||||
std::vector<Font*> mFallbackFonts;
|
||||
FontHinting mHinting{ FontHinting::Full };
|
||||
FontAntialiasing mAntialiasing{ FontAntialiasing::Grayscale };
|
||||
|
||||
|
||||
@@ -313,34 +313,17 @@ class EE_API URI {
|
||||
std::string mFragment;
|
||||
};
|
||||
|
||||
inline const std::string& URI::getScheme() const {
|
||||
return mScheme;
|
||||
}
|
||||
|
||||
inline const std::string& URI::getUserInfo() const {
|
||||
return mUserInfo;
|
||||
}
|
||||
|
||||
inline const std::string& URI::getHost() const {
|
||||
return mHost;
|
||||
}
|
||||
|
||||
inline const std::string& URI::getPath() const {
|
||||
return mPath;
|
||||
}
|
||||
|
||||
inline const std::string& URI::getRawQuery() const {
|
||||
return mQuery;
|
||||
}
|
||||
|
||||
inline const std::string& URI::getFragment() const {
|
||||
return mFragment;
|
||||
}
|
||||
|
||||
inline void swap( URI& u1, URI& u2 ) {
|
||||
u1.swap( u2 );
|
||||
}
|
||||
|
||||
}} // namespace EE::Network
|
||||
|
||||
template <> struct std::hash<EE::Network::URI> {
|
||||
std::size_t operator()( EE::Network::URI const& uri ) const noexcept {
|
||||
return hashCombine(
|
||||
std::hash<std::string>()( uri.getScheme() ),
|
||||
std::hash<std::string>()( uri.getUserInfo() ),
|
||||
std::hash<std::string>()( uri.getHost() ), std::hash<int>()( uri.getPort() ),
|
||||
std::hash<std::string>()( uri.getPath() ), std::hash<std::string>()( uri.getQuery() ),
|
||||
std::hash<std::string>()( uri.getFragment() ) );
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace EE { namespace System {
|
||||
* example for a console. */
|
||||
class LogReaderInterface {
|
||||
public:
|
||||
virtual void writeLog( const std::string& Text ) = 0;
|
||||
virtual void writeLog( const std::string_view& Text ) = 0;
|
||||
};
|
||||
|
||||
enum class LogLevel : int {
|
||||
@@ -56,22 +56,22 @@ class EE_API Log : protected Mutex {
|
||||
|
||||
/** @brief Writes the text to the log
|
||||
** @param text The text to write */
|
||||
void write( const std::string& text );
|
||||
void write( const std::string_view& text );
|
||||
|
||||
/** @brief Writes the text to the log with a log level.
|
||||
** @param level The log level that will try to write.
|
||||
** @param text The text to write */
|
||||
void write( const LogLevel& level, const std::string& text );
|
||||
void write( const LogLevel& level, const std::string_view& text );
|
||||
|
||||
/** @brief Writes the text to the log and appends a new line character at the end.
|
||||
** @param text The text to write */
|
||||
void writel( const std::string& text );
|
||||
void writel( const std::string_view& text );
|
||||
|
||||
/** @brief Writes the text to the log and appends a new line character at the end with a log
|
||||
*level.
|
||||
** @param levelThe log level that will try to write.
|
||||
** @param text The text to write */
|
||||
void writel( const LogLevel& level, const std::string& text );
|
||||
void writel( const LogLevel& level, const std::string_view& text );
|
||||
|
||||
/** @brief Writes a formated string to the log with a log level.
|
||||
** @param level The log level that will try to write.
|
||||
@@ -124,29 +124,29 @@ class EE_API Log : protected Mutex {
|
||||
/** Enable/Disable to keep a copy of the logs into memory (disabled by default) */
|
||||
void setKeepLog( bool keepLog );
|
||||
|
||||
static void debug( const std::string& text ) {
|
||||
static void debug( const std::string_view& text ) {
|
||||
Log::instance()->writel( LogLevel::Debug, text );
|
||||
}
|
||||
|
||||
static void info( const std::string& text ) { Log::instance()->writel( LogLevel::Info, text ); }
|
||||
static void info( const std::string_view& text ) { Log::instance()->writel( LogLevel::Info, text ); }
|
||||
|
||||
static void notice( const std::string& text ) {
|
||||
static void notice( const std::string_view& text ) {
|
||||
Log::instance()->writel( LogLevel::Notice, text );
|
||||
}
|
||||
|
||||
static void warning( const std::string& text ) {
|
||||
static void warning( const std::string_view& text ) {
|
||||
Log::instance()->writel( LogLevel::Warning, text );
|
||||
}
|
||||
|
||||
static void error( const std::string& text ) {
|
||||
static void error( const std::string_view& text ) {
|
||||
Log::instance()->writel( LogLevel::Error, text );
|
||||
}
|
||||
|
||||
static void critical( const std::string& text ) {
|
||||
static void critical( const std::string_view& text ) {
|
||||
Log::instance()->writel( LogLevel::Critical, text );
|
||||
}
|
||||
|
||||
static void assertLog( const std::string& text ) {
|
||||
static void assertLog( const std::string_view& text ) {
|
||||
Log::instance()->writel( LogLevel::Assert, text );
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class EE_API Log : protected Mutex {
|
||||
|
||||
void closeFS();
|
||||
|
||||
void writeToReaders( const std::string& text );
|
||||
void writeToReaders( const std::string_view& text );
|
||||
};
|
||||
|
||||
}} // namespace EE::System
|
||||
|
||||
@@ -301,7 +301,7 @@ class EE_API UIConsole : public UIWidget,
|
||||
|
||||
void privPushText( const String& str );
|
||||
|
||||
void writeLog( const std::string& text );
|
||||
void writeLog( const std::string_view& text );
|
||||
|
||||
void resetCursor();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user