summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-02-20 23:06:59 +0100
committerCarl Hetherington <cth@carlh.net>2025-02-22 23:05:14 +0100
commitb29a0f4bc67f6f8cc84c3d88cdbb9582e35d3fed (patch)
tree8e518d1300e96ea7385c84a490015bf54ad998d6 /src
parent674b74173d2d0ec8e178fa0938a4c48c2863c38b (diff)
Return std::vector instead of boost::optional from the EditableList dialog.
It's a bit clumsy, as returning more than one thing only makes sense when adding (not when editing), but allowing both optional and vector with template voodoo seems awkward (at least with C++11).
Diffstat (limited to 'src')
-rw-r--r--src/tools/dcpomatic_combiner.cc4
-rw-r--r--src/tools/dcpomatic_disk.cc4
-rw-r--r--src/tools/dcpomatic_editor.cc4
-rw-r--r--src/wx/content_version_dialog.cc5
-rw-r--r--src/wx/content_version_dialog.h2
-rw-r--r--src/wx/editable_list.h24
-rw-r--r--src/wx/email_dialog.cc10
-rw-r--r--src/wx/email_dialog.h2
-rw-r--r--src/wx/rating_dialog.cc4
-rw-r--r--src/wx/rating_dialog.h2
-rw-r--r--src/wx/screen_dialog.cc6
-rw-r--r--src/wx/server_dialog.cc12
-rw-r--r--src/wx/server_dialog.h2
13 files changed, 43 insertions, 38 deletions
diff --git a/src/tools/dcpomatic_combiner.cc b/src/tools/dcpomatic_combiner.cc
index 890f01ad0..78edc0795 100644
--- a/src/tools/dcpomatic_combiner.cc
+++ b/src/tools/dcpomatic_combiner.cc
@@ -74,9 +74,9 @@ public:
return DirDialog::show() ? wxID_OK : wxID_CANCEL;
}
- optional<boost::filesystem::path> get () const
+ vector<boost::filesystem::path> get() const
{
- return path();
+ return { path() };
}
void set (boost::filesystem::path)
diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc
index ab603ccad..b9645a7ca 100644
--- a/src/tools/dcpomatic_disk.cc
+++ b/src/tools/dcpomatic_disk.cc
@@ -85,7 +85,7 @@ public:
}
- boost::optional<boost::filesystem::path> get () const
+ vector<boost::filesystem::path> get() const
{
auto const dcp = boost::filesystem::path(wx_to_std(GetPath()));
if (!dcp::filesystem::exists(dcp / "ASSETMAP") && !dcp::filesystem::exists(dcp / "ASSETMAP.xml")) {
@@ -93,7 +93,7 @@ public:
return {};
}
- return dcp;
+ return { dcp };
}
void set (boost::filesystem::path)
diff --git a/src/tools/dcpomatic_editor.cc b/src/tools/dcpomatic_editor.cc
index 2f86851c8..1e0d5672d 100644
--- a/src/tools/dcpomatic_editor.cc
+++ b/src/tools/dcpomatic_editor.cc
@@ -158,8 +158,8 @@ public:
SetSizerAndFit(_sizer);
}
- optional<shared_ptr<dcp::Reel>> get() {
- return _reel;
+ vector<shared_ptr<dcp::Reel>> get() {
+ return { _reel };
}
void set(shared_ptr<dcp::Reel> reel)
diff --git a/src/wx/content_version_dialog.cc b/src/wx/content_version_dialog.cc
index 876f43838..bf94e1e53 100644
--- a/src/wx/content_version_dialog.cc
+++ b/src/wx/content_version_dialog.cc
@@ -24,6 +24,7 @@
using std::string;
+using std::vector;
using boost::optional;
@@ -47,8 +48,8 @@ ContentVersionDialog::set (string r)
}
-optional<string>
+vector<string>
ContentVersionDialog::get () const
{
- return wx_to_std(_version->GetValue());
+ return { wx_to_std(_version->GetValue()) };
}
diff --git a/src/wx/content_version_dialog.h b/src/wx/content_version_dialog.h
index 8407c0475..aec235411 100644
--- a/src/wx/content_version_dialog.h
+++ b/src/wx/content_version_dialog.h
@@ -30,7 +30,7 @@ public:
ContentVersionDialog (wxWindow* parent);
void set (std::string);
- boost::optional<std::string> get () const;
+ std::vector<std::string> get() const;
private:
wxTextCtrl* _version;
diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h
index 0cb4c841f..f1b74b193 100644
--- a/src/wx/editable_list.h
+++ b/src/wx/editable_list.h
@@ -235,14 +235,14 @@ private:
S dialog(this);
if (dialog.ShowModal() == wxID_OK) {
- auto const v = dialog.get();
- static_assert(std::is_same<typename std::remove_const<decltype(v)>::type, boost::optional<T>>::value, "get() must return boost::optional<T>");
- if (v) {
- add_to_control (v.get ());
- auto all = _get ();
- all.push_back (v.get ());
- _set (all);
+ auto const values = dialog.get();
+ static_assert(std::is_same<typename std::remove_const<decltype(values)>::type, std::vector<T>>::value, "get() must return std::vector<T>");
+ auto all = _get();
+ for (auto item: values) {
+ add_to_control(item);
+ all.push_back(item);
}
+ _set(all);
}
}
@@ -259,13 +259,13 @@ private:
S dialog(this);
dialog.set(all[item]);
if (dialog.ShowModal() == wxID_OK) {
- auto const v = dialog.get();
- static_assert(std::is_same<typename std::remove_const<decltype(v)>::type, boost::optional<T>>::value, "get() must return boost::optional<T>");
- if (!v) {
+ auto const value = dialog.get();
+ static_assert(std::is_same<typename std::remove_const<decltype(value)>::type, std::vector<T>>::value, "get() must return std::vector<T>");
+ if (value.empty()) {
return;
}
-
- all[item] = v.get ();
+ DCPOMATIC_ASSERT(value.size() == 1);
+ all[item] = value[0];
}
for (size_t i = 0; i < _columns.size(); ++i) {
diff --git a/src/wx/email_dialog.cc b/src/wx/email_dialog.cc
index 50fa66dcc..4f33f9a5a 100644
--- a/src/wx/email_dialog.cc
+++ b/src/wx/email_dialog.cc
@@ -23,9 +23,9 @@
#include "wx_util.h"
-using std::string;
using std::shared_ptr;
-using boost::optional;
+using std::string;
+using std::vector;
EmailDialog::EmailDialog (wxWindow* parent)
@@ -47,8 +47,8 @@ EmailDialog::set (string address)
}
-optional<string>
-EmailDialog::get () const
+vector<string>
+EmailDialog::get() const
{
auto s = wx_to_std (_email->GetValue ());
if (s.empty()) {
@@ -56,5 +56,5 @@ EmailDialog::get () const
return {};
}
- return s;
+ return { s };
}
diff --git a/src/wx/email_dialog.h b/src/wx/email_dialog.h
index 3f622f87d..e613bb021 100644
--- a/src/wx/email_dialog.h
+++ b/src/wx/email_dialog.h
@@ -29,7 +29,7 @@ public:
explicit EmailDialog (wxWindow *);
void set (std::string);
- boost::optional<std::string> get () const;
+ std::vector<std::string> get() const;
private:
wxTextCtrl* _email;
diff --git a/src/wx/rating_dialog.cc b/src/wx/rating_dialog.cc
index 083c927c7..d9c432f5e 100644
--- a/src/wx/rating_dialog.cc
+++ b/src/wx/rating_dialog.cc
@@ -92,10 +92,10 @@ RatingDialog::set (dcp::Rating rating)
}
-optional<dcp::Rating>
+vector<dcp::Rating>
RatingDialog::get () const
{
- return _active_page->get();
+ return { _active_page->get() };
}
diff --git a/src/wx/rating_dialog.h b/src/wx/rating_dialog.h
index 97a56f52e..e8dfc2d9c 100644
--- a/src/wx/rating_dialog.h
+++ b/src/wx/rating_dialog.h
@@ -90,7 +90,7 @@ public:
RatingDialog (wxWindow* parent);
void set (dcp::Rating r);
- boost::optional<dcp::Rating> get () const;
+ std::vector<dcp::Rating> get() const;
private:
void setup_sensitivity (bool ok_valid);
diff --git a/src/wx/screen_dialog.cc b/src/wx/screen_dialog.cc
index d0cf499e9..21786b8a2 100644
--- a/src/wx/screen_dialog.cc
+++ b/src/wx/screen_dialog.cc
@@ -86,13 +86,13 @@ public:
setup_sensitivity();
}
- optional<TrustedDevice> get ()
+ vector<TrustedDevice> get()
{
auto const t = wx_to_std (_thumbprint->GetValue());
if (_certificate && _certificate->thumbprint() == t) {
- return TrustedDevice (*_certificate);
+ return { TrustedDevice(*_certificate) };
} else if (t.length() == 28) {
- return TrustedDevice (t);
+ return { TrustedDevice(t) };
}
return {};
diff --git a/src/wx/server_dialog.cc b/src/wx/server_dialog.cc
index ef03609ba..ffc757faa 100644
--- a/src/wx/server_dialog.cc
+++ b/src/wx/server_dialog.cc
@@ -18,14 +18,18 @@
*/
-#include "lib/encode_server.h"
+
#include "server_dialog.h"
#include "wx_util.h"
+#include "lib/encode_server.h"
+
-using std::string;
using std::shared_ptr;
+using std::string;
+using std::vector;
using boost::optional;
+
ServerDialog::ServerDialog (wxWindow* parent)
: TableDialog (parent, _("Server"), 2, 1, true)
{
@@ -51,8 +55,8 @@ ServerDialog::set (string server)
_host->SetValue (std_to_wx (server));
}
-optional<string>
+vector<string>
ServerDialog::get () const
{
- return wx_to_std (_host->GetValue ());
+ return { wx_to_std(_host->GetValue()) };
}
diff --git a/src/wx/server_dialog.h b/src/wx/server_dialog.h
index 92b417a4c..0ff032fc4 100644
--- a/src/wx/server_dialog.h
+++ b/src/wx/server_dialog.h
@@ -27,7 +27,7 @@ public:
explicit ServerDialog (wxWindow *);
void set (std::string);
- boost::optional<std::string> get () const;
+ std::vector<std::string> get() const;
private:
wxTextCtrl* _host;