summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/bit_field.h2
-rw-r--r--src/common/common_types.h43
-rw-r--r--src/common/console_listener.h2
-rw-r--r--src/common/emu_window.h12
-rw-r--r--src/common/file_util.cpp7
-rw-r--r--src/common/log_manager.h4
-rw-r--r--src/common/string_util.cpp11
-rw-r--r--src/common/string_util.h1
-rw-r--r--src/common/swap.h1
-rw-r--r--src/common/timer.cpp7
10 files changed, 30 insertions, 60 deletions
diff --git a/src/common/bit_field.h b/src/common/bit_field.h
index b6f0179c6..9e02210f9 100644
--- a/src/common/bit_field.h
+++ b/src/common/bit_field.h
@@ -68,7 +68,7 @@
* u32 hex;
*
* BitField<0,7,u32> first_seven_bits; // unsigned
- * BitField<7,8,32> next_eight_bits; // unsigned
+ * BitField<7,8,u32> next_eight_bits; // unsigned
* BitField<3,15,s32> some_signed_fields; // signed
* };
*
diff --git a/src/common/common_types.h b/src/common/common_types.h
index 00fde828d..7ce6b2240 100644
--- a/src/common/common_types.h
+++ b/src/common/common_types.h
@@ -25,42 +25,21 @@
#pragma once
#include <cmath>
+#include <cstdint>
#include <xmmintrin.h> // data_types__m128.cpp
-#ifdef _WIN32
+typedef std::uint8_t u8; ///< 8-bit unsigned byte
+typedef std::uint16_t u16; ///< 16-bit unsigned short
+typedef std::uint32_t u32; ///< 32-bit unsigned word
+typedef std::uint64_t u64; ///< 64-bit unsigned int
-#include <tchar.h>
+typedef std::int8_t s8; ///< 8-bit signed byte
+typedef std::int16_t s16; ///< 16-bit signed short
+typedef std::int32_t s32; ///< 32-bit signed word
+typedef std::int64_t s64; ///< 64-bit signed int
-typedef unsigned __int8 u8; ///< 8-bit unsigned byte
-typedef unsigned __int16 u16; ///< 16-bit unsigned short
-typedef unsigned __int32 u32; ///< 32-bit unsigned word
-typedef unsigned __int64 u64; ///< 64-bit unsigned int
-
-typedef signed __int8 s8; ///< 8-bit signed byte
-typedef signed __int16 s16; ///< 16-bit signed short
-typedef signed __int32 s32; ///< 32-bit signed word
-typedef signed __int64 s64; ///< 64-bit signed int
-
-#else
-
-typedef unsigned char u8; ///< 8-bit unsigned byte
-typedef unsigned short u16; ///< 16-bit unsigned short
-typedef unsigned int u32; ///< 32-bit unsigned word
-typedef unsigned long long u64; ///< 64-bit unsigned int
-
-typedef signed char s8; ///< 8-bit signed byte
-typedef signed short s16; ///< 16-bit signed short
-typedef signed int s32; ///< 32-bit signed word
-typedef signed long long s64; ///< 64-bit signed int
-
-// For using windows lock code
-#define TCHAR char
-#define LONG int
-
-#endif // _WIN32
-
-typedef float f32; ///< 32-bit floating point
-typedef double f64; ///< 64-bit floating point
+typedef float f32; ///< 32-bit floating point
+typedef double f64; ///< 64-bit floating point
#include "common/common.h"
diff --git a/src/common/console_listener.h b/src/common/console_listener.h
index 3c0e420c6..ebd90a105 100644
--- a/src/common/console_listener.h
+++ b/src/common/console_listener.h
@@ -26,7 +26,7 @@ public:
#ifdef _WIN32
COORD GetCoordinates(int BytesRead, int BufferWidth);
#endif
- void Log(LogTypes::LOG_LEVELS, const char *Text);
+ void Log(LogTypes::LOG_LEVELS, const char *Text) override;
void ClearScreen(bool Cursor = true);
private:
diff --git a/src/common/emu_window.h b/src/common/emu_window.h
index 34cecb40b..4d09acb8b 100644
--- a/src/common/emu_window.h
+++ b/src/common/emu_window.h
@@ -6,7 +6,7 @@
#include "common/common.h"
#include "common/scm_rev.h"
-
+#include "common/string_util.h"
#include "common/key_map.h"
// Abstraction class used to provide an interface between emulation code and the frontend (e.g. SDL,
@@ -75,11 +75,11 @@ public:
}
protected:
- EmuWindow() : m_client_area_width(640), m_client_area_height(480) {
- char window_title[255];
- sprintf(window_title, "Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
- m_window_title = window_title;
- }
+ EmuWindow():
+ m_client_area_width(640),
+ m_client_area_height(480),
+ m_window_title(Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc))
+ {}
virtual ~EmuWindow() {}
std::string m_window_title; ///< Current window title, should be used by window impl.
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 78a642599..35da07306 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -13,6 +13,7 @@
#include <commdlg.h> // for GetSaveFileName
#include <io.h>
#include <direct.h> // getcwd
+#include <tchar.h>
#else
#include <sys/param.h>
#include <dirent.h>
@@ -190,8 +191,10 @@ bool CreateFullPath(const std::string &fullPath)
// Include the '/' so the first call is CreateDir("/") rather than CreateDir("")
std::string const subPath(fullPath.substr(0, position + 1));
- if (!FileUtil::IsDirectory(subPath))
- FileUtil::CreateDir(subPath);
+ if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) {
+ ERROR_LOG(COMMON, "CreateFullPath: directory creation failed");
+ return false;
+ }
// A safety check
panicCounter--;
diff --git a/src/common/log_manager.h b/src/common/log_manager.h
index ce62d0361..de1d16ee5 100644
--- a/src/common/log_manager.h
+++ b/src/common/log_manager.h
@@ -30,7 +30,7 @@ class FileLogListener : public LogListener
public:
FileLogListener(const char *filename);
- void Log(LogTypes::LOG_LEVELS, const char *msg);
+ void Log(LogTypes::LOG_LEVELS, const char *msg) override;
bool IsValid() { return !m_logfile.fail(); }
bool IsEnabled() const { return m_enable; }
@@ -47,7 +47,7 @@ private:
class DebuggerLogListener : public LogListener
{
public:
- void Log(LogTypes::LOG_LEVELS, const char *msg);
+ void Log(LogTypes::LOG_LEVELS, const char *msg) override;
};
class LogContainer
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 9199e30bc..61f0939c4 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -186,9 +186,9 @@ bool TryParse(const std::string &str, u32 *const output)
bool TryParse(const std::string &str, bool *const output)
{
- if ("1" == str || !strcasecmp("true", str.c_str()))
+ if ("1" == str || "true" == ToLower(str))
*output = true;
- else if ("0" == str || !strcasecmp("false", str.c_str()))
+ else if ("0" == str || "false" == ToLower(str))
*output = false;
else
return false;
@@ -196,13 +196,6 @@ bool TryParse(const std::string &str, bool *const output)
return true;
}
-std::string StringFromInt(int value)
-{
- char temp[16];
- sprintf(temp, "%i", value);
- return temp;
-}
-
std::string StringFromBool(bool value)
{
return value ? "True" : "False";
diff --git a/src/common/string_util.h b/src/common/string_util.h
index 16ce39bc1..a41ccc691 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -54,7 +54,6 @@ std::string ThousandSeparate(I value, int spaces = 0)
return oss.str();
}
-std::string StringFromInt(int value);
std::string StringFromBool(bool value);
bool TryParse(const std::string &str, bool *output);
diff --git a/src/common/swap.h b/src/common/swap.h
index 123019fd1..4f8f39efb 100644
--- a/src/common/swap.h
+++ b/src/common/swap.h
@@ -85,7 +85,6 @@ public:
return *this;
}
- operator long() const { return (long)swap(); }
operator s8() const { return (s8)swap(); }
operator u8() const { return (u8)swap(); }
operator s16() const { return (s16)swap(); }
diff --git a/src/common/timer.cpp b/src/common/timer.cpp
index f8e1fadca..ded4a344e 100644
--- a/src/common/timer.cpp
+++ b/src/common/timer.cpp
@@ -169,7 +169,6 @@ std::string Timer::GetTimeFormatted()
{
time_t sysTime;
struct tm * gmTime;
- char formattedTime[13];
char tmp[13];
time(&sysTime);
@@ -181,14 +180,12 @@ std::string Timer::GetTimeFormatted()
#ifdef _WIN32
struct timeb tp;
(void)::ftime(&tp);
- sprintf(formattedTime, "%s:%03i", tmp, tp.millitm);
+ return StringFromFormat("%s:%03i", tmp, tp.millitm);
#else
struct timeval t;
(void)gettimeofday(&t, NULL);
- sprintf(formattedTime, "%s:%03d", tmp, (int)(t.tv_usec / 1000));
+ return StringFromFormat("%s:%03d", tmp, (int)(t.tv_usec / 1000));
#endif
-
- return std::string(formattedTime);
}
// Returns a timestamp with decimals for precise time comparisons