2009-09-08 12:08:10 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
2010-05-03 14:08:02 +00:00
|
|
|
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
2009-10-04 09:00:07 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-04-02 11:30:23 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2009-04-02 11:30:23 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-04-02 11:30:23 +00:00
|
|
|
*/
|
2009-10-04 09:00:07 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
#include <wx/gdicmn.h> // for wxPoint/wxRect stuff
|
2021-09-01 20:31:46 +00:00
|
|
|
#include "common/Pcsx2Defs.h"
|
|
|
|
#include "common/StringHelpers.h"
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
__fi wxString fromUTF8(const char* src)
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
// IMPORTANT: We cannot use wxString::FromUTF8 because it *stupidly* relies on a C++ global instance of
|
|
|
|
// wxMBConvUTF8(). C++ initializes and destroys these globals at random, so any object constructor or
|
|
|
|
// destructor that attempts to do logging may crash the app (either during startup or during exit) unless
|
|
|
|
// we use a LOCAL instance of wxMBConvUTF8(). --air
|
2010-04-27 13:12:03 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
// Performance? No worries. wxMBConvUTF8() is virtually free. Initializing a stack copy of the class
|
|
|
|
// is just as efficient as passing a pointer to a pre-instanced global. (which makes me wonder wh wxWidgets
|
|
|
|
// uses the stupid globals in the first place!) --air
|
2010-04-27 13:12:03 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return wxString(src, wxMBConvUTF8());
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 07:13:33 +00:00
|
|
|
__fi wxString fromUTF8(const std::string& str)
|
|
|
|
{
|
|
|
|
return wxString(str.data(), wxMBConvUTF8(), str.size());
|
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
__fi wxString fromAscii(const char* src)
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
return wxString::FromAscii(src);
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2010-08-31 05:14:00 +00:00
|
|
|
wxString u128::ToString() const
|
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
return pxsFmt(L"0x%08X.%08X.%08X.%08X", _u32[0], _u32[1], _u32[2], _u32[3]);
|
2010-08-31 05:14:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString u128::ToString64() const
|
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
return pxsFmt(L"0x%08X%08X.%08X%08X", _u32[0], _u32[1], _u32[2], _u32[3]);
|
2010-08-31 05:14:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString u128::ToString8() const
|
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
FastFormatUnicode result;
|
|
|
|
result.Write(L"0x%02X.%02X", _u8[0], _u8[1]);
|
|
|
|
for (uint i = 2; i < 16; i += 2)
|
|
|
|
result.Write(L".%02X.%02X", _u8[i], _u8[i + 1]);
|
|
|
|
return result;
|
2010-08-31 05:14:00 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
void u128::WriteTo(FastFormatAscii& dest) const
|
2010-08-31 05:14:00 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
dest.Write("0x%08X.%08X.%08X.%08X", _u32[0], _u32[1], _u32[2], _u32[3]);
|
2010-08-31 05:14:00 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
void u128::WriteTo64(FastFormatAscii& dest) const
|
2010-08-31 05:14:00 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
dest.Write("0x%08X%08X.%08X%08X", _u32[0], _u32[1], _u32[2], _u32[3]);
|
2010-08-31 05:14:00 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
void u128::WriteTo8(FastFormatAscii& dest) const
|
2010-08-31 05:14:00 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
dest.Write("0x%02X.%02X", _u8[0], _u8[1]);
|
|
|
|
for (uint i = 2; i < 16; i += 2)
|
|
|
|
dest.Write(".%02X.%02X", _u8[i], _u8[i + 1]);
|
2010-08-31 05:14:00 +00:00
|
|
|
}
|
|
|
|
|
2009-04-02 11:30:23 +00:00
|
|
|
// Splits a string into parts and adds the parts into the given SafeList.
|
|
|
|
// This list is not cleared, so concatenating many splits into a single large list is
|
|
|
|
// the 'default' behavior, unless you manually clear the SafeList prior to subsequent calls.
|
|
|
|
//
|
|
|
|
// Note: wxWidgets 2.9 / 3.0 has a wxSplit function, but we're using 2.8 so I had to make
|
|
|
|
// my own.
|
2021-09-06 18:28:26 +00:00
|
|
|
void SplitString(wxArrayString& dest, const wxString& src, const wxString& delims, wxStringTokenizerMode mode)
|
2009-09-16 17:23:02 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
wxStringTokenizer parts(src, delims, mode);
|
|
|
|
while (parts.HasMoreTokens())
|
|
|
|
dest.Add(parts.GetNextToken());
|
2009-09-16 17:23:02 +00:00
|
|
|
}
|
|
|
|
|
2009-04-02 11:30:23 +00:00
|
|
|
// Joins a list of strings into one larger string, using the given string concatenation
|
|
|
|
// character as a separator. If you want to be able to split the string later then the
|
|
|
|
// concatenation string needs to be a single character.
|
|
|
|
//
|
|
|
|
// Note: wxWidgets 2.9 / 3.0 has a wxJoin function, but we're using 2.8 so I had to make
|
|
|
|
// my own.
|
2021-09-06 18:28:26 +00:00
|
|
|
wxString JoinString(const wxArrayString& src, const wxString& separator)
|
2009-09-16 17:23:02 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
wxString dest;
|
|
|
|
for (int i = 0, len = src.GetCount(); i < len; ++i)
|
|
|
|
{
|
|
|
|
if (src[i].IsEmpty())
|
|
|
|
continue;
|
|
|
|
if (!dest.IsEmpty())
|
|
|
|
dest += separator;
|
|
|
|
dest += src[i];
|
|
|
|
}
|
|
|
|
return dest;
|
2010-06-30 03:21:59 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
wxString JoinString(const wxChar** src, const wxString& separator)
|
2010-06-30 03:21:59 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
wxString dest;
|
|
|
|
while (*src != NULL)
|
|
|
|
{
|
|
|
|
if (*src[0] == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!dest.IsEmpty())
|
|
|
|
dest += separator;
|
|
|
|
dest += *src;
|
|
|
|
++src;
|
|
|
|
}
|
|
|
|
return dest;
|
2009-09-16 17:23:02 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 04:58:35 +00:00
|
|
|
|
2009-04-02 11:30:23 +00:00
|
|
|
// Attempts to parse and return a value for the given template type, and throws a ParseError
|
|
|
|
// exception if the parse fails. The template type can be anything that is supported/
|
|
|
|
// implemented via one of the TryParse() method overloads.
|
|
|
|
//
|
|
|
|
// This, so far, include types such as wxPoint, wxRect, and wxSize.
|
|
|
|
//
|
2016-11-12 15:28:37 +00:00
|
|
|
template <typename T>
|
2021-09-06 18:28:26 +00:00
|
|
|
T Parse(const wxString& src, const wxString& separators = L",")
|
2009-04-02 11:30:23 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
T retval;
|
|
|
|
if (!TryParse(retval, src, separators))
|
|
|
|
throw Exception::ParseError("Parse failure on call to " + fromUTF8(__WXFUNCTION__) + ": " + src);
|
|
|
|
return retval;
|
2009-04-02 11:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-16 17:23:02 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// ToString helpers for wxString!
|
|
|
|
// --------------------------------------------------------------------------------------
|
2009-04-02 11:30:23 +00:00
|
|
|
|
|
|
|
// Converts a wxPoint into a comma-delimited string!
|
2021-09-06 18:28:26 +00:00
|
|
|
wxString ToString(const wxPoint& src, const wxString& separator)
|
2009-04-02 11:30:23 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
return wxString() << src.x << separator << src.y;
|
2009-04-02 11:30:23 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
wxString ToString(const wxSize& src, const wxString& separator)
|
2009-04-02 11:30:23 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
return wxString() << src.GetWidth() << separator << src.GetHeight();
|
2009-04-02 11:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Converts a wxRect into a comma-delimited string!
|
|
|
|
// Example: 32,64,128,5
|
2021-09-06 18:28:26 +00:00
|
|
|
wxString ToString(const wxRect& src, const wxString& separator)
|
2009-04-02 11:30:23 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
return ToString(src.GetLeftTop(), separator) << separator << ToString(src.GetSize(), separator);
|
2009-04-02 11:30:23 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 17:23:02 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// Parse helpers for wxString!
|
|
|
|
// --------------------------------------------------------------------------------------
|
2009-04-02 11:30:23 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool TryParse(wxPoint& dest, wxStringTokenizer& parts)
|
2009-04-02 11:30:23 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
long result[2];
|
2009-04-02 11:30:23 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[0]))
|
|
|
|
return false;
|
|
|
|
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[1]))
|
|
|
|
return false;
|
|
|
|
dest.x = result[0];
|
|
|
|
dest.y = result[1];
|
2009-04-02 11:30:23 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return true;
|
2009-04-02 11:30:23 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool TryParse(wxSize& dest, wxStringTokenizer& parts)
|
2009-04-02 11:30:23 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
long result[2];
|
2009-04-02 11:30:23 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[0]))
|
|
|
|
return false;
|
|
|
|
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[1]))
|
|
|
|
return false;
|
|
|
|
dest.SetWidth(result[0]);
|
|
|
|
dest.SetHeight(result[1]);
|
2009-04-02 11:30:23 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return true;
|
2009-04-02 11:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Tries to parse the given string into a wxPoint value at 'dest.' If the parse fails, the
|
|
|
|
// method aborts and returns false.
|
2021-09-06 18:28:26 +00:00
|
|
|
bool TryParse(wxPoint& dest, const wxString& src, const wxPoint& defval, const wxString& separators)
|
2009-04-02 11:30:23 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
dest = defval;
|
|
|
|
wxStringTokenizer parts(src, separators);
|
|
|
|
return TryParse(dest, parts);
|
2009-04-02 11:30:23 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool TryParse(wxSize& dest, const wxString& src, const wxSize& defval, const wxString& separators)
|
2009-04-02 11:30:23 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
dest = defval;
|
|
|
|
wxStringTokenizer parts(src, separators);
|
|
|
|
return TryParse(dest, parts);
|
2009-04-02 11:30:23 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool TryParse(wxRect& dest, const wxString& src, const wxRect& defval, const wxString& separators)
|
2009-04-02 11:30:23 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
dest = defval;
|
2009-04-02 11:30:23 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
wxStringTokenizer parts(src, separators);
|
2009-10-04 09:00:07 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
wxPoint point;
|
|
|
|
wxSize size;
|
2009-04-02 11:30:23 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
if (!TryParse(point, parts))
|
|
|
|
return false;
|
|
|
|
if (!TryParse(size, parts))
|
|
|
|
return false;
|
2009-04-02 11:30:23 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
dest = wxRect(point, size);
|
|
|
|
return true;
|
2009-04-02 11:30:23 +00:00
|
|
|
}
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
|
2010-06-09 17:37:11 +00:00
|
|
|
// returns TRUE if the parse is valid, or FALSE if it's a comment.
|
2021-09-06 18:28:26 +00:00
|
|
|
bool pxParseAssignmentString(const wxString& src, wxString& ldest, wxString& rdest)
|
2009-11-08 17:18:34 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
if (src.StartsWith(L"--") || src.StartsWith(L"//") || src.StartsWith(L";"))
|
|
|
|
return false;
|
2010-06-09 17:37:11 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
ldest = src.BeforeFirst(L'=').Trim(true).Trim(false);
|
|
|
|
rdest = src.AfterFirst(L'=').Trim(true).Trim(false);
|
2016-11-12 15:28:37 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return true;
|
2010-06-09 17:37:11 +00:00
|
|
|
}
|
2009-11-08 17:18:34 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
ParsedAssignmentString::ParsedAssignmentString(const wxString& src)
|
2010-06-09 17:37:11 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
IsComment = pxParseAssignmentString(src, lvalue, rvalue);
|
2009-11-08 17:18:34 +00:00
|
|
|
}
|
|
|
|
|
2009-10-04 09:00:07 +00:00
|
|
|
// Performs a cross-platform puts operation, which adds CRs to naked LFs on Win32 platforms,
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
// so that Notepad won't throw a fit and Rama can read the logs again! On Unix and Mac platforms,
|
|
|
|
// the input string is written unmodified.
|
|
|
|
//
|
|
|
|
// PCSX2 generally uses Unix-style newlines -- LF (\n) only -- hence there's no need to strip CRs
|
|
|
|
// from incoming data. Mac platforms may need an implementation of their own that converts
|
|
|
|
// newlines to CRs...?
|
|
|
|
//
|
2021-09-06 18:28:26 +00:00
|
|
|
void px_fputs(FILE* fp, const char* src)
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
if (fp == NULL)
|
|
|
|
return;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2021-09-06 18:28:26 +00:00
|
|
|
// Windows needs CR's partnered with all newlines, or else notepad.exe can't view
|
|
|
|
// the stupid logfile. Best way is to write one char at a time.. >_<
|
|
|
|
|
|
|
|
const char* curchar = src;
|
|
|
|
bool prevcr = false;
|
|
|
|
while (*curchar != 0)
|
|
|
|
{
|
|
|
|
if (*curchar == '\r')
|
|
|
|
{
|
|
|
|
prevcr = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Only write a CR/LF pair if the current LF is not prefixed nor
|
|
|
|
// post-fixed by a CR.
|
|
|
|
if (*curchar == '\n' && !prevcr && (*(curchar + 1) != '\r'))
|
|
|
|
fputs("\r\n", fp);
|
|
|
|
else
|
|
|
|
fputc(*curchar, fp);
|
|
|
|
|
|
|
|
prevcr = false;
|
|
|
|
}
|
|
|
|
++curchar;
|
|
|
|
}
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
|
|
|
|
#else
|
2021-09-06 18:28:26 +00:00
|
|
|
// Linux is happy with plain old LFs. Not sure about Macs... does OSX still
|
|
|
|
// go by the old school Mac style of using Crs only?
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
fputs(src, fp); // fputs does not do automatic newlines, so it's ok!
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
#endif
|
2009-10-04 09:00:07 +00:00
|
|
|
}
|