mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Clean up pointer use:
* Use unique_ptr for Actions instead of manual memory management * Use unique_ptr in KeywordDatabase * Use unique_ptr instead of shared_ptr for file formats * Don't pass shared_ptr to Reader/Writer, use references instead Also * Switch to C++17 so we can use map::try_emplace
This commit is contained in:
@@ -301,7 +301,7 @@ void ApprDistroDatabase::removeSet(const String& code) {
|
||||
// TODO ?
|
||||
}
|
||||
|
||||
void ApprDistroDatabase::doRead(InputStream& in) {
|
||||
void ApprDistroDatabase::doRead(wxInputStream& in) {
|
||||
wxTextInputStream tin(in);
|
||||
ApprDistro* last = 0;
|
||||
while (!in.Eof()) {
|
||||
|
||||
@@ -23,16 +23,16 @@
|
||||
/// Serialize an object to a string, clipboard_package will be set to the given package.
|
||||
template <typename T>
|
||||
String serialize_for_clipboard(Package& package, T& object) {
|
||||
shared_ptr<wxStringOutputStream> stream( new wxStringOutputStream );
|
||||
wxStringOutputStream stream;
|
||||
Writer writer(stream, file_version_clipboard);
|
||||
WITH_DYNAMIC_ARG(clipboard_package, &package);
|
||||
writer.handle(object);
|
||||
return stream->GetString();
|
||||
return stream.GetString();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void deserialize_from_clipboard(T& object, Package& package, const String& data) {
|
||||
shared_ptr<wxStringInputStream> stream( new wxStringInputStream(data) );
|
||||
wxStringInputStream stream = {data};
|
||||
Reader reader(stream, nullptr, _("clipboard"));
|
||||
WITH_DYNAMIC_ARG(clipboard_package, &package);
|
||||
reader.handle_greedy(object);
|
||||
|
||||
Reference in New Issue
Block a user