Skip to content

Commit 7b36b84

Browse files
committed
Don't include fmt.h in text_types.h
1 parent 958641d commit 7b36b84

40 files changed

+85
-39
lines changed

gframe/Android/COSAndroidOperator.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static inline int android_get_device_api_level() {
2020
#endif
2121
#include "COSAndroidOperator.h"
2222
#include "porting_android.h"
23+
#include "../fmt.h"
2324

2425
namespace irr {
2526

gframe/CGUISkinSystem/CGUISkinSystem.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <string>
99
#include <set>
1010
#include "../utils.h"
11+
#include "../fmt.h"
1112

1213
using namespace irr;
1314

@@ -119,7 +120,7 @@ gui::CImageGUISkin* CGUISkinSystem::loadSkinFromFile(const fschar_t *skinname) {
119120
// is to make the registry write out the root node and see what comes out.
120121
//registry->writeFile("Skin",".");
121122

122-
// To switch on the fly, we have to set the skin to the fallback skin first
123+
// To switch on the fly, we have to set the skin to the fallback skin first
123124
tmp = registry->getValueAsCStr(L"skin", L"Skin/Properties/Fallback");
124125
// Always default to metalic
125126
fallbackType = gui::EGST_WINDOWS_METALLIC;
@@ -156,7 +157,7 @@ gui::CImageGUISkin* CGUISkinSystem::loadSkinFromFile(const fschar_t *skinname) {
156157
skinConfig.CheckBoxColor = registry->getValueAsColor(L"Skin/Global/CheckBoxColor");
157158

158159
// If there was no progress bar colors set, set them in the config to the defaults
159-
// otherwise their 0,0,0,0. This is neccicary for the old klagui.
160+
// otherwise their 0,0,0,0. This is neccicary for the old klagui.
160161

161162
if(skinConfig.ProgressBarFilled.Color == 0)
162163
skinConfig.ProgressBarFilled.Color = video::SColor(255, 255, 0, 0);
@@ -380,10 +381,10 @@ bool CGUISkinSystem::applySkin(const fschar_t *skinname) {
380381
}
381382
device->getGUIEnvironment()->setSkin(skin);
382383
loaded_skin = skin;
383-
// If we're going to switch skin we need to find all the progress bars and overwrite their colors
384+
// If we're going to switch skin we need to find all the progress bars and overwrite their colors
384385
skin->drop();
385386
registry = nullptr;
386387
//fs->changeWorkingDirectoryTo(oldpath);
387388

388389
return true;
389-
}
390+
}

gframe/CGUITTFont/CGUITTFont.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <IMeshSceneNode.h>
4141
#include <unordered_set>
4242
#include <climits>
43+
#include "../fmt.h"
4344
#ifdef YGOPRO_USE_BUNDLED_FONT
4445
extern const char* bundled_font_name;
4546
extern const size_t bundled_font_len;

gframe/address.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "address.h"
33
#include "bufferio.h"
44
#include "config.h"
5+
#include "fmt.h"
56
#if EDOPRO_ANDROID
67
#include <netinet/in.h>
78
#endif
@@ -42,19 +43,17 @@ void Address::toIn6Addr(in6_addr& sin6_addr) const {
4243
memcpy(sin6_addr.s6_addr, buffer, sizeof(in6_addr::s6_addr));
4344
}
4445

45-
template<>
46-
std::basic_string<char> Address::format() const {
47-
if(family == UNK)
46+
std::string format_address(const Address& address) {
47+
if(address.family == address.UNK)
4848
return "";
4949
char ret[50]{};
50-
if(evutil_inet_ntop(family == INET ? AF_INET : AF_INET6, buffer, ret, sizeof(ret)) == nullptr)
50+
if(evutil_inet_ntop(address.family == address.INET ? AF_INET : AF_INET6, address.buffer, ret, sizeof(ret)) == nullptr)
5151
return "";
5252
return ret;
5353
}
5454

55-
template<>
56-
std::basic_string<wchar_t> Address::format() const {
57-
return BufferIO::DecodeUTF8(format<char>());
55+
std::wstring wformat_address(const Address& address) {
56+
return BufferIO::DecodeUTF8(format_address(address));
5857
}
5958

6059
bool Host::operator==(const Host& other) const {

gframe/address.h

+4-19
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include <cstdint>
55
#include <string>
6-
#include "fmt.h"
76
#include "bufferio.h"
87
#include "text_types.h"
98

@@ -16,6 +15,7 @@ namespace epro {
1615

1716
struct Address {
1817
friend struct Host;
18+
friend std::string format_address(const Address& address);
1919
private:
2020
uint8_t buffer[32]{}; //buffer big enough to store an ipv6
2121
public:
@@ -30,8 +30,6 @@ struct Address {
3030
AF family;
3131
void setIP4(const uint32_t* ip);
3232
void setIP6(const void* ip);
33-
template<typename T>
34-
std::basic_string<T> format() const;
3533
void toInAddr(in_addr& sin_addr) const;
3634
void toIn6Addr(in6_addr& sin6_addr) const;
3735
};
@@ -46,22 +44,9 @@ struct Host {
4644
static Host resolve(epro::stringview address, uint16_t port);
4745
};
4846

49-
template<>
50-
std::basic_string<char> Address::format() const;
51-
template<>
52-
std::basic_string<wchar_t> Address::format() const;
53-
}
54-
55-
template<typename T>
56-
struct fmt::formatter<epro::Address, T> {
57-
template<typename ParseContext>
58-
constexpr auto parse(ParseContext& ctx) const { return ctx.begin(); }
47+
std::string format_address(const Address&);
48+
std::wstring wformat_address(const Address&);
5949

60-
template<typename FormatContext>
61-
auto format(const epro::Address& address, FormatContext& ctx) const {
62-
static constexpr auto format_str = CHAR_T_STRINGVIEW(T, "{}");
63-
return format_to(ctx.out(), format_str, address.format<T>());
64-
}
65-
};
50+
}
6651

6752
#endif //ADDRESS_H

gframe/bufferio.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef BUFFERIO_H
22
#define BUFFERIO_H
33

4+
#include <algorithm>
45
#include <string>
56
#include <vector>
67
#include <cstring>

gframe/client_card.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "data_manager.h"
33
#include "common.h"
44
#include "client_card.h"
5+
#include "fmt.h"
56

67
namespace ygo {
78

gframe/client_field.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "CGUIImageButton/CGUIImageButton.h"
2222
#include "CGUITTFont/CGUITTFont.h"
2323
#include "custom_skin_enum.h"
24+
#include "fmt.h"
2425

2526
namespace ygo {
2627

gframe/client_updater.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "utils.h"
2121
#include "porting.h"
2222
#include "game_config.h"
23+
#include "fmt.h"
2324

2425
#define LOCKFILE EPRO_TEXT("./.edopro_lock")
2526
#define UPDATES_FOLDER EPRO_TEXT("./updates/{}")

gframe/data_handler.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "utils_gui.h"
77
#include "deck_manager.h"
88
#include "logging.h"
9+
#include "fmt.h"
910
#include "utils.h"
1011
#include "windbot.h"
1112
#include "windbot_panel.h"

gframe/data_manager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "utils.h"
99
#include "common.h"
1010
#include "file_stream.h"
11+
#include "fmt.h"
1112

1213
namespace ygo {
1314

gframe/deck_con.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "duelclient.h"
1414
#include "single_mode.h"
1515
#include "client_card.h"
16+
#include "fmt.h"
1617

1718
namespace ygo {
1819

gframe/deck_manager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "utils.h"
1010
#include "client_card.h"
1111
#include "file_stream.h"
12+
#include "fmt.h"
1213

1314
namespace ygo {
1415
const CardDataC* DeckManager::GetDummyOrMappedCardData(uint32_t code) const {

gframe/discord_wrapper.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "logging.h"
1616
#include "config.h"
1717
#include "server_lobby.h"
18+
#include "fmt.h"
1819
#endif
1920
#include "text_types.h"
2021
#include "discord_wrapper.h"

gframe/dllinterface.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "config.h"
1212
#include "dllinterface.h"
1313
#include "utils.h"
14+
#include "fmt.h"
1415

1516
#if EDOPRO_WINDOWS
1617
#define CORENAME EPRO_TEXT("ocgcore.dll")

gframe/drawing.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "CGUIImageButton/CGUIImageButton.h"
1010
#include "custom_skin_enum.h"
1111
#include "image_manager.h"
12+
#include "fmt.h"
1213

1314
namespace ygo {
1415
void Game::DrawSelectionLine(const Materials::QuadVertex vec, bool strip, int width, irr::video::SColor color) {

gframe/duelclient.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "progressivebuffer.h"
2929
#include "utils.h"
3030
#include "porting.h"
31+
#include "fmt.h"
3132

3233
#define DEFAULT_DUEL_RULE 5
3334
namespace ygo {

gframe/event_handler.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "joystick_wrapper.h"
3939
#include "porting.h"
4040
#include "config.h"
41+
#include "fmt.h"
4142

4243
namespace {
4344

gframe/fmt.h

+26-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,32 @@ struct fmt::formatter<irr::core::string<CharT, TAlloc>, CharT> {
2929
constexpr auto parse(ParseContext& ctx) { return ctx.begin(); }
3030
template <typename ParseContext>
3131
constexpr auto format(const irr::core::string<CharT, TAlloc>& s, ParseContext& ctx) const {
32-
return format_to(ctx.out(), fmt::basic_string_view{s.data(), s.size()});
32+
return format_to(ctx.out(), basic_string_view{s.data(), s.size()});
33+
}
34+
};
35+
36+
namespace epro {
37+
struct Address;
38+
std::string format_address(const Address&);
39+
std::wstring wformat_address(const Address&);
40+
}
41+
42+
template<typename T>
43+
struct fmt::formatter<epro::Address, T> {
44+
template<typename ParseContext>
45+
constexpr auto parse(ParseContext& ctx) const { return ctx.begin(); }
46+
47+
template<typename FormatContext>
48+
auto format(const epro::Address& address, FormatContext& ctx) const {
49+
static constexpr auto format_str = CHAR_T_STRINGVIEW(T, "{}");
50+
const auto formatted = [&] {
51+
if constexpr(std::is_same_v<T, wchar_t>) {
52+
return wformat_address(address);
53+
} else {
54+
return format_address(address);
55+
}
56+
}();
57+
return format_to(ctx.out(), format_str, formatted);
3358
}
3459
};
3560

gframe/game.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "CGUIWindowedTabControl/CGUIWindowedTabControl.h"
3939
#include "file_stream.h"
4040
#include "porting.h"
41+
#include "fmt.h"
4142

4243
#if EDOPRO_ANDROID || EDOPRO_IOS
4344
#include "CGUICustomComboBox/CGUICustomComboBox.h"

gframe/game_config.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "config.h"
88
#include "logging.h"
99
#include "file_stream.h"
10+
#include "fmt.h"
1011

1112
namespace ygo {
1213

gframe/gframe.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "log.h"
1818
#include "joystick_wrapper.h"
1919
#include "utils_gui.h"
20+
#include "fmt.h"
2021
#if EDOPRO_MACOS
2122
#include "osx_menu.h"
2223
#endif

gframe/iOS/COSiOSOperator.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#import <UIKit/UIPasteboard.h>
44
#include <sys/utsname.h>
5-
#include <fmt/format.h>
65
#include "../bufferio.h"
76
#include "../text_types.h"
7+
#include "../fmt.h"
88
#include "COSiOSOperator.h"
99

1010
namespace irr {

gframe/image_downloader.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "utils.h"
77
#include "game_config.h"
88
#include "file_stream.h"
9+
#include "fmt.h"
910

1011
namespace ygo {
1112

gframe/image_manager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "image_downloader.h"
1111
#include "game.h"
1212
#include "config.h"
13+
#include "fmt.h"
1314

1415
#define BASE_PATH EPRO_TEXT("./textures/")
1516

gframe/logging.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "logging.h"
22
#include <ctime>
3+
#include "fmt.h"
34
#include "file_stream.h"
45

56
namespace ygo {

gframe/logging.h

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define LOGGING_H
33

44
#include "text_types.h"
5+
#include "fmt.h"
56

67
namespace ygo {
78

gframe/menu_handler.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <IGUITable.h>
2727
#include <IGUIWindow.h>
2828
#include "address.h"
29+
#include "fmt.h"
2930

3031
namespace ygo {
3132

gframe/old_replay_mode.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "duelclient.h"
44
#include "game.h"
55
#include "single_mode.h"
6+
#include "fmt.h"
67

78
namespace ygo {
89
bool ReplayMode::ReadReplayResponse() {

gframe/replay.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "common.h"
55
#include "utils.h"
66
#include "file_stream.h"
7+
#include "fmt.h"
78

89
namespace ygo {
910
void Replay::BeginRecord(bool write, epro::path_string name) {

gframe/repo_cloner.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "repo_cloner.h"
22

33
#include "config.h"
4+
#include "fmt.h"
45
#include "game_config.h"
56
#include "porting.h"
67
#include "repo_manager.h"

gframe/repo_manager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "logging.h"
99
#include "utils.h"
1010
#include "libgit2.hpp"
11+
#include "fmt.h"
1112

1213
static constexpr int MAX_HISTORY_LENGTH = 100;
1314
static constexpr int FETCH_OBJECTS_PERCENTAGE = 60;

gframe/server_lobby.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "custom_skin_enum.h"
1818
#include "game_config.h"
1919
#include "address.h"
20+
#include "fmt.h"
2021

2122
namespace ygo {
2223

0 commit comments

Comments
 (0)