diff --git a/es-core/src/MameNames.cpp b/es-core/src/MameNames.cpp index ed998b2d5..78743b5dd 100644 --- a/es-core/src/MameNames.cpp +++ b/es-core/src/MameNames.cpp @@ -55,7 +55,7 @@ MameNames::MameNames() for(pugi::xml_node gameNode = doc.child("game"); gameNode; gameNode = gameNode.next_sibling("game")) { NamePair namePair = { gameNode.child("mamename").text().get(), gameNode.child("realname").text().get() }; - names.push_back(namePair); + mNamePairs.push_back(namePair); } } // MameNames @@ -68,16 +68,16 @@ MameNames::~MameNames() std::string MameNames::getRealName(const std::string& _mameName) { size_t start = 0; - size_t end = names.size(); + size_t end = mNamePairs.size(); while(start < end) { const size_t index = (start + end) / 2; - const int compare = strcmp(names[index].mameName.c_str(), _mameName.c_str()); + const int compare = strcmp(mNamePairs[index].mameName.c_str(), _mameName.c_str()); if(compare < 0) start = index + 1; else if( compare > 0) end = index; - else return names[index].realName; + else return mNamePairs[index].realName; } return _mameName; diff --git a/es-core/src/MameNames.h b/es-core/src/MameNames.h index 5f8bb4634..52fd71455 100644 --- a/es-core/src/MameNames.h +++ b/es-core/src/MameNames.h @@ -5,8 +5,6 @@ #include #include -namespace CEC { class ICECAdapter; } - class MameNames { public: @@ -31,7 +29,7 @@ private: static MameNames* sInstance; - namePairVector names; + namePairVector mNamePairs; }; // MameNames diff --git a/es-core/src/math/Misc.h b/es-core/src/math/Misc.h index a571796f1..ea07e2e7e 100644 --- a/es-core/src/math/Misc.h +++ b/es-core/src/math/Misc.h @@ -29,7 +29,7 @@ namespace Math float bounce(const float _delayTime, const float _scrollTime, const float _currentTime, const float _scrollLength); float loop (const float _delayTime, const float _scrollTime, const float _currentTime, const float _scrollLength); - } // Math::Scroll:: + } // Scroll:: } // Math:: diff --git a/es-core/src/math/Vector2f.h b/es-core/src/math/Vector2f.h index 061684284..b9c91fda0 100644 --- a/es-core/src/math/Vector2f.h +++ b/es-core/src/math/Vector2f.h @@ -46,10 +46,10 @@ public: float& operator[](const int _index) { assert(_index < 2 && "index out of range"); return (&mX)[_index]; } const float& operator[](const int _index) const { assert(_index < 2 && "index out of range"); return (&mX)[_index]; } - float& x() { return mX; } - float& y() { return mY; } - const float& x() const { return mX; } - const float& y() const { return mY; } + inline float& x() { return mX; } + inline float& y() { return mY; } + inline const float& x() const { return mX; } + inline const float& y() const { return mY; } Vector2f& round(); Vector2f& lerp (const Vector2f& _start, const Vector2f& _end, const float _fraction); diff --git a/es-core/src/math/Vector2i.h b/es-core/src/math/Vector2i.h index 7cc020ea5..0c91a1155 100644 --- a/es-core/src/math/Vector2i.h +++ b/es-core/src/math/Vector2i.h @@ -40,10 +40,10 @@ public: int& operator[](const int _index) { assert(_index < 2 && "index out of range"); return (&mX)[_index]; } const int& operator[](const int _index) const { assert(_index < 2 && "index out of range"); return (&mX)[_index]; } - int& x() { return mX; } - int& y() { return mY; } - const int& x() const { return mX; } - const int& y() const { return mY; } + inline int& x() { return mX; } + inline int& y() { return mY; } + inline const int& x() const { return mX; } + inline const int& y() const { return mY; } static const Vector2i Zero () { return { 0, 0 }; } static const Vector2i UnitX() { return { 1, 0 }; } diff --git a/es-core/src/math/Vector3f.h b/es-core/src/math/Vector3f.h index c6237bc2c..8126e70d2 100644 --- a/es-core/src/math/Vector3f.h +++ b/es-core/src/math/Vector3f.h @@ -47,12 +47,12 @@ public: float& operator[](const int _index) { assert(_index < 3 && "index out of range"); return (&mX)[_index]; } const float& operator[](const int _index) const { assert(_index < 3 && "index out of range"); return (&mX)[_index]; } - float& x() { return mX; } - float& y() { return mY; } - float& z() { return mZ; } - const float& x() const { return mX; } - const float& y() const { return mY; } - const float& z() const { return mZ; } + inline float& x() { return mX; } + inline float& y() { return mY; } + inline float& z() { return mZ; } + inline const float& x() const { return mX; } + inline const float& y() const { return mY; } + inline const float& z() const { return mZ; } inline Vector2f& v2() { return *(Vector2f*)this; } inline const Vector2f& v2() const { return *(Vector2f*)this; } diff --git a/es-core/src/math/Vector4f.h b/es-core/src/math/Vector4f.h index 518c1450b..1776c80fe 100644 --- a/es-core/src/math/Vector4f.h +++ b/es-core/src/math/Vector4f.h @@ -49,14 +49,14 @@ public: float& operator[](const int _index) { assert(_index < 4 && "index out of range"); return (&mX)[_index]; } const float& operator[](const int _index) const { assert(_index < 4 && "index out of range"); return (&mX)[_index]; } - float& x() { return mX; } - float& y() { return mY; } - float& z() { return mZ; } - float& w() { return mW; } - const float& x() const { return mX; } - const float& y() const { return mY; } - const float& z() const { return mZ; } - const float& w() const { return mW; } + inline float& x() { return mX; } + inline float& y() { return mY; } + inline float& z() { return mZ; } + inline float& w() { return mW; } + inline const float& x() const { return mX; } + inline const float& y() const { return mY; } + inline const float& z() const { return mZ; } + inline const float& w() const { return mW; } inline Vector2f& v2() { return *(Vector2f*)this; } inline const Vector2f& v2() const { return *(Vector2f*)this; } diff --git a/es-core/src/utils/StringUtil.cpp b/es-core/src/utils/StringUtil.cpp index 54e2b18f2..fd70dfaa7 100644 --- a/es-core/src/utils/StringUtil.cpp +++ b/es-core/src/utils/StringUtil.cpp @@ -1,6 +1,7 @@ #include "utils/StringUtil.h" #include +#include namespace Utils { @@ -134,6 +135,17 @@ namespace Utils } // moveCursor + std::string toLower(const std::string& _string) + { + std::string string; + + for(size_t i = 0; i < _string.length(); ++i) + string += (char)tolower(_string[i]); + + return string; + + } // toLower + std::string toUpper(const std::string& _string) { std::string string; @@ -243,6 +255,31 @@ namespace Utils } // vectorToCommaString + std::string format(const char* _format, ...) + { + va_list args; + va_list copy; + + va_start(args, _format); + + va_copy(copy, args); + const int length = vsnprintf(nullptr, 0, _format, copy); + va_end(copy); + + char* buffer = new char[length + 1]; + va_copy(copy, args); + vsnprintf(buffer, length + 1, _format, copy); + va_end(copy); + + va_end(args); + + std::string out(buffer); + delete buffer; + + return out; + + } // format + } // String:: } // Utils:: diff --git a/es-core/src/utils/StringUtil.h b/es-core/src/utils/StringUtil.h index 47fb7d1fe..47bba35ac 100644 --- a/es-core/src/utils/StringUtil.h +++ b/es-core/src/utils/StringUtil.h @@ -16,6 +16,7 @@ namespace Utils size_t nextCursor (const std::string& _string, const size_t _cursor); size_t prevCursor (const std::string& _string, const size_t _cursor); size_t moveCursor (const std::string& _string, const size_t _cursor, const int _amount); + std::string toLower (const std::string& _string); std::string toUpper (const std::string& _string); std::string trim (const std::string& _string); std::string replace (const std::string& _string, const std::string& _replace, const std::string& _with); @@ -24,6 +25,7 @@ namespace Utils std::string removeParenthesis (const std::string& _string); stringVector commaStringToVector(const std::string& _string); std::string vectorToCommaString(stringVector _vector); + std::string format (const char* _string, ...); } // String::