Skip to content

Commit 670ccad

Browse files
committed
Added NOMINMAX to remove windows namespace pollution.
1 parent 145b7fc commit 670ccad

File tree

4 files changed

+50
-47
lines changed

4 files changed

+50
-47
lines changed

include/frame/json/parse_json.h

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
#pragma once
2-
3-
#include <google/protobuf/util/json_util.h>
4-
5-
#include <filesystem>
6-
#include <fstream>
7-
#include <string>
8-
9-
namespace frame::proto
10-
{
11-
1+
#pragma once
2+
3+
#include <google/protobuf/util/json_util.h>
4+
5+
#include <filesystem>
6+
#include <fstream>
7+
#include <string>
8+
9+
namespace frame::proto
10+
{
11+
1212
template <typename T>
13-
T LoadProtoFromJson(const std::string& json)
14-
{
15-
T proto{};
16-
google::protobuf::util::JsonParseOptions options{};
17-
options.ignore_unknown_fields = false;
18-
auto status =
19-
google::protobuf::util::JsonStringToMessage(json, &proto, options);
20-
if (!status.ok())
21-
{
22-
throw std::runtime_error(
23-
"Couldn't parse json status error: " +
24-
status.ToString());
25-
}
26-
return proto;
27-
}
28-
29-
template <typename T>
30-
T LoadProtoFromJsonFile(const std::filesystem::path& filename)
31-
{
32-
// Empty case (no such file return an empty structure).
33-
if (filename.empty())
34-
return T{};
35-
// Try to open it.
36-
std::ifstream ifs(filename.string(), std::ios::in);
37-
if (!ifs.is_open())
38-
{
39-
throw std::runtime_error("Couldn't open file: " + filename.string());
40-
}
41-
std::string contents(std::istreambuf_iterator<char>(ifs), {});
42-
return LoadProtoFromJson<T>(contents);
43-
}
44-
45-
} // End namespace frame::proto.
13+
T LoadProtoFromJson(const std::string& json)
14+
{
15+
T proto{};
16+
google::protobuf::util::JsonParseOptions options{};
17+
options.ignore_unknown_fields = false;
18+
auto status =
19+
google::protobuf::util::JsonStringToMessage(json, &proto, options);
20+
if (!status.ok())
21+
{
22+
throw std::runtime_error(
23+
"Couldn't parse json status error: " +
24+
status.ToString());
25+
}
26+
return proto;
27+
}
28+
29+
template <typename T>
30+
T LoadProtoFromJsonFile(const std::filesystem::path& filename)
31+
{
32+
// Empty case (no such file return an empty structure).
33+
if (filename.empty())
34+
return T{};
35+
// Try to open it.
36+
std::ifstream ifs(filename.string(), std::ios::in);
37+
if (!ifs.is_open())
38+
{
39+
throw std::runtime_error("Couldn't open file: " + filename.string());
40+
}
41+
std::string contents(std::istreambuf_iterator<char>(ifs), {});
42+
return LoadProtoFromJson<T>(contents);
43+
}
44+
45+
} // End namespace frame::proto.

src/frame/opengl/sdl_opengl_none.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
2-
2+
3+
#define NOMINMAX
34
#include <GL/glew.h>
45
#include <SDL2/SDL.h>
56
#if defined(_WIN32) || defined(_WIN64)

src/frame/opengl/sdl_opengl_window.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include "frame/opengl/sdl_opengl_window.h"
22

33
// Needed under windows to get the PPI.
4-
#if defined(_WIN32) || defined(_WIN64)
4+
#if defined(_WIN32) || defined(_WIN64)
5+
#define NOMIXMAX
56
#include <shellscalingapi.h>
67
#include <shtypes.h>
78
#pragma comment(lib, "Shcore.lib")

src/frame/opengl/sdl_opengl_window.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
2-
2+
3+
#define NOMINMAX
34
#include <GL/glew.h>
45
#include <SDL2/SDL.h>
56
#if defined(_WIN32) || defined(_WIN64)

0 commit comments

Comments
 (0)