2011-10-02 10:05:45 +00:00
|
|
|
#ifdef NALL_STRING_INTERNAL_HPP
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
namespace nall {
|
2013-05-05 09:21:30 +00:00
|
|
|
|
|
|
|
struct string;
|
|
|
|
struct stringref;
|
|
|
|
struct lstring;
|
|
|
|
typedef const stringref& rstring;
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
//#define NALL_STRING_ALLOCATOR_COPY_ON_WRITE
|
|
|
|
#define NALL_STRING_ALLOCATOR_SMALL_STRING_OPTIMIZATION
|
|
|
|
//#define NALL_STRING_ALLOCATOR_VECTOR
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
struct string {
|
|
|
|
protected:
|
2013-07-29 09:42:45 +00:00
|
|
|
#if defined(NALL_STRING_ALLOCATOR_COPY_ON_WRITE)
|
|
|
|
inline void _copy();
|
2013-05-05 09:21:30 +00:00
|
|
|
std::shared_ptr<char> _data;
|
2013-07-29 09:42:45 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(NALL_STRING_ALLOCATOR_SMALL_STRING_OPTIMIZATION)
|
|
|
|
enum : unsigned { SSO = 24 };
|
|
|
|
union {
|
|
|
|
char* _data;
|
|
|
|
char _text[SSO];
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(NALL_STRING_ALLOCATOR_VECTOR)
|
|
|
|
char* _data;
|
|
|
|
#endif
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
unsigned _capacity;
|
|
|
|
unsigned _size;
|
|
|
|
|
|
|
|
public:
|
|
|
|
//core.hpp
|
|
|
|
inline char* data();
|
|
|
|
inline const char* data() const;
|
|
|
|
inline unsigned length() const;
|
|
|
|
inline unsigned size() const;
|
|
|
|
inline unsigned capacity() const;
|
|
|
|
inline bool empty() const;
|
|
|
|
|
|
|
|
inline void reset();
|
|
|
|
inline void reserve(unsigned);
|
|
|
|
inline void resize(unsigned);
|
|
|
|
inline void clear(char);
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
inline unsigned hash() const;
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
template<typename... Args> inline string& assign(Args&&... args);
|
|
|
|
template<typename... Args> inline string& append(Args&&... args);
|
|
|
|
|
|
|
|
//file.hpp
|
2013-07-29 09:42:45 +00:00
|
|
|
inline static string read(const string& filename);
|
2013-05-05 09:21:30 +00:00
|
|
|
|
|
|
|
//datetime.hpp
|
|
|
|
inline static string date();
|
|
|
|
inline static string time();
|
|
|
|
inline static string datetime();
|
|
|
|
|
|
|
|
//replace.hpp
|
|
|
|
template<unsigned Limit = 0> inline string& replace(rstring, rstring);
|
|
|
|
template<unsigned Limit = 0> inline string& ireplace(rstring, rstring);
|
|
|
|
template<unsigned Limit = 0> inline string& qreplace(rstring, rstring);
|
|
|
|
template<unsigned Limit = 0> inline string& iqreplace(rstring, rstring);
|
|
|
|
|
|
|
|
//wrapper.hpp
|
|
|
|
template<unsigned Limit = 0> inline lstring split(rstring) const;
|
|
|
|
template<unsigned Limit = 0> inline lstring isplit(rstring) const;
|
|
|
|
template<unsigned Limit = 0> inline lstring qsplit(rstring) const;
|
|
|
|
template<unsigned Limit = 0> inline lstring iqsplit(rstring) const;
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
inline signed compare(rstring) const;
|
|
|
|
inline signed icompare(rstring) const;
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
inline bool equals(rstring) const;
|
|
|
|
inline bool iequals(rstring) const;
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
inline bool match(rstring) const;
|
|
|
|
inline bool imatch(rstring) const;
|
2013-05-05 09:21:30 +00:00
|
|
|
|
2013-12-03 10:01:59 +00:00
|
|
|
inline bool beginsWith(rstring) const;
|
|
|
|
inline bool ibeginsWith(rstring) const;
|
|
|
|
inline bool endsWith(rstring) const;
|
|
|
|
inline bool iendsWith(rstring) const;
|
2013-05-05 09:21:30 +00:00
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
inline string slice(unsigned offset, unsigned length = ~0u) const;
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
inline string& lower();
|
|
|
|
inline string& upper();
|
|
|
|
inline string& qlower();
|
|
|
|
inline string& qupper();
|
|
|
|
inline string& transform(rstring before, rstring after);
|
|
|
|
inline string& reverse();
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
template<unsigned limit = 0> inline string& ltrim() { return ltrim<limit>(" "); }
|
|
|
|
template<unsigned limit = 0> inline string& ltrim(rstring key);
|
|
|
|
|
|
|
|
template<unsigned limit = 0> inline string& rtrim() { return rtrim<limit>(" "); }
|
|
|
|
template<unsigned limit = 0> inline string& rtrim(rstring key);
|
|
|
|
|
|
|
|
template<unsigned limit = 0> inline string& trim() { return trim<limit>(" "); }
|
|
|
|
template<unsigned limit = 0> inline string& trim(rstring key);
|
|
|
|
template<unsigned limit = 0> inline string& trim(rstring key, rstring rkey);
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
inline string& strip();
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
inline optional<unsigned> find(rstring key) const;
|
|
|
|
inline optional<unsigned> ifind(rstring key) const;
|
|
|
|
inline optional<unsigned> qfind(rstring key) const;
|
|
|
|
inline optional<unsigned> iqfind(rstring key) const;
|
2013-05-05 09:21:30 +00:00
|
|
|
|
|
|
|
//core.hpp
|
|
|
|
inline explicit operator bool() const;
|
|
|
|
inline operator const char*() const;
|
2013-07-29 09:42:45 +00:00
|
|
|
inline char& operator[](signed);
|
|
|
|
inline const char& operator[](signed) const;
|
2013-05-05 09:21:30 +00:00
|
|
|
|
|
|
|
inline bool operator==(const char*) const;
|
|
|
|
inline bool operator!=(const char*) const;
|
|
|
|
inline bool operator< (const char*) const;
|
|
|
|
inline bool operator<=(const char*) const;
|
|
|
|
inline bool operator> (const char*) const;
|
|
|
|
inline bool operator>=(const char*) const;
|
|
|
|
|
|
|
|
inline string& operator=(const string&);
|
|
|
|
inline string& operator=(string&&);
|
|
|
|
|
|
|
|
template<typename T, typename... Args> inline string(T&& source, Args&&... args);
|
|
|
|
inline string();
|
|
|
|
inline string(const string&);
|
|
|
|
inline string(string&&);
|
|
|
|
inline ~string();
|
|
|
|
|
|
|
|
inline char* begin() { return &data()[0]; }
|
|
|
|
inline char* end() { return &data()[size()]; }
|
|
|
|
inline const char* begin() const { return &data()[0]; }
|
|
|
|
inline const char* end() const { return &data()[size()]; }
|
|
|
|
|
|
|
|
//protected:
|
|
|
|
struct exception_out_of_bounds{};
|
|
|
|
template<unsigned Limit, bool Insensitive, bool Quoted> inline string& ureplace(rstring, rstring);
|
|
|
|
inline string& _append(const char*);
|
|
|
|
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
private:
|
|
|
|
inline void construct();
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
#if defined(QSTRING_H)
|
|
|
|
public:
|
|
|
|
inline operator QString() const;
|
|
|
|
#endif
|
2010-08-09 13:28:56 +00:00
|
|
|
};
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
//list.hpp
|
|
|
|
struct lstring : vector<string> {
|
|
|
|
inline optional<unsigned> find(rstring) const;
|
Update to v093r01 release.
byuu says:
Changelog:
- added SA-1 MDR; fixes bug in SD Gundam G-Next where the main
battleship was unable to fire
- added out-of-the-box support for any BSD running Clang 3.3+ (FreeBSD
10+, notably)
- added new video shader, "Display Emulation", which changes the shader
based on the emulated system
- fixed the home button to go to your default library path
- phoenix: Windows port won't send onActivate unless an item is selected
(prevents crashing on pressing enter in file dialog)
- ruby: removed vec4 position from out Vertex {} (helps AMD cards)
- shaders: updated all shaders to use texture() instead of texture2D()
(helps AMD cards)
The "Display Emulation" option works like this: when selected, it tries
to load "<path>/Video Shaders/Emulation/<systemName>.shader/"; otherwise
it falls back to the blur shader. <path> is the usual (next to binary,
then in <config>/higan, then in /usr/share/higan, etc); and <systemName>
is "Famicom", "Super Famicom", "Game Boy", "Game Boy Color", "Game Boy
Advance"
To support BSD, I had to modify the $(platform) variable to
differentiate between Linux and BSD.
As such, the new $(platform) values are:
win -> windows
osx -> macosx
x -> linux or bsd
I am also checking uname -s instead of uname -a now. No reason to
potentially match the hostname to the wrong OS type.
2013-10-21 11:45:39 +00:00
|
|
|
inline string merge(const string&) const;
|
2013-05-05 09:21:30 +00:00
|
|
|
inline lstring& isort();
|
|
|
|
inline lstring& strip();
|
|
|
|
inline void append() {}
|
|
|
|
template<typename... Args> inline void append(const string&, Args&&...);
|
|
|
|
|
|
|
|
inline bool operator==(const lstring&) const;
|
|
|
|
inline bool operator!=(const lstring&) const;
|
|
|
|
|
|
|
|
inline lstring& operator=(const lstring&);
|
|
|
|
inline lstring& operator=(lstring&);
|
|
|
|
inline lstring& operator=(lstring&&);
|
|
|
|
|
|
|
|
template<typename... Args> inline lstring(Args&&... args);
|
|
|
|
inline lstring(const lstring&);
|
|
|
|
inline lstring(lstring&);
|
|
|
|
inline lstring(lstring&&);
|
|
|
|
|
|
|
|
//split.hpp
|
|
|
|
template<unsigned Limit = 0> inline lstring& split(rstring, rstring);
|
|
|
|
template<unsigned Limit = 0> inline lstring& isplit(rstring, rstring);
|
|
|
|
template<unsigned Limit = 0> inline lstring& qsplit(rstring, rstring);
|
|
|
|
template<unsigned Limit = 0> inline lstring& iqsplit(rstring, rstring);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
template<unsigned Limit, bool Insensitive, bool Quoted> inline lstring& usplit(rstring, rstring);
|
|
|
|
};
|
|
|
|
|
|
|
|
//filename.hpp
|
|
|
|
inline string dir(string name);
|
|
|
|
inline string notdir(string name);
|
|
|
|
inline string parentdir(string name);
|
|
|
|
inline string basename(string name);
|
|
|
|
inline string extension(string name);
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
inline string tempname();
|
2013-05-05 09:21:30 +00:00
|
|
|
|
|
|
|
//format.hpp
|
|
|
|
template<signed precision = 0, char padchar = ' '> inline string format(const string& value);
|
|
|
|
template<signed precision = 0, char padchar = '0'> inline string hex(uintmax_t value);
|
|
|
|
template<signed precision = 0, char padchar = '0'> inline string octal(uintmax_t value);
|
|
|
|
template<signed precision = 0, char padchar = '0'> inline string binary(uintmax_t value);
|
|
|
|
|
|
|
|
//platform.hpp
|
|
|
|
inline string activepath();
|
|
|
|
inline string realpath(const string& name);
|
|
|
|
inline string userpath();
|
|
|
|
inline string configpath();
|
|
|
|
inline string sharedpath();
|
|
|
|
inline string temppath();
|
|
|
|
|
|
|
|
//utility.hpp
|
|
|
|
inline string substr(rstring source, unsigned offset = 0, unsigned length = ~0u);
|
|
|
|
inline string sha256(const uint8_t* data, unsigned size);
|
|
|
|
inline bool tokenize(lstring& list, const char* s, const char* p);
|
|
|
|
|
|
|
|
inline char* integer(char* result, intmax_t value);
|
|
|
|
inline char* decimal(char* result, uintmax_t value);
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
inline unsigned real(char* str, long double value);
|
|
|
|
inline string real(long double value);
|
2013-05-05 09:21:30 +00:00
|
|
|
|
|
|
|
//variadic.hpp
|
|
|
|
inline void sprint(string& output);
|
|
|
|
template<typename T, typename... Args> inline void sprint(string& output, const T& value, Args&&... args);
|
|
|
|
template<typename... Args> inline void print(Args&&... args);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#endif
|