Merge pull request #156 from Bigpet/wxString_exorcism

Fix static placeholder test.
This commit is contained in:
Alexandro Sánchez Bach 2014-04-01 20:30:44 +02:00
commit 4857e86cdc
4 changed files with 18 additions and 12 deletions

View file

@ -1,6 +1,9 @@
#include "stdafx.h" #include "stdafx.h"
#include "StrFmt.h" #include "StrFmt.h"
static const std::string fmt::placeholder = "???";
//wrapper to deal with advance sprintf formating options with automatic length finding //wrapper to deal with advance sprintf formating options with automatic length finding
//can't take strings by reference because of "va_start", so overload it with char * //can't take strings by reference because of "va_start", so overload it with char *
std::string fmt::FormatV(const char *fmt, va_list args) std::string fmt::FormatV(const char *fmt, va_list args)

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <string> #include <string>
#include <vector>
#include <ostream> #include <ostream>
#include <sstream> #include <sstream>
#include <cstdio> #include <cstdio>
@ -15,7 +16,7 @@ namespace fmt{
struct empty_t{}; struct empty_t{};
//static const string placeholder = "???"; extern const string placeholder;
// write `fmt` from `pos` to the first occurence of `fmt::placeholder` to // 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 // the stream `os`. Then write `arg` to to the stream. If there's no
@ -24,7 +25,7 @@ namespace fmt{
template<typename T> template<typename T>
empty_t write(const string &fmt, ostream &os, string::size_type &pos, T &&arg) empty_t write(const string &fmt, ostream &os, string::size_type &pos, T &&arg)
{ {
string::size_type ins = fmt.find(/*placeholder*/"???", pos); string::size_type ins = fmt.find(placeholder, pos);
if (ins == string::npos) if (ins == string::npos)
{ {
@ -94,14 +95,6 @@ namespace fmt{
return str; return str;
} }
//TODO:remove
//fmt alias for FormatV unused at the moment
template <typename... Args>
auto fmt(Args&&... args) -> decltype(FormatV(std::forward<Args>(parameters)...))
{
return FormatV(std::forward<Args>(args)...);
}
//convert a wxString to a std::string encoded in utf8 //convert a wxString to a std::string encoded in utf8
//CAUTION, only use this to interface with wxWidgets classes //CAUTION, only use this to interface with wxWidgets classes
std::string ToUTF8(const wxString& right); std::string ToUTF8(const wxString& right);

View file

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <algorithm>
#include "CPUInstrTable.h" #include "CPUInstrTable.h"
#pragma warning( disable : 4800 ) #pragma warning( disable : 4800 )
@ -321,7 +322,16 @@ public:
, m_args_count(args_count) , m_args_count(args_count)
, m_args(args_count ? new CodeFieldBase*[args_count] : nullptr) , m_args(args_count ? new CodeFieldBase*[args_count] : nullptr)
{ {
m_name.MakeLower().Replace("_", "."); std::transform(
name.begin(),
name.end(),
m_name.begin(),
[](const char &a)
{
char b = tolower(a);
if (b == '_') b = '.';
return b;
});
} }
__forceinline const std::string& GetName() const __forceinline const std::string& GetName() const

View file

@ -149,7 +149,7 @@ void CompilePPUProgram::WriteError(const std::string& error)
{ {
if(m_err_list) if(m_err_list)
{ {
m_err_list->WriteText(fmt::FromUTF8(fmt::Format("line %lld: %s\n", m_line, error))); m_err_list->WriteText(fmt::FromUTF8(fmt::Format("line %lld: %s\n", m_line, error.c_str())));
} }
} }