Skip to content

Commit bfc53a7

Browse files
author
siska
committed
Remove useless constructors from instance_item
1 parent fc01812 commit bfc53a7

File tree

7 files changed

+21
-58
lines changed

7 files changed

+21
-58
lines changed

foo_np_adv/events.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "stdafx.h"
22

3+
34
CEvents *IEvents::m_Events = nullptr;
45
static std::map<pfc::string8, instance_state> c_instst;
56

foo_np_adv/events.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#pragma once
22

33
#include "prefs_instance.h"
4-
#include "event_enums.h"
5-
#include "datetime.h"
64

75
#include <map>
86
#include <vector>
9-
#include <string>
107

118
static std::map<int, std::vector<pfc::string8>> _evtostr = {
129
{EVENT_PLAYBACK_STARTING, {"Playback start","Trigger when playback starts"}},

foo_np_adv/jsoncpp.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ license you like.
7171

7272
#include "stdafx.h"
7373

74-
#include "json/json.h"
75-
7674
#ifndef JSON_IS_AMALGAMATION
7775
#error "Compile with -I PATH_TO_JSON_DIRECTORY"
7876
#endif

foo_np_adv/preferences.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "stdafx.h"
22

33
#include <fstream>
4+
#include <algorithm>
45

56
using namespace std;
67

@@ -227,8 +228,7 @@ void CNPAPreferences::OnBnClickedAdd(UINT, int, CWindow)
227228
return;
228229
}
229230

230-
instance_item item(pfc::string8(CT2CA(str)), "", "", false,
231-
false, false, 0, {}, false, "", ENCODING_UTF8, false, false);
231+
instance_item item((const char *) CT2CA(str));
232232
g_cfg_instance_list.add_item(item);
233233
m_ComboBoxInstance.InsertString(m_ComboBoxInstance.GetCount(), str);
234234
ComboInstanceSelect(m_ComboBoxInstance.GetCount() - 1);
@@ -270,13 +270,11 @@ void CNPAPreferences::OnBnClickedRename(UINT, int, CWindow)
270270
instance_item &item = g_cfg_instance_list.get_item(m_curIndex);
271271
item.name = pfc::string8(CT2CA(str));
272272
g_cfg_instance_list.replace_item(m_curIndex, item);
273-
274273
IEvents::UpdateInstance(item);
275274

276275
m_ComboBoxInstance.DeleteString(m_curIndex);
277276
m_ComboBoxInstance.InsertString(m_curIndex, str);
278277
OnComboTextChange(0, IDC_COMBO1, m_ComboBoxInstance);
279-
280278
}
281279

282280
bool CNPAPreferences::HasComboString(CString &ls) {

foo_np_adv/preferences.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
typedef struct fn_filter_s {
1010
pfc::string8 ext, desc;
11-
fn_filter_s(pfc::string8 p_ext, pfc::string8 p_desc) : ext(p_ext), desc(p_desc) {}
11+
fn_filter_s(const char *p_ext,const char *p_desc) : ext(p_ext), desc(p_desc) {}
1212
}fn_filter;
1313

1414
class CNPAPreferences : public CDialogImpl<CNPAPreferences>,

foo_np_adv/prefs_instance.h

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
#pragma once
22

33
#include "event_enums.h"
4+
#include "writer_flags.h"
5+
46
#include "json/json.h"
57

68
typedef struct instance_item_s {
79
pfc::string8 name;
810
pfc::string8 filename;
911
pfc::string8 format_string;
10-
bool write_to_file;
11-
bool log_mode;
12-
bool enable_delay;
12+
bool write_to_file = false;
13+
bool log_mode = false;
14+
bool enable_delay = false;
1315
uint32_t delay = 0;
1416
bool events[EVENT_COUNT];
15-
bool on_exit;
17+
bool on_exit = false;
1618
pfc::string8 on_exit_str;
17-
uint8_t encoding;
18-
bool changes_only;
19-
bool clipboard;
19+
uint8_t encoding = ENCODING_UTF8;
20+
bool changes_only = false;
21+
bool clipboard = false;
2022
bool _breserved2 = false;
2123
bool _breserved3 = false;
2224
bool _breserved4 = false;
@@ -29,43 +31,10 @@ typedef struct instance_item_s {
2931
pfc::string8 _sreserved3;
3032
pfc::string8 _sreserved4;
3133

32-
instance_item_s(const char * p_name, const char * p_filename, const char * p_format_string,
33-
const bool p_write_to_file, const bool p_log_mode, const bool p_enable_delay, const uint32_t p_delay,
34-
const bool(&p_events)[EVENT_COUNT], const bool p_on_exit, const char *p_on_exit_str, const uint8_t p_encoding,
35-
const bool p_changes_only, const bool p_clipboard)
36-
: name(p_name), filename(p_filename), format_string(p_format_string), log_mode(p_log_mode),
37-
enable_delay(p_enable_delay), delay(p_delay), on_exit(p_on_exit), on_exit_str(p_on_exit_str),
38-
encoding(p_encoding), changes_only(p_changes_only), clipboard(p_clipboard)
39-
{
40-
for (uint32_t i = 0; i < EVENT_COUNT; i++) {
41-
events[i] = p_events[i];
42-
pfc::string_formatter str;
43-
console::print(str << p_events[i]);
44-
}
45-
}
46-
instance_item_s(const char * p_name, const char * p_filename, const char * p_format_string, const bool p_write_to_file,
47-
const bool p_log_mode, const bool p_enable_delay, const uint32_t p_delay, const std::initializer_list <uint32_t> p_events,
48-
const bool p_on_exit, const char *p_on_exit_str, const uint8_t p_encoding, const bool p_changes_only,
49-
const bool p_clipboard)
50-
: name(p_name), filename(p_filename), format_string(p_format_string), log_mode(p_log_mode),
51-
enable_delay(p_enable_delay), delay(p_delay), write_to_file(p_write_to_file), on_exit(p_on_exit),
52-
on_exit_str(p_on_exit_str), encoding(p_encoding), changes_only(p_changes_only), clipboard(p_clipboard)
53-
{
34+
instance_item_s(const char *p_name) : name(p_name) {
5435
reset_events();
55-
56-
for (auto f : p_events) {
57-
if (f >= EVENT_COUNT) {
58-
pfc::string_formatter str;
59-
console::info(str << "WARNING: got invalid event during 'instance_item_s' initialization: " << f);
60-
}
61-
else {
62-
events[f] = true;
63-
}
64-
}
6536
}
6637
instance_item_s(Json::Value &p_data) {
67-
68-
6938
if (!p_data["name"].isString()) {
7039
throw std::invalid_argument("'name' expected type string");
7140
}

foo_np_adv/stdafx.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
#include "../foobar2000_sdk/foobar2000/ATLHelpers/ATLHelpersLean.h"
42
#include "../foobar2000_sdk/foobar2000/helpers/helpers.h"
53
#include "../foobar2000_sdk/foobar2000/ATLHelpers/WTL-PP.h"
@@ -9,11 +7,13 @@
97

108
#define COMMON_NAME "Now Playing Advanced"
119

12-
#include "datetime.h"
1310
#include "event_enums.h"
14-
#include "events.h"
15-
#include "prefs_instance.h"
16-
#include "preferences.h"
17-
#include "queue.h"
1811
#include "writer_flags.h"
12+
#include "queue.h"
13+
#include "datetime.h"
14+
#include "prefs_instance.h"
15+
#include "events.h"
1916
#include "writer.h"
17+
#include "preferences.h"
18+
19+

0 commit comments

Comments
 (0)