initial start to eliminate static func init, not compilable atm
move module initialization into a module manager, still has some issues like stopping not working and debug crashing add #idef 0 to modules that aren't in the windows project don't double initialize and don't de-initialize for now, since many modules don't expect it and it leads to many errors remove duplicate module lists for empty modules and implemented ones, make Module non-copyable but movable add secondary project, no real use for it now add some memleak config to the emucore and add asmjit path to rpcs3 small rebase error fixed to get it to compile again add filters for emucore re-add the module manager and static file WIP commit, linker errors abound some more abstraction layer stuff fix the remaining linker errors, re-enable platform specific mouse, pad and keyboard handlers rebasing fix memset undefined and re() usage of se_t before declaration Add wxGUI define by default for cmake builds fix copy constructors of Datetime header fix copy constructors of other wx interface classes remove static declarations of global variables make wxGLCanvas constructor non-ambiguous even with wx2.8. compat mode, fix wrong std::exception constructor calls remove duplicate definition for FromUTF8 and ToUTF8 temp changes
This commit is contained in:
@@ -2,12 +2,24 @@
|
||||
|
||||
#include "Utilities/GNU.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
//#define re(val) MemoryBase::Reverse(val)
|
||||
#define re64(val) MemoryBase::Reverse64(val)
|
||||
#define re32(val) MemoryBase::Reverse32(val)
|
||||
#define re16(val) MemoryBase::Reverse16(val)
|
||||
|
||||
template<typename T, int size = sizeof(T)> struct se_t;
|
||||
template<typename T> struct se_t<T, 1> { static __forceinline void func(T& dst, const T src) { (u8&)dst = (u8&)src; } };
|
||||
template<typename T> struct se_t<T, 2> { static __forceinline void func(T& dst, const T src) { (u16&)dst = _byteswap_ushort((u16&)src); } };
|
||||
template<typename T> struct se_t<T, 4> { static __forceinline void func(T& dst, const T src) { (u32&)dst = _byteswap_ulong((u32&)src); } };
|
||||
template<typename T> struct se_t<T, 8> { static __forceinline void func(T& dst, const T src) { (u64&)dst = _byteswap_uint64((u64&)src); } };
|
||||
|
||||
template<typename T> T re(const T val) { T res; se_t<T>::func(res, val); return res; }
|
||||
template<typename T1, typename T2> void re(T1& dst, const T2 val) { se_t<T1>::func(dst, val); }
|
||||
|
||||
template<typename T, s64 _value, int size = sizeof(T)> struct const_se_t;
|
||||
template<typename T, s64 _value> struct const_se_t<T, _value, 1>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include <unordered_map>
|
||||
|
||||
#define rID_ANY -1 // was wxID_ANY
|
||||
|
||||
typedef u32 ID_TYPE;
|
||||
|
||||
class IDData
|
||||
@@ -154,7 +156,7 @@ public:
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mtx_main);
|
||||
|
||||
if(id == wxID_ANY)
|
||||
if(id == rID_ANY)
|
||||
return m_id_map.begin() != m_id_map.end();
|
||||
}
|
||||
|
||||
|
||||
+59
-15
@@ -54,21 +54,23 @@ std::string replace_all(std::string src, const std::string& from, const std::str
|
||||
return src;
|
||||
}
|
||||
|
||||
//convert a wxString to a std::string encoded in utf8
|
||||
//CAUTION, only use this to interface with wxWidgets classes
|
||||
std::string fmt::ToUTF8(const wxString& right)
|
||||
{
|
||||
auto ret = std::string(((const char *) right.utf8_str()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
//convert a std::string encoded in utf8 to a wxString
|
||||
//CAUTION, only use this to interface with wxWidgets classes
|
||||
wxString fmt::FromUTF8(const std::string& right)
|
||||
{
|
||||
auto ret = wxString::FromUTF8(right.c_str());
|
||||
return ret;
|
||||
}
|
||||
//#ifdef wxGUI
|
||||
////convert a wxString to a std::string encoded in utf8
|
||||
////CAUTION, only use this to interface with wxWidgets classes
|
||||
//std::string fmt::ToUTF8(const wxString& right)
|
||||
//{
|
||||
// auto ret = std::string(((const char *) right.utf8_str()));
|
||||
// return ret;
|
||||
//}
|
||||
//
|
||||
////convert a std::string encoded in utf8 to a wxString
|
||||
////CAUTION, only use this to interface with wxWidgets classes
|
||||
//wxString fmt::FromUTF8(const std::string& right)
|
||||
//{
|
||||
// auto ret = wxString::FromUTF8(right.c_str());
|
||||
// return ret;
|
||||
//}
|
||||
//#endif
|
||||
|
||||
//TODO: remove this after every snippet that uses it is gone
|
||||
//WARNING: not fully compatible with CmpNoCase from wxString
|
||||
@@ -86,4 +88,46 @@ int fmt::CmpNoCase(const std::string& a, const std::string& b)
|
||||
[](const char& a, const char& b){return tolower(a) == tolower(b); })
|
||||
? 0 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: remove this after every snippet that uses it is gone
|
||||
//WARNING: not fully compatible with CmpNoCase from wxString
|
||||
void fmt::Replace(std::string &str, const std::string &searchterm, const std::string& replaceterm)
|
||||
{
|
||||
size_t cursor = 0;
|
||||
do
|
||||
{
|
||||
cursor = str.find(searchterm, cursor);
|
||||
if (cursor != std::string::npos)
|
||||
{
|
||||
str.replace(cursor, searchterm.size(), replaceterm);
|
||||
cursor += replaceterm.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
std::vector<std::string> fmt::rSplit(const std::string& source, const std::string& delim)
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
size_t cursor = 0;
|
||||
do
|
||||
{
|
||||
size_t prevcurs = cursor;
|
||||
cursor = source.find(delim, cursor);
|
||||
if (cursor != std::string::npos)
|
||||
{
|
||||
ret.push_back(source.substr(prevcurs,cursor-prevcurs));
|
||||
cursor += delim.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.push_back(source.substr(prevcurs));
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
return ret;
|
||||
}
|
||||
@@ -9,6 +9,29 @@
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//int CmpNoCase(const std::string &str, const std::string &str2)
|
||||
//{
|
||||
// bool same;
|
||||
// if (str.size() > str2.size())
|
||||
// {
|
||||
// same = std::equal(str.cbegin(), str.cend(), str2.cbegin(), [](const char a, const char b) -> bool{ return tolower(a) == tolower(b); });
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// same = std::equal(str2.cbegin(), str2.cend(), str.cbegin(), [](const char a, const char b) -> bool{ return tolower(a) == tolower(b); });
|
||||
// }
|
||||
// if (same)
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 1;
|
||||
// }
|
||||
//}
|
||||
|
||||
namespace fmt{
|
||||
using std::string;
|
||||
using std::ostream;
|
||||
@@ -18,6 +41,38 @@ namespace fmt{
|
||||
|
||||
extern const string placeholder;
|
||||
|
||||
template <typename T>
|
||||
std::string AfterLast(const std::string& source, T searchstr)
|
||||
{
|
||||
size_t search_pos = source.rfind(searchstr);
|
||||
search_pos = search_pos == std::string::npos ? 0 : search_pos;
|
||||
return source.substr(search_pos);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string BeforeLast(const std::string& source, T searchstr)
|
||||
{
|
||||
size_t search_pos = source.rfind(searchstr);
|
||||
search_pos = search_pos == std::string::npos ? 0 : search_pos;
|
||||
return source.substr(0, search_pos);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string AfterFirst(const std::string& source, T searchstr)
|
||||
{
|
||||
size_t search_pos = source.find(searchstr);
|
||||
search_pos = search_pos == std::string::npos ? 0 : search_pos;
|
||||
return source.substr(search_pos);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string BeforeFirst(const std::string& source, T searchstr)
|
||||
{
|
||||
size_t search_pos = source.find(searchstr);
|
||||
search_pos = search_pos == std::string::npos ? 0 : search_pos;
|
||||
return source.substr(0, search_pos);
|
||||
}
|
||||
|
||||
// write `fmt` from `pos` to the first occurence of `fmt::placeholder` to
|
||||
// the stream `os`. Then write `arg` to to the stream. If there's no
|
||||
// `fmt::placeholder` after `pos` everything in `fmt` after pos is written
|
||||
@@ -161,4 +216,9 @@ namespace fmt{
|
||||
//WARNING: not fully compatible with CmpNoCase from wxString
|
||||
int CmpNoCase(const std::string& a, const std::string& b);
|
||||
|
||||
//TODO: remove this after every snippet that uses it is gone
|
||||
//WARNING: not fully compatible with Replace from wxString
|
||||
void Replace(std::string &str, const std::string &searchterm, const std::string& replaceterm);
|
||||
|
||||
std::vector<std::string> rSplit(const std::string& source, const std::string& delim);
|
||||
}
|
||||
|
||||
+2
-2
@@ -124,9 +124,9 @@ public:
|
||||
bool IsBusy() const { return m_busy; }
|
||||
};
|
||||
|
||||
static __forceinline bool SemaphorePostAndWait(wxSemaphore& sem)
|
||||
static __forceinline bool SemaphorePostAndWait(rSemaphore& sem)
|
||||
{
|
||||
if(sem.TryWait() != wxSEMA_BUSY) return false;
|
||||
if(sem.TryWait() != rSEMA_BUSY) return false;
|
||||
|
||||
sem.Post();
|
||||
sem.Wait();
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
rSemaphore::rSemaphore()
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxSemaphore());
|
||||
}
|
||||
|
||||
//rSemaphore::rSemaphore(rSemaphore& other)
|
||||
//{
|
||||
// handle = reinterpret_cast<void*>(new wxSemaphore(*reinterpret_cast<wxSemaphore*>(other.handle)));
|
||||
//}
|
||||
|
||||
rSemaphore::~rSemaphore()
|
||||
{
|
||||
delete reinterpret_cast<wxSemaphore*>(handle);
|
||||
}
|
||||
|
||||
rSemaphore::rSemaphore(int initial_count, int max_count)
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxSemaphore(initial_count,max_count));
|
||||
}
|
||||
|
||||
void rSemaphore::Wait()
|
||||
{
|
||||
reinterpret_cast<wxSemaphore*>(handle)->Wait();
|
||||
}
|
||||
|
||||
rSemaStatus rSemaphore::TryWait()
|
||||
{
|
||||
wxSemaError err = reinterpret_cast<wxSemaphore*>(handle)->TryWait();
|
||||
if (err == wxSEMA_BUSY)
|
||||
{
|
||||
return rSEMA_BUSY;
|
||||
}
|
||||
else
|
||||
{
|
||||
return rSEMA_OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
void rSemaphore::Post()
|
||||
{
|
||||
reinterpret_cast<wxSemaphore*>(handle)->Post();
|
||||
}
|
||||
|
||||
void rSemaphore::WaitTimeout(u64 timeout)
|
||||
{
|
||||
reinterpret_cast<wxSemaphore*>(handle)->WaitTimeout(timeout);
|
||||
}
|
||||
|
||||
rCriticalSection::rCriticalSection()
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxCriticalSection());
|
||||
}
|
||||
|
||||
//rCriticalSection::rCriticalSection(rCriticalSection&)
|
||||
//{
|
||||
// handle = reinterpret_cast<void*>(new wxCriticalSection(*reinterpret_cast<wxCriticalSection*>(other.handle)));
|
||||
//}
|
||||
|
||||
rCriticalSection::~rCriticalSection()
|
||||
{
|
||||
delete reinterpret_cast<wxCriticalSection*>(handle);
|
||||
}
|
||||
|
||||
void rCriticalSection::Enter()
|
||||
{
|
||||
reinterpret_cast<wxCriticalSection*>(handle)->Enter();
|
||||
}
|
||||
|
||||
void rCriticalSection::Leave()
|
||||
{
|
||||
reinterpret_cast<wxCriticalSection*>(handle)->Leave();
|
||||
}
|
||||
|
||||
rTimer::rTimer()
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxTimer());
|
||||
}
|
||||
|
||||
//rTimer::rTimer(rTimer&)
|
||||
//{
|
||||
// handle = reinterpret_cast<void*>(new wxTimer(*reinterpret_cast<wxTimer*>(other.handle)));
|
||||
//}
|
||||
|
||||
rTimer::~rTimer()
|
||||
{
|
||||
delete reinterpret_cast<wxTimer*>(handle);
|
||||
}
|
||||
|
||||
void rTimer::Start()
|
||||
{
|
||||
reinterpret_cast<wxTimer*>(handle)->Start();
|
||||
}
|
||||
|
||||
void rTimer::Stop()
|
||||
{
|
||||
reinterpret_cast<wxTimer*>(handle)->Stop();
|
||||
}
|
||||
|
||||
void rSleep(u32 time)
|
||||
{
|
||||
wxSleep(time);
|
||||
}
|
||||
|
||||
void rMicroSleep(u64 time)
|
||||
{
|
||||
wxMicroSleep(time);
|
||||
}
|
||||
|
||||
rCriticalSectionLocker::rCriticalSectionLocker(const rCriticalSection &sec)
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxCriticalSectionLocker(*reinterpret_cast<wxCriticalSection*>(sec.handle)));
|
||||
}
|
||||
|
||||
|
||||
rCriticalSectionLocker::~rCriticalSectionLocker()
|
||||
{
|
||||
delete reinterpret_cast<wxCriticalSectionLocker*>(handle);
|
||||
}
|
||||
|
||||
bool rThread::IsMain()
|
||||
{
|
||||
return wxThread::IsMain();
|
||||
}
|
||||
|
||||
void rYieldIfNeeded()
|
||||
{
|
||||
wxYieldIfNeeded();
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
enum rSemaStatus
|
||||
{
|
||||
rSEMA_BUSY,
|
||||
rSEMA_OTHER
|
||||
};
|
||||
struct rSemaphore
|
||||
{
|
||||
rSemaphore();
|
||||
rSemaphore(const rSemaphore& other) = delete;
|
||||
~rSemaphore();
|
||||
rSemaphore(int initial_count, int max_count);
|
||||
void Wait();
|
||||
rSemaStatus TryWait();
|
||||
void Post();
|
||||
void WaitTimeout(u64 timeout);
|
||||
private:
|
||||
void *handle;
|
||||
};
|
||||
|
||||
struct rCriticalSection
|
||||
{
|
||||
rCriticalSection();
|
||||
rCriticalSection(const rCriticalSection& other) = delete;
|
||||
~rCriticalSection();
|
||||
void Enter();
|
||||
void Leave();
|
||||
void *handle;
|
||||
};
|
||||
|
||||
struct rTimer
|
||||
{
|
||||
rTimer();
|
||||
rTimer(const rTimer& other) = delete;
|
||||
~rTimer();
|
||||
void Start();
|
||||
void Stop();
|
||||
private:
|
||||
void *handle;
|
||||
};
|
||||
|
||||
void rSleep(u32 time);
|
||||
void rMicroSleep(u64 time);
|
||||
|
||||
struct rCriticalSectionLocker
|
||||
{
|
||||
rCriticalSectionLocker(const rCriticalSection& other);
|
||||
~rCriticalSectionLocker();
|
||||
private:
|
||||
void *handle;
|
||||
};
|
||||
|
||||
struct rThread
|
||||
{
|
||||
static bool IsMain();
|
||||
};
|
||||
|
||||
void rYieldIfNeeded();
|
||||
@@ -0,0 +1,327 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
const int rPATH_MKDIR_FULL = wxPATH_MKDIR_FULL;
|
||||
|
||||
//enum rSeekMode
|
||||
//{
|
||||
// rFromStart,
|
||||
// rFromCurrent,
|
||||
// rFromEnd
|
||||
//};
|
||||
//
|
||||
// enum OpenMode
|
||||
// {
|
||||
// read,
|
||||
// write,
|
||||
// read_write,
|
||||
// write_append,
|
||||
// write_excl
|
||||
// };
|
||||
|
||||
wxFile::OpenMode convertOpenMode(rFile::OpenMode open)
|
||||
{
|
||||
wxFile::OpenMode mode;
|
||||
switch (open)
|
||||
{
|
||||
case rFile::read:
|
||||
mode = wxFile::read;
|
||||
break;
|
||||
case rFile::write:
|
||||
mode = wxFile::write;
|
||||
break;
|
||||
case rFile::read_write:
|
||||
mode = wxFile::read_write;
|
||||
break;
|
||||
case rFile::write_append:
|
||||
mode = wxFile::write_append;
|
||||
break;
|
||||
case rFile::write_excl:
|
||||
mode = wxFile::write_excl;
|
||||
break;
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
rFile::OpenMode rConvertOpenMode(wxFile::OpenMode open)
|
||||
{
|
||||
rFile::OpenMode mode;
|
||||
switch (open)
|
||||
{
|
||||
case wxFile::read:
|
||||
mode = rFile::read;
|
||||
break;
|
||||
case wxFile::write:
|
||||
mode = rFile::write;
|
||||
break;
|
||||
case wxFile::read_write:
|
||||
mode = rFile::read_write;
|
||||
break;
|
||||
case wxFile::write_append:
|
||||
mode = rFile::write_append;
|
||||
break;
|
||||
case wxFile::write_excl:
|
||||
mode = rFile::write_excl;
|
||||
break;
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
wxSeekMode convertSeekMode(rSeekMode mode)
|
||||
{
|
||||
wxSeekMode ret;
|
||||
switch (mode)
|
||||
{
|
||||
case rFromStart:
|
||||
ret = wxFromStart;
|
||||
break;
|
||||
case rFromCurrent:
|
||||
ret = wxFromCurrent;
|
||||
break;
|
||||
case rFromEnd:
|
||||
ret = wxFromEnd;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
rSeekMode rConvertSeekMode(wxSeekMode mode)
|
||||
{
|
||||
rSeekMode ret;
|
||||
switch (mode)
|
||||
{
|
||||
case wxFromStart:
|
||||
ret = rFromStart;
|
||||
break;
|
||||
case wxFromCurrent:
|
||||
ret = rFromCurrent;
|
||||
break;
|
||||
case wxFromEnd:
|
||||
ret = rFromEnd;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
rFile::rFile()
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxFile());
|
||||
}
|
||||
|
||||
rFile::rFile(const std::string& filename, rFile::OpenMode open)
|
||||
{
|
||||
|
||||
handle = reinterpret_cast<void*>(new wxFile(fmt::FromUTF8(filename), convertOpenMode(open)));
|
||||
}
|
||||
|
||||
rFile::rFile(int fd)
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxFile(fd));
|
||||
}
|
||||
|
||||
rFile::~rFile()
|
||||
{
|
||||
delete reinterpret_cast<wxFile*>(handle);
|
||||
}
|
||||
|
||||
bool rFile::Access(const std::string &filename, rFile::OpenMode mode)
|
||||
{
|
||||
return wxFile::Access(fmt::FromUTF8(filename), convertOpenMode(mode));
|
||||
}
|
||||
|
||||
size_t rFile::Write(const void *buffer, size_t count)
|
||||
{
|
||||
return reinterpret_cast<wxFile*>(handle)->Write(buffer,count);
|
||||
}
|
||||
|
||||
bool rFile::Write(const std::string &text)
|
||||
{
|
||||
return reinterpret_cast<wxFile*>(handle)->Write(fmt::FromUTF8(text));
|
||||
}
|
||||
|
||||
bool rFile::Close()
|
||||
{
|
||||
return reinterpret_cast<wxFile*>(handle)->Close();
|
||||
}
|
||||
|
||||
bool rFile::Create(const std::string &filename, bool overwrite, int access)
|
||||
{
|
||||
return reinterpret_cast<wxFile*>(handle)->Create(fmt::FromUTF8(filename),overwrite,access);
|
||||
}
|
||||
|
||||
bool rFile::Open(const std::string &filename, rFile::OpenMode mode, int access)
|
||||
{
|
||||
return reinterpret_cast<wxFile*>(handle)->Open(fmt::FromUTF8(filename), convertOpenMode(mode), access);
|
||||
}
|
||||
|
||||
bool rFile::Exists(const std::string &file)
|
||||
{
|
||||
return wxFile::Exists(fmt::FromUTF8(file));
|
||||
}
|
||||
|
||||
bool rFile::IsOpened() const
|
||||
{
|
||||
return reinterpret_cast<wxFile*>(handle)->IsOpened();
|
||||
}
|
||||
|
||||
size_t rFile::Length() const
|
||||
{
|
||||
return reinterpret_cast<wxFile*>(handle)->Length();
|
||||
}
|
||||
|
||||
size_t rFile::Read(void *buffer, size_t count)
|
||||
{
|
||||
return reinterpret_cast<wxFile*>(handle)->Read(buffer,count);
|
||||
}
|
||||
|
||||
size_t rFile::Seek(size_t ofs, rSeekMode mode)
|
||||
{
|
||||
return reinterpret_cast<wxFile*>(handle)->Seek(ofs, convertSeekMode(mode));
|
||||
}
|
||||
|
||||
size_t rFile::Tell() const
|
||||
{
|
||||
return reinterpret_cast<wxFile*>(handle)->Tell();
|
||||
}
|
||||
|
||||
std::string rGetCwd()
|
||||
{
|
||||
return fmt::ToUTF8(wxGetCwd());
|
||||
}
|
||||
|
||||
bool rMkdir(const std::string &path)
|
||||
{
|
||||
return wxMkdir(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
bool rRmdir(const std::string &path)
|
||||
{
|
||||
return wxRmdir(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
bool rDirExists(const std::string &path)
|
||||
{
|
||||
return wxDirExists(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
bool rFileExists(const std::string &path)
|
||||
{
|
||||
return wxFileExists(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
bool rRemoveFile(const std::string &path)
|
||||
{
|
||||
return wxRemoveFile(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
bool rIsWritable(const std::string& path)
|
||||
{
|
||||
return wxIsWritable(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
bool rIsReadable(const std::string& path)
|
||||
{
|
||||
return wxIsReadable(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
bool rIsExecutable(const std::string& path)
|
||||
{
|
||||
return wxIsExecutable(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
rDir::rDir()
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxDir());
|
||||
}
|
||||
|
||||
rDir::~rDir()
|
||||
{
|
||||
delete reinterpret_cast<wxDir*>(handle);
|
||||
}
|
||||
|
||||
rDir::rDir(const std::string &path)
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxDir(fmt::FromUTF8(path)));
|
||||
}
|
||||
|
||||
bool rDir::Open(const std::string& path)
|
||||
{
|
||||
return reinterpret_cast<wxDir*>(handle)->Open(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
bool rDir::Exists(const std::string &path)
|
||||
{
|
||||
return wxDir::Exists(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
bool rDir::GetFirst(std::string *filename) const
|
||||
{
|
||||
wxString str;
|
||||
bool res;
|
||||
res = reinterpret_cast<wxDir*>(handle)->GetFirst(&str);
|
||||
*filename = str.ToStdString();
|
||||
return res;
|
||||
}
|
||||
|
||||
bool rDir::GetNext(std::string *filename) const
|
||||
{
|
||||
wxString str;
|
||||
bool res;
|
||||
res = reinterpret_cast<wxDir*>(handle)->GetNext(&str);
|
||||
*filename = str.ToStdString();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
rFileName::rFileName()
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxFileName());
|
||||
}
|
||||
|
||||
rFileName::~rFileName()
|
||||
{
|
||||
delete reinterpret_cast<wxFileName*>(handle);
|
||||
}
|
||||
|
||||
rFileName::rFileName(const rFileName& filename)
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxFileName(*reinterpret_cast<wxFileName*>(filename.handle)));
|
||||
}
|
||||
|
||||
|
||||
rFileName::rFileName(const std::string& name)
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxFileName(fmt::FromUTF8(name)));
|
||||
}
|
||||
|
||||
std::string rFileName::GetFullPath()
|
||||
{
|
||||
return fmt::ToUTF8(reinterpret_cast<wxFileName*>(handle)->GetFullPath());
|
||||
}
|
||||
|
||||
std::string rFileName::GetPath()
|
||||
{
|
||||
return fmt::ToUTF8(reinterpret_cast<wxFileName*>(handle)->GetPath());
|
||||
}
|
||||
|
||||
std::string rFileName::GetName()
|
||||
{
|
||||
return fmt::ToUTF8(reinterpret_cast<wxFileName*>(handle)->GetName());
|
||||
}
|
||||
|
||||
std::string rFileName::GetFullName()
|
||||
{
|
||||
return fmt::ToUTF8(reinterpret_cast<wxFileName*>(handle)->GetFullName());
|
||||
}
|
||||
|
||||
bool rFileName::Mkdir(const std::string& name, int permissions , int flags )
|
||||
{
|
||||
return wxFileName::Mkdir(fmt::FromUTF8(name), permissions, flags);
|
||||
}
|
||||
|
||||
bool rFileName::Normalize()
|
||||
{
|
||||
return reinterpret_cast<wxFileName*>(handle)->Normalize();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
extern const int rPATH_MKDIR_FULL;
|
||||
|
||||
enum rSeekMode
|
||||
{
|
||||
rFromStart,
|
||||
rFromCurrent,
|
||||
rFromEnd
|
||||
};
|
||||
|
||||
class rFile
|
||||
{
|
||||
public:
|
||||
enum OpenMode
|
||||
{
|
||||
read,
|
||||
write,
|
||||
read_write,
|
||||
write_append,
|
||||
write_excl
|
||||
};
|
||||
rFile();
|
||||
rFile(const rFile& other) = delete;
|
||||
~rFile();
|
||||
rFile(const std::string& filename, rFile::OpenMode open = rFile::read);
|
||||
rFile(int fd);
|
||||
static bool Access(const std::string &filename, rFile::OpenMode mode);
|
||||
size_t Write(const void *buffer, size_t count);
|
||||
bool Write(const std::string &text);
|
||||
bool Close();
|
||||
bool Create(const std::string &filename, bool overwrite = false, int access = 0666);
|
||||
bool Open(const std::string &filename, rFile::OpenMode mode = rFile::read, int access = 0666);
|
||||
static bool Exists(const std::string&);
|
||||
bool IsOpened() const;
|
||||
size_t Length() const;
|
||||
size_t Read(void *buffer, size_t count);
|
||||
size_t Seek(size_t ofs, rSeekMode mode = rFromStart);
|
||||
size_t Tell() const;
|
||||
|
||||
void *handle;
|
||||
};
|
||||
|
||||
std::string rGetCwd();
|
||||
bool rMkdir(const std::string &path);
|
||||
bool rRmdir(const std::string &path);
|
||||
bool rDirExists(const std::string &path);
|
||||
bool rFileExists(const std::string &path);
|
||||
bool rRemoveFile(const std::string &path);
|
||||
|
||||
bool rIsWritable(const std::string& path);
|
||||
bool rIsReadable(const std::string& path);
|
||||
bool rIsExecutable(const std::string& path);
|
||||
|
||||
struct rDir
|
||||
{
|
||||
rDir();
|
||||
~rDir();
|
||||
rDir(const rDir& other) = delete;
|
||||
rDir(const std::string &path);
|
||||
bool Open(const std::string& path);
|
||||
static bool Exists(const std::string &path);
|
||||
bool GetFirst(std::string *filename) const;
|
||||
bool GetNext(std::string *filename) const;
|
||||
|
||||
void *handle;
|
||||
};
|
||||
struct rFileName
|
||||
{
|
||||
rFileName();
|
||||
rFileName(const rFileName& other);
|
||||
~rFileName();
|
||||
rFileName(const std::string& name);
|
||||
std::string GetFullPath();
|
||||
std::string GetPath();
|
||||
std::string GetName();
|
||||
std::string GetFullName();
|
||||
static bool Mkdir(const std::string& name, int permissions=0777, int flags=0);
|
||||
bool Normalize();
|
||||
|
||||
void *handle;
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
std::string rMessageBoxCaptionStr = "Message";
|
||||
|
||||
rMessageDialog::rMessageDialog(void *parent, const std::string& msg, const std::string& title , long style )
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxMessageDialog(
|
||||
reinterpret_cast<wxWindow*>(parent)
|
||||
, fmt::FromUTF8(msg)
|
||||
, fmt::FromUTF8(title)
|
||||
, style
|
||||
));
|
||||
}
|
||||
|
||||
rMessageDialog::~rMessageDialog()
|
||||
{
|
||||
delete reinterpret_cast<wxMessageDialog*>(handle);
|
||||
}
|
||||
|
||||
long rMessageDialog::ShowModal()
|
||||
{
|
||||
return reinterpret_cast<wxMessageDialog*>(handle)->ShowModal();
|
||||
}
|
||||
|
||||
long rMessageBox(const std::string& message, const std::string& title, long style)
|
||||
{
|
||||
return wxMessageBox(fmt::FromUTF8(message), fmt::FromUTF8(title),style);
|
||||
}
|
||||
|
||||
std::string dummyApp::GetAppName()
|
||||
{
|
||||
if (handle)
|
||||
{
|
||||
return fmt::ToUTF8(reinterpret_cast<wxApp*>(handle)->GetAppName());
|
||||
}
|
||||
else
|
||||
{
|
||||
return "NULL";
|
||||
}
|
||||
}
|
||||
dummyApp::dummyApp() : handle(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
static dummyApp app;
|
||||
|
||||
dummyApp& rGetApp()
|
||||
{
|
||||
return app;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
extern std::string rMessageBoxCaptionStr;// = "Message";
|
||||
|
||||
enum MsgBoxParams : unsigned long
|
||||
{
|
||||
rOK = 0x4
|
||||
, rYES =0x2//res
|
||||
, rNO = 0x8 //res
|
||||
, rID_YES = 5103 //resDialog
|
||||
, rCANCEL = 0x10
|
||||
, rYES_NO = 0xA
|
||||
, rHELP = 0x1000
|
||||
, rNO_DEFAULT = 0x80
|
||||
, rCANCEL_DEFAULT = 0x80000000
|
||||
, rYES_DEFAULT = 0x0
|
||||
, rOK_DEFAULT = 0x0
|
||||
, rICON_NONE = 0x40000
|
||||
, rICON_EXCLAMATION = 0x100
|
||||
, rICON_ERROR = 0x200
|
||||
, rICON_HAND = 0x200
|
||||
, rICON_QUESTION = 0x400
|
||||
, rICON_INFORMATION = 0x800
|
||||
, rICON_AUTH_NEEDED = 0x80000
|
||||
, rSTAY_ON_TOP = 0x8000
|
||||
, rCENTRE = 0x1
|
||||
};
|
||||
|
||||
struct rMessageDialog
|
||||
{
|
||||
rMessageDialog(void *parent, const std::string& msg, const std::string& title = rMessageBoxCaptionStr, long style = rOK | rCENTRE);
|
||||
rMessageDialog(const rMessageDialog& other) = delete;
|
||||
~rMessageDialog();
|
||||
long ShowModal();
|
||||
void *handle;
|
||||
};
|
||||
|
||||
long rMessageBox(const std::string& message, const std::string& title,long style);
|
||||
|
||||
struct dummyApp
|
||||
{
|
||||
dummyApp();
|
||||
std::string GetAppName();
|
||||
void* handle;
|
||||
};
|
||||
|
||||
dummyApp& rGetApp();
|
||||
@@ -0,0 +1,165 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <wx/glcanvas.h>
|
||||
#include "Gui/GLGSFrame.h"
|
||||
|
||||
#include "Emu/Io/Null/NullKeyboardHandler.h"
|
||||
#include "Emu/Io/Windows/WindowsKeyboardHandler.h"
|
||||
|
||||
#include "Emu/Io/Null/NullMouseHandler.h"
|
||||
#include "Emu/Io/Windows/WindowsMouseHandler.h"
|
||||
|
||||
#include "Emu/Io/Null/NullPadHandler.h"
|
||||
#include "Emu/Io/Windows/WindowsPadHandler.h"
|
||||
|
||||
rCanvas::rCanvas(void *parent)
|
||||
{
|
||||
handle = static_cast<void*>(new wxGLCanvas(static_cast<wxWindow *>(parent),wxID_ANY,NULL));
|
||||
}
|
||||
|
||||
rCanvas::~rCanvas()
|
||||
{
|
||||
delete static_cast<wxGLCanvas*>(handle);
|
||||
}
|
||||
|
||||
//void *rCanvas::GetCurrent()
|
||||
//{
|
||||
// static_cast<wxGLCanvas*>(handle)->GetCur;
|
||||
//}
|
||||
|
||||
bool rCanvas::SetCurrent(void *ctx)
|
||||
{
|
||||
return static_cast<wxGLCanvas*>(handle)->SetCurrent(*static_cast<wxGLContext *>(ctx));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
rGLFrame::rGLFrame()
|
||||
{
|
||||
handle = static_cast<void*>(new GLGSFrame());
|
||||
}
|
||||
|
||||
rGLFrame::~rGLFrame()
|
||||
{
|
||||
delete static_cast<GLGSFrame*>(handle);
|
||||
}
|
||||
|
||||
void rGLFrame::Close()
|
||||
{
|
||||
static_cast<GLGSFrame*>(handle)->Close();
|
||||
}
|
||||
|
||||
bool rGLFrame::IsShown()
|
||||
{
|
||||
return static_cast<GLGSFrame*>(handle)->IsShown();
|
||||
}
|
||||
|
||||
void rGLFrame::Hide()
|
||||
{
|
||||
static_cast<GLGSFrame*>(handle)->Hide();
|
||||
}
|
||||
|
||||
void rGLFrame::Show()
|
||||
{
|
||||
static_cast<GLGSFrame*>(handle)->Show();
|
||||
}
|
||||
|
||||
|
||||
void *rGLFrame::GetNewContext()
|
||||
{
|
||||
return static_cast<void *>(new wxGLContext(
|
||||
static_cast<GLGSFrame*>(handle)->GetCanvas()
|
||||
));
|
||||
}
|
||||
|
||||
void rGLFrame::Flip(void *ctx)
|
||||
{
|
||||
static_cast<GLGSFrame*>(handle)->Flip(
|
||||
static_cast<wxGLContext*>(ctx));
|
||||
}
|
||||
|
||||
void rGLFrame::SetCurrent(void *ctx)
|
||||
{
|
||||
static_cast<GLGSFrame*>(handle)->GetCanvas()->SetCurrent(*static_cast<wxGLContext*>(ctx));
|
||||
}
|
||||
|
||||
|
||||
rImage::rImage()
|
||||
{
|
||||
handle = static_cast<void*>(new wxImage());
|
||||
}
|
||||
|
||||
rImage::~rImage()
|
||||
{
|
||||
delete static_cast<wxImage*>(handle);
|
||||
}
|
||||
|
||||
void rImage::Create(int width, int height, void *data, void *alpha)
|
||||
{
|
||||
static_cast<wxImage*>(handle)->Create(width, height, static_cast<unsigned char*>(data), static_cast<unsigned char*>(alpha));
|
||||
}
|
||||
void rImage::SaveFile(const std::string& name, rImageType type)
|
||||
{
|
||||
if (type == rBITMAP_TYPE_PNG)
|
||||
{
|
||||
static_cast<wxImage*>(handle)->SaveFile(fmt::FromUTF8(name),wxBITMAP_TYPE_PNG);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::string("unsupported type");
|
||||
}
|
||||
}
|
||||
|
||||
int rPlatform::getKeyboardHandlerCount()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
KeyboardHandlerBase *rPlatform::getKeyboardHandler(int i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
return new NullKeyboardHandler();
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
return new WindowsKeyboardHandler();
|
||||
}
|
||||
}
|
||||
|
||||
int rPlatform::getMouseHandlerCount()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
MouseHandlerBase *rPlatform::getMouseHandler(int i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
return new NullMouseHandler();
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
return new WindowsMouseHandler();
|
||||
}
|
||||
}
|
||||
|
||||
int rPlatform::getPadHandlerCount()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
PadHandlerBase *rPlatform::getPadHandler(int i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
return new NullPadHandler();
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
return new WindowsPadHandler();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
//struct rGLContext;
|
||||
#include "Emu/Io/Null/NullKeyboardHandler.h"
|
||||
#include "Emu/Io/Null/NullMouseHandler.h"
|
||||
#include "Emu/Io/Null/NullPadHandler.h"
|
||||
|
||||
struct rCanvas
|
||||
{
|
||||
rCanvas(void *parent);
|
||||
rCanvas(const rCanvas &) = delete;
|
||||
~rCanvas();
|
||||
/*rGLContext*/void *GetCurrent();
|
||||
bool SetCurrent(/*rGLContext &*/ void *ctx);
|
||||
|
||||
void *handle;
|
||||
};
|
||||
|
||||
//struct rGLContext
|
||||
//{
|
||||
// rGLContext();
|
||||
// rGLContext(rGLContext &) = delete;
|
||||
// rGLContext(rCanvas *canvas);
|
||||
// ~rGLContext();
|
||||
//
|
||||
// void *handle;
|
||||
//};
|
||||
|
||||
//struct rFrame
|
||||
//{
|
||||
// rFrame();
|
||||
// rFrame(rFrame &) = delete;
|
||||
// ~rFrame();
|
||||
//
|
||||
// void Close();
|
||||
// bool IsShown();
|
||||
// void Hide();
|
||||
// void Show();
|
||||
//
|
||||
// void *handle;
|
||||
//};
|
||||
|
||||
struct rGLFrame/*: public rFrame*/
|
||||
{
|
||||
rGLFrame();
|
||||
rGLFrame(const rGLFrame &) = delete;
|
||||
~rGLFrame();
|
||||
|
||||
void Close();
|
||||
bool IsShown();
|
||||
void Hide();
|
||||
void Show();
|
||||
|
||||
void *handle;
|
||||
|
||||
void SetCurrent( void *ctx);
|
||||
//rCanvas *GetCanvas();
|
||||
void *GetNewContext();
|
||||
void Flip(/*rGLContext*/void *ctx);
|
||||
};
|
||||
|
||||
struct rPlatform
|
||||
{
|
||||
rGLFrame *getGLGSFrame();
|
||||
static rPlatform &getPlatform();
|
||||
|
||||
static int getKeyboardHandlerCount();
|
||||
static KeyboardHandlerBase *getKeyboardHandler(int i);
|
||||
static int getMouseHandlerCount();
|
||||
static MouseHandlerBase *getMouseHandler(int i);
|
||||
static int getPadHandlerCount();
|
||||
static PadHandlerBase *getPadHandler(int i);
|
||||
};
|
||||
|
||||
/**********************************************************************
|
||||
*********** RSX Debugger
|
||||
************************************************************************/
|
||||
|
||||
struct RSXDebuggerProgram
|
||||
{
|
||||
u32 id;
|
||||
u32 vp_id;
|
||||
u32 fp_id;
|
||||
std::string vp_shader;
|
||||
std::string fp_shader;
|
||||
bool modified;
|
||||
|
||||
RSXDebuggerProgram()
|
||||
: modified(false)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
extern std::vector<RSXDebuggerProgram> m_debug_programs;
|
||||
|
||||
/**********************************************************************
|
||||
*********** Image stuff
|
||||
************************************************************************/
|
||||
enum rImageType
|
||||
{
|
||||
rBITMAP_TYPE_PNG
|
||||
};
|
||||
struct rImage
|
||||
{
|
||||
rImage();
|
||||
rImage(const rImage &) = delete;
|
||||
~rImage();
|
||||
void Create(int width , int height, void *data, void *alpha);
|
||||
void SaveFile(const std::string& name, rImageType type);
|
||||
|
||||
void *handle;
|
||||
};
|
||||
@@ -0,0 +1,261 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <wx/datetime.h>
|
||||
|
||||
std::string rDefaultDateTimeFormat = "%c";
|
||||
|
||||
rTimeSpan::rTimeSpan()
|
||||
{
|
||||
handle = static_cast<void *>(new wxTimeSpan());
|
||||
}
|
||||
|
||||
rTimeSpan::~rTimeSpan()
|
||||
{
|
||||
delete static_cast<wxTimeSpan*>(handle);
|
||||
}
|
||||
|
||||
rTimeSpan::rTimeSpan(const rTimeSpan& other)
|
||||
|
||||
{
|
||||
handle = static_cast<void *>(new wxTimeSpan(*static_cast<wxTimeSpan*>(other.handle)));
|
||||
|
||||
}
|
||||
|
||||
rTimeSpan::rTimeSpan(int a, int b , int c, int d)
|
||||
{
|
||||
handle = static_cast<void *>(new wxTimeSpan(a,b,c,d));
|
||||
}
|
||||
|
||||
|
||||
rDateSpan::rDateSpan()
|
||||
{
|
||||
handle = static_cast<void *>(new wxDateSpan());
|
||||
}
|
||||
|
||||
rDateSpan::~rDateSpan()
|
||||
{
|
||||
delete static_cast<wxDateSpan*>(handle);
|
||||
}
|
||||
|
||||
rDateSpan::rDateSpan(const rDateSpan& other)
|
||||
{
|
||||
handle = static_cast<void *>(new wxDateSpan(*static_cast<wxDateSpan*>(other.handle)));
|
||||
}
|
||||
|
||||
rDateSpan::rDateSpan(int a, int b, int c, int d)
|
||||
{
|
||||
handle = static_cast<void *>(new wxDateSpan(a,b,c,d));
|
||||
}
|
||||
|
||||
//enum TZ
|
||||
//{
|
||||
// Local, GMT, UTC
|
||||
//};
|
||||
//enum Calender
|
||||
//{
|
||||
// Gregorian
|
||||
//};
|
||||
|
||||
//struct rTimeZone
|
||||
//{
|
||||
// rTimeZone();
|
||||
// rTimeZone(rDateTime::TZ timezone);
|
||||
//};
|
||||
//struct WeekDay
|
||||
//{
|
||||
// WeekDay();
|
||||
// WeekDay(int a);
|
||||
//};
|
||||
//struct Month
|
||||
//{
|
||||
// Month();
|
||||
// Month(int a);
|
||||
//};
|
||||
|
||||
rDateTime::rDateTime()
|
||||
{
|
||||
handle = static_cast<void *>(new wxDateTime());
|
||||
}
|
||||
|
||||
rDateTime::~rDateTime()
|
||||
{
|
||||
delete static_cast<wxDateTime*>(handle);
|
||||
}
|
||||
|
||||
rDateTime::rDateTime(const rDateTime& other)
|
||||
{
|
||||
handle = static_cast<void *>(new wxDateTime(*static_cast<wxDateTime*>(other.handle)));
|
||||
}
|
||||
|
||||
rDateTime::rDateTime(const time_t& time)
|
||||
{
|
||||
handle = static_cast<void *>(new wxDateTime(time));
|
||||
}
|
||||
|
||||
rDateTime::rDateTime(u16 day, rDateTime::Month month, u16 year, u16 hour, u16 minute, u16 second, u32 millisecond)
|
||||
{
|
||||
handle = static_cast<void *>(new wxDateTime(day,(wxDateTime::Month)month,year,hour,minute,second,millisecond));
|
||||
}
|
||||
|
||||
rDateTime rDateTime::UNow()
|
||||
{
|
||||
rDateTime time;
|
||||
delete static_cast<wxDateTime*>(time.handle);
|
||||
time.handle = static_cast<void *>(new wxDateTime(wxDateTime::UNow()));
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
rDateTime rDateTime::FromUTC(bool val)
|
||||
{
|
||||
rDateTime time(*this);
|
||||
void *temp = time.handle;
|
||||
|
||||
time.handle = static_cast<void *>(new wxDateTime(static_cast<wxDateTime*>(temp)->FromTimezone(wxDateTime::GMT0, val)));
|
||||
delete static_cast<wxDateTime*>(temp);
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
rDateTime rDateTime::ToUTC(bool val)
|
||||
{
|
||||
rDateTime time(*this);
|
||||
void *temp = time.handle;
|
||||
|
||||
time.handle = static_cast<void *>(new wxDateTime(static_cast<wxDateTime*>(temp)->ToTimezone(wxDateTime::GMT0, val)));
|
||||
delete static_cast<wxDateTime*>(temp);
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
time_t rDateTime::GetTicks()
|
||||
{
|
||||
return static_cast<wxDateTime*>(handle)->GetTicks();
|
||||
}
|
||||
|
||||
void rDateTime::Add(const rTimeSpan& span)
|
||||
{
|
||||
static_cast<wxDateTime*>(handle)->Add(*static_cast<wxTimeSpan*>(span.handle));
|
||||
}
|
||||
|
||||
void rDateTime::Add(const rDateSpan& span)
|
||||
{
|
||||
static_cast<wxDateTime*>(handle)->Add(*static_cast<wxDateSpan*>(span.handle));
|
||||
}
|
||||
|
||||
//void rDateTime::Close()
|
||||
//{
|
||||
// static_cast<wxDateTime*>(handle)->Close();
|
||||
//}
|
||||
|
||||
wxDateTime::TimeZone convertTZ(rDateTime::rTimeZone tz)
|
||||
{
|
||||
switch (tz)
|
||||
{
|
||||
case rDateTime::Local:
|
||||
return wxDateTime::Local;
|
||||
case rDateTime::GMT0:
|
||||
return wxDateTime::GMT0;
|
||||
case rDateTime::UTC:
|
||||
return wxDateTime::UTC;
|
||||
default:
|
||||
throw std::string("WRONG DATETIME");
|
||||
}
|
||||
}
|
||||
|
||||
std::string rDateTime::Format(const std::string &format, const rTimeZone &tz) const
|
||||
{
|
||||
return fmt::ToUTF8(static_cast<wxDateTime*>(handle)->Format(fmt::FromUTF8(format),convertTZ(tz)));
|
||||
}
|
||||
|
||||
void rDateTime::ParseDateTime(const std::string & format)
|
||||
{
|
||||
/*return fmt::ToUTF8(*/static_cast<wxDateTime*>(handle)->ParseDateTime(fmt::FromUTF8(format));
|
||||
}
|
||||
|
||||
u32 rDateTime::GetAsDOS()
|
||||
{
|
||||
return static_cast<wxDateTime*>(handle)->GetAsDOS();
|
||||
}
|
||||
|
||||
rDateTime &rDateTime::SetFromDOS(u32 fromdos)
|
||||
{
|
||||
static_cast<wxDateTime*>(handle)->SetFromDOS(fromdos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool rDateTime::IsLeapYear(int year, rDateTime::Calender cal)
|
||||
{
|
||||
if (cal == Gregorian)
|
||||
{
|
||||
return wxDateTime::IsLeapYear(year, wxDateTime::Gregorian);
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxDateTime::IsLeapYear(year, wxDateTime::Julian);
|
||||
}
|
||||
}
|
||||
|
||||
int rDateTime::GetNumberOfDays(rDateTime::Month month, int year, rDateTime::Calender cal)
|
||||
{
|
||||
if (cal == Gregorian)
|
||||
{
|
||||
return wxDateTime::GetNumberOfDays(static_cast<wxDateTime::Month>(month), year, wxDateTime::Gregorian);
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxDateTime::GetNumberOfDays(static_cast<wxDateTime::Month>(month), year, wxDateTime::Julian);
|
||||
}
|
||||
}
|
||||
|
||||
void rDateTime::SetToWeekDay(rDateTime::WeekDay day, int n, rDateTime::Month month, int year)
|
||||
{
|
||||
static_cast<wxDateTime*>(handle)->SetToWeekDay(
|
||||
static_cast<wxDateTime::WeekDay>(day)
|
||||
, n
|
||||
, static_cast<wxDateTime::Month>(month)
|
||||
, year
|
||||
);
|
||||
}
|
||||
|
||||
int rDateTime::GetWeekDay()
|
||||
{
|
||||
return static_cast<wxDateTime*>(handle)->GetWeekDay();
|
||||
}
|
||||
|
||||
u16 rDateTime::GetYear(rDateTime::TZ timezone)
|
||||
{
|
||||
return static_cast<wxDateTime*>(handle)->GetYear(convertTZ(timezone));
|
||||
}
|
||||
|
||||
u16 rDateTime::GetMonth(rDateTime::TZ timezone)
|
||||
{
|
||||
return static_cast<wxDateTime*>(handle)->GetMonth(convertTZ(timezone));
|
||||
}
|
||||
|
||||
u16 rDateTime::GetDay(rDateTime::TZ timezone)
|
||||
{
|
||||
return static_cast<wxDateTime*>(handle)->GetDay(convertTZ(timezone));
|
||||
}
|
||||
|
||||
u16 rDateTime::GetHour(rDateTime::TZ timezone)
|
||||
{
|
||||
return static_cast<wxDateTime*>(handle)->GetHour(convertTZ(timezone));
|
||||
}
|
||||
|
||||
u16 rDateTime::GetMinute(rDateTime::TZ timezone)
|
||||
{
|
||||
return static_cast<wxDateTime*>(handle)->GetMinute(convertTZ(timezone));
|
||||
}
|
||||
|
||||
u16 rDateTime::GetSecond(rDateTime::TZ timezone)
|
||||
{
|
||||
return static_cast<wxDateTime*>(handle)->GetSecond(convertTZ(timezone));
|
||||
}
|
||||
|
||||
u32 rDateTime::GetMillisecond(rDateTime::TZ timezone)
|
||||
{
|
||||
return static_cast<wxDateTime*>(handle)->GetMillisecond(convertTZ(timezone));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
#pragma once
|
||||
|
||||
extern std::string rDefaultDateTimeFormat;
|
||||
|
||||
|
||||
struct rTimeSpan
|
||||
{
|
||||
rTimeSpan();
|
||||
~rTimeSpan();
|
||||
rTimeSpan(const rTimeSpan& other);
|
||||
rTimeSpan(int, int, int, int);
|
||||
|
||||
void *handle;
|
||||
};
|
||||
|
||||
struct rDateSpan
|
||||
{
|
||||
rDateSpan();
|
||||
~rDateSpan();
|
||||
rDateSpan(const rDateSpan& other);
|
||||
rDateSpan(int, int, int, int);
|
||||
|
||||
void *handle;
|
||||
};
|
||||
|
||||
struct rDateTime
|
||||
{
|
||||
enum TZ
|
||||
{
|
||||
Local, GMT0,UTC
|
||||
};
|
||||
enum Calender
|
||||
{
|
||||
Gregorian, Julian
|
||||
};
|
||||
|
||||
using rTimeZone = TZ;
|
||||
|
||||
enum WeekDay
|
||||
{
|
||||
Sun = 0,
|
||||
Mon,
|
||||
Tue,
|
||||
Wed,
|
||||
Thu,
|
||||
Fri,
|
||||
Sat,
|
||||
Inv_WeekDay
|
||||
};
|
||||
|
||||
enum Month {
|
||||
Jan = 0,
|
||||
Feb = 1,
|
||||
Mar = 2,
|
||||
Apr = 3,
|
||||
May = 4,
|
||||
Jun = 5,
|
||||
Jul = 6,
|
||||
Aug = 7,
|
||||
Sep = 8,
|
||||
Oct = 9,
|
||||
Nov = 10,
|
||||
Dec = 11,
|
||||
Inv_Month = 12
|
||||
};
|
||||
|
||||
rDateTime();
|
||||
~rDateTime();
|
||||
rDateTime(const rDateTime& other);
|
||||
rDateTime(const time_t &time);
|
||||
rDateTime(u16 day, rDateTime::Month month, u16 year, u16 hour, u16 minute, u16 second, u32 millisecond);
|
||||
|
||||
static rDateTime UNow();
|
||||
rDateTime FromUTC(bool val);
|
||||
rDateTime ToUTC(bool val);
|
||||
time_t GetTicks();
|
||||
void Add(const rTimeSpan& span);
|
||||
void Add(const rDateSpan& span);
|
||||
void Close();
|
||||
std::string Format(const std::string &format = rDefaultDateTimeFormat, const rTimeZone &tz = Local) const;
|
||||
|
||||
void ParseDateTime(const std::string & format);
|
||||
|
||||
u32 GetAsDOS();
|
||||
rDateTime &SetFromDOS(u32 fromdos);
|
||||
|
||||
static bool IsLeapYear(int year, rDateTime::Calender cal);
|
||||
static int GetNumberOfDays(rDateTime::Month month, int year, rDateTime::Calender cal);
|
||||
void SetToWeekDay(rDateTime::WeekDay day, int n, rDateTime::Month month, int year);
|
||||
int GetWeekDay();
|
||||
|
||||
u16 GetYear( rDateTime::TZ timezone);
|
||||
u16 GetMonth(rDateTime::TZ timezone);
|
||||
u16 GetDay(rDateTime::TZ timezone);
|
||||
u16 GetHour(rDateTime::TZ timezone);
|
||||
u16 GetMinute(rDateTime::TZ timezone);
|
||||
u16 GetSecond(rDateTime::TZ timezone);
|
||||
u32 GetMillisecond(rDateTime::TZ timezone);
|
||||
|
||||
void *handle;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <wx/xml/xml.h>
|
||||
|
||||
rXmlNode::rXmlNode()
|
||||
{
|
||||
ownPtr = true;
|
||||
handle = reinterpret_cast<void *>(new wxXmlNode());
|
||||
}
|
||||
|
||||
rXmlNode::rXmlNode(void *ptr)
|
||||
{
|
||||
ownPtr = false;
|
||||
handle = ptr;
|
||||
}
|
||||
|
||||
rXmlNode::rXmlNode(const rXmlNode& other)
|
||||
{
|
||||
ownPtr = true;
|
||||
handle = reinterpret_cast<void *>(new wxXmlNode(*reinterpret_cast<wxXmlNode*>(other.handle)));
|
||||
}
|
||||
|
||||
rXmlNode &rXmlNode::operator=(const rXmlNode& other)
|
||||
{
|
||||
if (ownPtr)
|
||||
{
|
||||
delete reinterpret_cast<wxXmlNode*>(handle);
|
||||
}
|
||||
handle = reinterpret_cast<void *>(new wxXmlNode(*reinterpret_cast<wxXmlNode*>(other.handle)));
|
||||
ownPtr = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
rXmlNode::~rXmlNode()
|
||||
{
|
||||
if (ownPtr)
|
||||
{
|
||||
delete reinterpret_cast<wxXmlNode*>(handle);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<rXmlNode> rXmlNode::GetChildren()
|
||||
{
|
||||
wxXmlNode* result = reinterpret_cast<wxXmlNode*>(handle)->GetChildren();
|
||||
return std::make_shared<rXmlNode>(reinterpret_cast<void*>(result));
|
||||
}
|
||||
|
||||
std::shared_ptr<rXmlNode> rXmlNode::GetNext()
|
||||
{
|
||||
wxXmlNode* result = reinterpret_cast<wxXmlNode*>(handle)->GetNext();
|
||||
return std::make_shared<rXmlNode>(reinterpret_cast<void*>(result));
|
||||
}
|
||||
|
||||
std::string rXmlNode::GetName()
|
||||
{
|
||||
return fmt::ToUTF8(reinterpret_cast<wxXmlNode*>(handle)->GetName());
|
||||
}
|
||||
|
||||
std::string rXmlNode::GetAttribute(const std::string &name)
|
||||
{
|
||||
return fmt::ToUTF8(reinterpret_cast<wxXmlNode*>(handle)->GetAttribute(fmt::FromUTF8(name)));
|
||||
}
|
||||
|
||||
std::string rXmlNode::GetNodeContent()
|
||||
{
|
||||
return fmt::ToUTF8(reinterpret_cast<wxXmlNode*>(handle)->GetNodeContent());
|
||||
}
|
||||
|
||||
rXmlDocument::rXmlDocument()
|
||||
{
|
||||
handle = reinterpret_cast<void *>(new wxXmlDocument());
|
||||
}
|
||||
|
||||
rXmlDocument::rXmlDocument(const rXmlDocument& other)
|
||||
{
|
||||
handle = reinterpret_cast<void *>(new wxXmlDocument(*reinterpret_cast<wxXmlDocument*>(other.handle)));
|
||||
}
|
||||
|
||||
rXmlDocument &rXmlDocument::operator = (const rXmlDocument& other)
|
||||
{
|
||||
delete reinterpret_cast<wxXmlDocument*>(handle);
|
||||
handle = reinterpret_cast<void *>(new wxXmlDocument(*reinterpret_cast<wxXmlDocument*>(other.handle)));
|
||||
return *this;
|
||||
}
|
||||
|
||||
rXmlDocument::~rXmlDocument()
|
||||
{
|
||||
delete reinterpret_cast<wxXmlDocument*>(handle);
|
||||
}
|
||||
|
||||
void rXmlDocument::Load(const std::string & path)
|
||||
{
|
||||
reinterpret_cast<wxXmlDocument*>(handle)->Load(fmt::FromUTF8(path));
|
||||
}
|
||||
|
||||
std::shared_ptr<rXmlNode> rXmlDocument::GetRoot()
|
||||
{
|
||||
return std::make_shared<rXmlNode>(reinterpret_cast<void*>(reinterpret_cast<wxXmlDocument*>(handle)->GetRoot()));
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
struct rXmlNode
|
||||
{
|
||||
rXmlNode();
|
||||
rXmlNode(void *);
|
||||
rXmlNode(const rXmlNode& other);
|
||||
rXmlNode &operator=(const rXmlNode& other);
|
||||
~rXmlNode();
|
||||
std::shared_ptr<rXmlNode> GetChildren();
|
||||
std::shared_ptr<rXmlNode> GetNext();
|
||||
std::string GetName();
|
||||
std::string GetAttribute( const std::string &name);
|
||||
std::string GetNodeContent();
|
||||
|
||||
void *handle;
|
||||
bool ownPtr;
|
||||
};
|
||||
|
||||
struct rXmlDocument
|
||||
{
|
||||
rXmlDocument();
|
||||
rXmlDocument(const rXmlDocument& other);
|
||||
rXmlDocument &operator=(const rXmlDocument& other);
|
||||
~rXmlDocument();
|
||||
void Load(const std::string & path);
|
||||
std::shared_ptr<rXmlNode> GetRoot();
|
||||
|
||||
void *handle;
|
||||
};
|
||||
Reference in New Issue
Block a user