aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/data.cpp4
-rw-r--r--c/data.h12
-rw-r--r--c/debug.cpp4
-rw-r--r--c/main.cpp6
-rw-r--r--c/test.cpp42
-rw-r--r--c/wcharptr.cpp2
-rw-r--r--c/win.cpp8
-rw-r--r--c/win.h4
8 files changed, 41 insertions, 41 deletions
diff --git a/c/data.cpp b/c/data.cpp
index e260209..58fcde7 100644
--- a/c/data.cpp
+++ b/c/data.cpp
@@ -16,7 +16,7 @@ struct InternetFile
INTERNET_OPEN_TYPE_DIRECT, nullptr, nullptr,
/*INTERNET_FLAG_ASYNC*/0);
if (!hi)
- throw Win32Error{};
+ throw Win32Error();
hiUrl = InternetOpenUrl(hi, url,
nullptr, 0, INTERNET_FLAG_NO_UI, 0);
@@ -39,7 +39,7 @@ struct InternetFile
if (InternetReadFile(hiUrl, buf, cb, &cbRead))
return cbRead;
else
- throw InternetError{};
+ throw InternetError();
}
HINTERNET hi;
diff --git a/c/data.h b/c/data.h
index 23c9e5f..14e8920 100644
--- a/c/data.h
+++ b/c/data.h
@@ -62,7 +62,7 @@ struct CfgA
/* Variable template for obtaining the version of a given struct. */
template <typename T>
-constexpr inline unsigned char Version = T{}.version;
+constexpr inline unsigned char Version = T().version;
template <typename T, typename = int>
constexpr inline bool HasVersion = false;
@@ -79,7 +79,7 @@ struct FileView
static FileView Initialized(const wchar_t* filename, size_t c, size_t cInit = 0)
{
bool bExisting = GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES;
- FileView fv{filename, c};
+ FileView fv(filename, c);
/* If file didn't exist, initialize it with defaults. */
if (!bExisting) {
@@ -101,9 +101,9 @@ struct FileView
hf = CreateFile(filename, GENERIC_READ|GENERIC_WRITE,
0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hf == INVALID_HANDLE_VALUE)
- throw Win32Error{};
+ throw Win32Error();
} else
- throw Win32Error{};
+ throw Win32Error();
}
LARGE_INTEGER cbMap;
@@ -111,11 +111,11 @@ struct FileView
hm = CreateFileMapping(hf, nullptr, PAGE_READWRITE,
cbMap.HighPart, cbMap.LowPart, nullptr);
if (!hm)
- throw Win32Error{};
+ throw Win32Error();
view = reinterpret_cast<T*>(MapViewOfFile(hm, FILE_MAP_ALL_ACCESS, 0, 0, 0));
if (!view)
- throw Win32Error{};
+ throw Win32Error();
}
~FileView()
diff --git a/c/debug.cpp b/c/debug.cpp
index a7f7595..e8a9d6e 100644
--- a/c/debug.cpp
+++ b/c/debug.cpp
@@ -19,13 +19,13 @@ Benchmark::Benchmark(const char* const name, const int id, const int avgmax)
{
if (!freq) {
if (!QueryPerformanceFrequency(&liFreq))
- throw Win32Error{};
+ throw Win32Error();
freq = liFreq.QuadPart;
}
LARGE_INTEGER liTicks;
if (!QueryPerformanceCounter(&liTicks))
- throw Win32Error{};
+ throw Win32Error();
ticks = liTicks.QuadPart;
}
diff --git a/c/main.cpp b/c/main.cpp
index 0e6c839..e3e2f82 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -59,8 +59,8 @@ DlvDragger g_dragDlv;
/* File views. */
FileView<CfgA> g_fvCfg = FileView<CfgA>::Initialized(L"cfg.dat", 1);
CfgA& g_cfg = g_fvCfg.At(0);
-FileView<ElvDataA> g_fvElv{L"elvdata.dat", g_cfg.cEp+128u};
-FileView<DlvDataA> g_fvDlv{L"dlvdata.dat", g_cfg.cEp+128u};
+FileView<ElvDataA> g_fvElv(L"elvdata.dat", g_cfg.cEp+128u);
+FileView<DlvDataA> g_fvDlv(L"dlvdata.dat", g_cfg.cEp+128u);
/* Optional Windows functions. */
BOOL (*IsThemeActive)();
@@ -473,7 +473,7 @@ void WaitFor(void (*f)(bool*))
* shared boolean value to true. */
bDone = false;
bActive = true;
- std::thread{f, &bDone}.detach();
+ std::thread(f, &bDone).detach();
SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), reinterpret_cast<LPARAM>(L"."));
Prefer(iTimer = SetTimer(nullptr, -1, 500, proc));
}
diff --git a/c/test.cpp b/c/test.cpp
index 7d6b3ed..a649f23 100644
--- a/c/test.cpp
+++ b/c/test.cpp
@@ -64,7 +64,7 @@ TESTS
/* Write two ElvDataA structs to disk. */
{
- FileView<ElvDataA> fv{L"tmp.dat", 2};
+ FileView<ElvDataA> fv(L"tmp.dat", 2);
memcpy(fv+0, &e1_0, sizeof(e1_0));
memcpy(fv+1, &e2_0, sizeof(e2_0));
}
@@ -72,7 +72,7 @@ TESTS
/* Read first ElvDataA struct from disk using
* ElvDataA-typed FileView. */
{
- FileView<ElvDataA> fv{L"tmp.dat", 2};
+ FileView<ElvDataA> fv(L"tmp.dat", 2);
const ElvDataA& e1 = *fv;
if (e1.version != 'a')
FAIL("version is different");
@@ -93,7 +93,7 @@ TESTS
/* Read second ElvDataA struct from disk using
* unsigned char-typed FileView. */
{
- FileView<unsigned char> fv{L"tmp.dat", 2*sizeof(ElvDataA)};
+ FileView<unsigned char> fv(L"tmp.dat", 2*sizeof(ElvDataA));
ElvDataA& e2 = *reinterpret_cast<ElvDataA*>(&fv.At(sizeof(ElvDataA)));
if (e2_0.rating != e2.rating)
FAIL("rating is different (%d/%d)", e2_0.rating, e2.rating);
@@ -118,7 +118,7 @@ TESTS
return;
{
- FileView<ElvDataA> fv{L"tmp.dat", g_cfg.cEp+128u};
+ FileView<ElvDataA> fv(L"tmp.dat", g_cfg.cEp+128u);
ElvDataA* p = fv;
for (int iEp = 1; iEp <= cEp; iEp++) {
@@ -129,7 +129,7 @@ TESTS
}
}
{
- FileView<ElvDataA> fv{L"tmp.dat", g_cfg.cEp+128u};
+ FileView<ElvDataA> fv(L"tmp.dat", g_cfg.cEp+128u);
ElvDataA& e = fv.At(9);
if (wcscmp(e.title, L"Pro Soccer Player Blackmail Case") != 0)
FAIL("title is not correct");
@@ -141,12 +141,12 @@ TESTS
{
CfgA cfg_0;
{
- FileView<CfgA> fv{L"tmp.dat", 1};
+ FileView<CfgA> fv(L"tmp.dat", 1);
Wcscpy(cfg_0.url, L"https://animixplay.to/v1/detective-conan/ep");
memcpy(fv, &cfg_0, sizeof(cfg_0));
}
{
- FileView<CfgA> fv{L"tmp.dat", 1};
+ FileView<CfgA> fv(L"tmp.dat", 1);
const CfgA& cfg = fv.At(0);
if (cfg_0.bViewWatched != cfg.bViewWatched)
FAIL("bViewWatched is different");
@@ -158,7 +158,7 @@ TESTS
// TEST(MigrateCfg)
// {
- // FileView<CfgA> fva{L"cfga.dat", 1};
+ // FileView<CfgA> fva(L"cfga.dat", 1);
// FileView<CfgB> fvb = FileView<CfgB>::Initialized(L"cfgb.dat", 1);
// fvb->bViewWatched = fva->bViewWatched;
// fvb->bViewTVOriginal = fva->bViewTVOriginal;
@@ -178,7 +178,7 @@ TESTS
return;
{
- FileView<DlvDataA> fv{L"tmp.dat", g_cfg.cEp+128u};
+ FileView<DlvDataA> fv(L"tmp.dat", g_cfg.cEp+128u);
DlvDataA* p = fv;
for (int iEp = 1; iEp <= cEp; iEp++) {
@@ -189,7 +189,7 @@ TESTS
}
}
{
- FileView<DlvDataA> fv{L"tmp.dat", g_cfg.cEp+128u};
+ FileView<DlvDataA> fv(L"tmp.dat", g_cfg.cEp+128u);
DlvDataA& e = fv.At(9);
if (wcscmp(e.date, L"March 11, 1996") != 0)
FAIL("date is not correct");
@@ -224,23 +224,23 @@ TESTS
TEST(Fetch)
{
bool bDone = false;
- std::thread{WaitFetchData, &bDone}.detach();
+ std::thread(WaitFetchData, &bDone).detach();
}
};
int RunTests()
{
const Test tests[] = {
- StrcpyWithSmallerDestination{},
- //EpisodeDataFromWeb{},
- //EpisodeDataFromProlog{},
- //IO{},
- //MigrateElvDataFromPrologToDisk{},
- //SampleConfigurationToDisk{},
- //MigrateCfg{}
- //MigrateDlvDataFromPrologToDisk{},
- //DownloadDataViaProlog{},
- //Fetch{},
+ StrcpyWithSmallerDestination(),
+ //EpisodeDataFromWeb(),
+ //EpisodeDataFromProlog(),
+ //IO(),
+ //MigrateElvDataFromPrologToDisk(),
+ //SampleConfigurationToDisk(),
+ //MigrateCfg()
+ //MigrateDlvDataFromPrologToDisk(),
+ //DownloadDataViaProlog(),
+ //Fetch(),
};
printf("Results (%llu tests):\n", sizeof(tests)/sizeof(*tests));
diff --git a/c/wcharptr.cpp b/c/wcharptr.cpp
index f7cb948..f659767 100644
--- a/c/wcharptr.cpp
+++ b/c/wcharptr.cpp
@@ -11,7 +11,7 @@ WcharPtr WcharPtr::FromNarrow(const char* const src, const int cp)
wchar_t* dst = new wchar_t[cchWide];
if (!MultiByteToWideChar(cp, 0, src, cchNarrow, dst, cchWide)) {
delete dst;
- throw Win32Error{};
+ throw Win32Error();
}
return dst;
}
diff --git a/c/win.cpp b/c/win.cpp
index 601f82c..548c951 100644
--- a/c/win.cpp
+++ b/c/win.cpp
@@ -170,7 +170,7 @@ const wchar_t* Win32Error::What() const noexcept
InternetError::InternetError(DWORD codeSystem)
{
if (codeSystem != ERROR_INTERNET_EXTENDED_ERROR)
- throw Win32Error{codeSystem};
+ throw Win32Error(codeSystem);
DWORD len, cch;
InternetGetLastResponseInfo(&code, nullptr, &len);
@@ -178,12 +178,12 @@ InternetError::InternetError(DWORD codeSystem)
cch = len+1;
m_szMsg = new char[cch];
if (!InternetGetLastResponseInfoA(&code, m_szMsg, &cch))
- throw Win32Error{};
+ throw Win32Error();
cch = len+1;
m_wszMsg = new wchar_t[cch];
if (!InternetGetLastResponseInfo(&code, m_wszMsg, &len))
- throw Win32Error{};
+ throw Win32Error();
}
InternetError::~InternetError()
@@ -216,7 +216,7 @@ Library::Library(const wchar_t* const lib)
{
m_hModule = LoadLibrary(lib);
if (!m_hModule)
- throw Win32Error{};
+ throw Win32Error();
}
Library::~Library()
diff --git a/c/win.h b/c/win.h
index f5bda59..06de198 100644
--- a/c/win.h
+++ b/c/win.h
@@ -74,7 +74,7 @@ T* Library::GetProcAddress(const char* const szProc) noexcept
template <typename T>
inline T Require(const T x)
{
- if (!x) throw Win32Error{};
+ if (!x) throw Win32Error();
return x;
}
@@ -83,7 +83,7 @@ template <typename T>
inline T Prefer(const T x)
{
if (!x) {
- EBMessageBox(Win32Error{}.What(), L"System Error", MB_ICONWARNING);
+ EBMessageBox(Win32Error().What(), L"System Error", MB_ICONWARNING);
return (T)0;
}
return x;