Skip to content

Commit

Permalink
Fixed MacOS compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Segfaultd committed Apr 24, 2023
1 parent 97d73dc commit 004e4d4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ cmake_policy(SET CMP0091 NEW)

project(Framework CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")

if(FW_STANDALONE)
Expand Down
12 changes: 7 additions & 5 deletions code/framework/src/utils/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

#pragma once

#include "utils/string_utils.h"

#include <nlohmann/json.hpp>
#include <string>
#include <type_traits>

#include "utils/string_utils.h"

namespace Framework::Utils {
typedef std::conditional_t<sizeof(wchar_t) == 2, std::u16string, std::u32string> wstring;

class Config {
private:
nlohmann::json *_document;
Expand Down Expand Up @@ -47,7 +49,7 @@ namespace Framework::Utils {
T Get(const std::string &field) {
if (!_lastError.empty())
return {};
if constexpr (std::is_same<T, std::wstring>) {
if constexpr (std::is_same_v<T, std::wstring>) {
return Utils::StringUtils::NormalToWide((*_document)[field]);
}
return (*_document)[field];
Expand All @@ -59,7 +61,7 @@ namespace Framework::Utils {
return {};

try {
if constexpr (std::is_same<T, std::wstring>) {
if constexpr (std::is_same_v<T, std::wstring>) {
return Utils::StringUtils::NormalToWide((*_document)[field]);
}
return (*_document)[field];
Expand All @@ -73,7 +75,7 @@ namespace Framework::Utils {
void Set(const std::string &field, T value) {
if (!_lastError.empty())
return;
if constexpr (std::is_same<T, std::wstring>) {
if constexpr (std::is_same_v<T, std::wstring>) {
(*_document)[field] = Utils::StringUtils::WideToNormal(value);
return;
}
Expand Down
13 changes: 12 additions & 1 deletion code/framework/src/utils/path.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#include "safe_win32.h"
#include <Shlwapi.h>
#include "path.h"

#ifdef WIN32
#include <Shlwapi.h>
#endif

namespace Framework::Utils {
std::wstring GetAbsolutePathW(const std::wstring &relative) {
#ifdef WIN32
static wchar_t executable_path[MAX_PATH] = {'\0'};

if (executable_path[0] == '\0') {
Expand All @@ -19,9 +23,13 @@ namespace Framework::Utils {
wchar_t final_buf[MAX_PATH] = {'\0'};
PathCanonicalizeW(final_buf, buf);
return final_buf;
#else
return NULL;
#endif
}

std::string GetAbsolutePathA(const std::string &relative) {
#ifdef WIN32
static char executable_path[MAX_PATH] = {'\0'};

if (executable_path[0] == '\0') {
Expand All @@ -37,5 +45,8 @@ namespace Framework::Utils {
char final_buf[MAX_PATH] = {'\0'};
PathCanonicalizeA(final_buf, buf);
return final_buf;
#else
return NULL;
#endif
}
}
1 change: 0 additions & 1 deletion code/framework/src/utils/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <string>


namespace Framework::Utils {
std::wstring GetAbsolutePathW(const std::wstring &);
std::string GetAbsolutePathA(const std::string &);
Expand Down

0 comments on commit 004e4d4

Please sign in to comment.