From 15ae2b0ccc5a6b74c3466c6da4c2ef682fc9810b Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 25 Apr 2014 10:01:07 -0700 Subject: [PATCH] Eliminate a bunch of explicit constructors/destructors Use explicitly defaulted destructors for base cases when possible, eliminate aggregate initialization constructors where possible, and push some more stuff to NSDMIs. --- libaegisub/ass/dialogue_parser.cpp | 4 +- libaegisub/common/cajun/elements.cpp | 6 +-- libaegisub/common/parser.cpp | 2 +- libaegisub/common/vfr.cpp | 6 +-- .../include/libaegisub/ass/dialogue_parser.h | 1 - libaegisub/include/libaegisub/cajun/reader.h | 8 ++-- libaegisub/include/libaegisub/cajun/visitor.h | 4 +- libaegisub/include/libaegisub/charset_conv.h | 2 +- libaegisub/include/libaegisub/color.h | 2 +- libaegisub/windows/fs.cpp | 3 +- src/ass_dialogue.h | 2 +- src/ass_entry.h | 2 +- src/ass_export_filter.h | 2 +- src/ass_override.cpp | 11 +----- src/audio_display.h | 2 +- src/audio_marker.h | 9 ++--- src/audio_player_dsound2.cpp | 8 +--- src/audio_renderer.h | 2 +- src/audio_timing.h | 2 +- src/audio_timing_karaoke.cpp | 2 +- src/auto4_base.h | 6 +-- src/auto4_lua.h | 2 +- src/command/command.h | 2 +- src/dialog_autosave.cpp | 4 +- src/dialog_autosave.h | 3 -- src/dialog_kara_timing_copy.cpp | 3 +- src/dialog_version_check.cpp | 18 ++++----- src/gl_text.cpp | 39 +++++++------------ src/hotkey_data_view_model.cpp | 4 +- src/include/aegisub/audio_player.h | 2 +- src/include/aegisub/audio_provider.h | 2 +- src/include/aegisub/subtitles_provider.h | 2 +- src/preferences.cpp | 3 +- src/preferences_base.cpp | 5 +-- src/search_replace_engine.cpp | 21 +++++----- src/search_replace_engine.h | 2 - src/subtitle_format.cpp | 2 - src/subtitle_format.h | 2 +- src/tooltip_manager.cpp | 30 +++----------- src/tooltip_manager.h | 16 -------- src/visual_tool.h | 2 +- src/visual_tool_clip.h | 6 +-- src/visual_tool_drag.h | 5 +-- src/visual_tool_vector_clip.h | 7 +--- 44 files changed, 91 insertions(+), 177 deletions(-) diff --git a/libaegisub/ass/dialogue_parser.cpp b/libaegisub/ass/dialogue_parser.cpp index f4bd4d300..399bf804f 100644 --- a/libaegisub/ass/dialogue_parser.cpp +++ b/libaegisub/ass/dialogue_parser.cpp @@ -38,7 +38,7 @@ class SyntaxHighlighter { if (ranges.size() && ranges.back().type == type) ranges.back().length += len; else - ranges.push_back(DialogueToken(type, len)); + ranges.push_back(DialogueToken{type, len}); } public: @@ -101,7 +101,7 @@ class WordSplitter { tokens[i].length = len; if (old.length != (size_t)len) { - tokens.insert(tokens.begin() + i + 1, DialogueToken(old.type, old.length - len)); + tokens.insert(tokens.begin() + i + 1, DialogueToken{old.type, old.length - len}); ++i; } } diff --git a/libaegisub/common/cajun/elements.cpp b/libaegisub/common/cajun/elements.cpp index 51c901c20..cfd569973 100644 --- a/libaegisub/common/cajun/elements.cpp +++ b/libaegisub/common/cajun/elements.cpp @@ -31,14 +31,12 @@ namespace { void Visit(Boolean const&) { } void Visit(Null const&) { is_null = true; } public: - bool is_null; - CastVisitorBase() : is_null(false) { } + bool is_null = false; }; template struct CastVisitor final : public CastVisitorBase { - T *element; - CastVisitor() : element(0) { } + T *element = nullptr; void Visit(T& ele) { element = &ele; } }; } diff --git a/libaegisub/common/parser.cpp b/libaegisub/common/parser.cpp index b793c5e7e..be59f853d 100644 --- a/libaegisub/common/parser.cpp +++ b/libaegisub/common/parser.cpp @@ -218,7 +218,7 @@ namespace ass { ptrdiff_t len = it->value().end() - it->value().begin(); assert(len > 0); if (data.empty() || data.back().type != id) - data.push_back(DialogueToken(id, len)); + data.push_back(DialogueToken{id, len}); else data.back().length += len; } diff --git a/libaegisub/common/vfr.cpp b/libaegisub/common/vfr.cpp index ad7d4ca09..f03947c4c 100644 --- a/libaegisub/common/vfr.cpp +++ b/libaegisub/common/vfr.cpp @@ -60,8 +60,6 @@ struct TimecodeRange { int end; double fps; bool operator<(TimecodeRange const& cmp) const { return start < cmp.start; } - TimecodeRange(int start=0, int end=0, double fps=0.) - : start(start), end(end), fps(fps) { } }; /// @brief Parse a single line of a v1 timecode file @@ -95,7 +93,7 @@ TimecodeRange v1_parse_line(std::string const& str) { void v1_fill_range_gaps(std::list &ranges, double fps) { // Range for frames between start and first override if (ranges.empty() || ranges.front().start > 0) - ranges.emplace_front(0, ranges.empty() ? 0 : ranges.front().start - 1, fps); + ranges.push_front(TimecodeRange{0, ranges.empty() ? 0 : ranges.front().start - 1, fps}); for (auto cur = ++begin(ranges), prev = begin(ranges); cur != end(ranges); ++cur, ++prev) { if (prev->end >= cur->start) @@ -103,7 +101,7 @@ void v1_fill_range_gaps(std::list &ranges, double fps) { // broken things with them throw UnorderedTimecodes("Override ranges must not overlap"); if (prev->end + 1 < cur->start) { - ranges.emplace(cur, prev->end + 1, cur->start -1, fps); + ranges.insert(cur, TimecodeRange{prev->end + 1, cur->start - 1, fps}); ++prev; } } diff --git a/libaegisub/include/libaegisub/ass/dialogue_parser.h b/libaegisub/include/libaegisub/ass/dialogue_parser.h index 10ac62685..0aa3f9962 100644 --- a/libaegisub/include/libaegisub/ass/dialogue_parser.h +++ b/libaegisub/include/libaegisub/ass/dialogue_parser.h @@ -66,7 +66,6 @@ namespace agi { struct DialogueToken { int type; size_t length; - DialogueToken(int type, size_t length) : type(type), length(length) { } }; /// Tokenize the passed string as the body of a dialogue line diff --git a/libaegisub/include/libaegisub/cajun/reader.h b/libaegisub/include/libaegisub/cajun/reader.h index 6d889be38..b181a75a7 100644 --- a/libaegisub/include/libaegisub/cajun/reader.h +++ b/libaegisub/include/libaegisub/cajun/reader.h @@ -19,11 +19,9 @@ class Reader { public: // this structure will be reported in one of the exceptions defined below struct Location { - Location() : m_nLine(0), m_nLineOffset(0), m_nDocOffset(0) { } - - unsigned int m_nLine; // document line, zero-indexed - unsigned int m_nLineOffset; // character offset from beginning of line, zero indexed - unsigned int m_nDocOffset; // character offset from entire document, zero indexed + unsigned int m_nLine = 0; // document line, zero-indexed + unsigned int m_nLineOffset = 0; // character offset from beginning of line, zero indexed + unsigned int m_nDocOffset = 0; // character offset from entire document, zero indexed }; // thrown during the first phase of reading. generally catches low-level diff --git a/libaegisub/include/libaegisub/cajun/visitor.h b/libaegisub/include/libaegisub/cajun/visitor.h index 4552f448f..b4b270ea1 100644 --- a/libaegisub/include/libaegisub/cajun/visitor.h +++ b/libaegisub/include/libaegisub/cajun/visitor.h @@ -14,7 +14,7 @@ namespace json { struct Visitor { - virtual ~Visitor() { } + virtual ~Visitor() = default; virtual void Visit(Array& array) = 0; virtual void Visit(Object& object) = 0; @@ -26,7 +26,7 @@ struct Visitor { }; struct ConstVisitor { - virtual ~ConstVisitor() { } + virtual ~ConstVisitor() = default; virtual void Visit(const Array& array) = 0; virtual void Visit(const Object& object) = 0; diff --git a/libaegisub/include/libaegisub/charset_conv.h b/libaegisub/include/libaegisub/charset_conv.h index 6de377652..d96a0c8af 100644 --- a/libaegisub/include/libaegisub/charset_conv.h +++ b/libaegisub/include/libaegisub/charset_conv.h @@ -40,7 +40,7 @@ typedef void* iconv_t; /// Helper class that abstracts away the differences between libiconv and /// POSIX iconv implementations struct Converter { - virtual ~Converter() { } + virtual ~Converter() = default; virtual size_t Convert(const char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft) = 0; }; diff --git a/libaegisub/include/libaegisub/color.h b/libaegisub/include/libaegisub/color.h index 7b415b0ea..b61b39f20 100644 --- a/libaegisub/include/libaegisub/color.h +++ b/libaegisub/include/libaegisub/color.h @@ -23,7 +23,7 @@ namespace agi { unsigned char b = 0; ///< Blue component unsigned char a = 0; ///< Alpha component - Color() { } + Color() = default; Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0); Color(std::string const& str); diff --git a/libaegisub/windows/fs.cpp b/libaegisub/windows/fs.cpp index fcfd22f69..697decb85 100644 --- a/libaegisub/windows/fs.cpp +++ b/libaegisub/windows/fs.cpp @@ -84,8 +84,7 @@ void Copy(fs::path const& from, fs::path const& to) { } struct DirectoryIterator::PrivData { - scoped_holder h; - PrivData() : h(INVALID_HANDLE_VALUE, FindClose) { } + scoped_holder h{INVALID_HANDLE_VALUE, FindClose}; }; DirectoryIterator::DirectoryIterator() { } diff --git a/src/ass_dialogue.h b/src/ass_dialogue.h index affa6809a..e9273255c 100644 --- a/src/ass_dialogue.h +++ b/src/ass_dialogue.h @@ -75,7 +75,7 @@ protected: std::string text; public: AssDialogueBlock(std::string text) : text(std::move(text)) { } - virtual ~AssDialogueBlock() { } + virtual ~AssDialogueBlock() = default; virtual AssBlockType GetType() const = 0; virtual std::string GetText() { return text; } diff --git a/src/ass_entry.h b/src/ass_entry.h index 9556ef18a..f830e0d92 100644 --- a/src/ass_entry.h +++ b/src/ass_entry.h @@ -51,7 +51,7 @@ using AssEntryListHook = boost::intrusive::make_list_base_hookname = name; - params.emplace_back(type, opt, classi); + params.push_back(AssOverrideParamProto{opt, type, classi}); } }; diff --git a/src/audio_display.h b/src/audio_display.h index cc2a77cf6..ca230382d 100644 --- a/src/audio_display.h +++ b/src/audio_display.h @@ -91,7 +91,7 @@ public: /// @brief Destructor /// /// Empty virtual destructor for the cases that need it. - virtual ~AudioDisplayInteractionObject() { } + virtual ~AudioDisplayInteractionObject() = default; }; /// @class AudioDisplay diff --git a/src/audio_marker.h b/src/audio_marker.h index fae660779..bc8f43514 100644 --- a/src/audio_marker.h +++ b/src/audio_marker.h @@ -85,7 +85,7 @@ protected: agi::signal::Signal<> AnnounceMarkerMoved; public: /// Virtual destructor, does nothing - virtual ~AudioMarkerProvider() { } + virtual ~AudioMarkerProvider() = default; /// @brief Return markers in a time range virtual void GetMarkers(const TimeRange &range, AudioMarkerVector &out) const = 0; @@ -106,11 +106,10 @@ public: wxString text; /// Range which this label applies to TimeRange range; - AudioLabel(wxString const& text, TimeRange const& range) : text(text), range(range) { } }; /// Virtual destructor, does nothing - virtual ~AudioLabelProvider() { } + virtual ~AudioLabelProvider() = default; /// @brief Get labels in a time range /// @param range Range of times to get labels for @@ -177,9 +176,9 @@ public: class SecondsMarkerProvider final : public AudioMarkerProvider { struct Marker final : public AudioMarker { Pen *style; - int position; + int position = 0; - Marker(Pen *style) : style(style), position(0) { } + Marker(Pen *style) : style(style) { } int GetPosition() const override { return position; } FeetStyle GetFeet() const override { return Feet_None; } bool CanSnap() const override { return false; } diff --git a/src/audio_player_dsound2.cpp b/src/audio_player_dsound2.cpp index b5f396e37..8d1ed3b25 100644 --- a/src/audio_player_dsound2.cpp +++ b/src/audio_player_dsound2.cpp @@ -115,13 +115,7 @@ public: struct COMInitialization { /// Flag set if an inited COM library is managed - bool inited; - - /// @brief Constructor, sets inited false - COMInitialization() - { - inited = false; - } + bool inited = false; /// @brief Destructor, de-inits COM if it is inited ~COMInitialization() diff --git a/src/audio_renderer.h b/src/audio_renderer.h index 19c8f142b..0ccd928bc 100644 --- a/src/audio_renderer.h +++ b/src/audio_renderer.h @@ -258,7 +258,7 @@ public: AudioRendererBitmapProvider() : provider(nullptr), pixel_ms(0), amplitude_scale(0) { }; /// @brief Destructor - virtual ~AudioRendererBitmapProvider() { } + virtual ~AudioRendererBitmapProvider() = default; /// @brief Rendering function /// @param bmp Bitmap to render to diff --git a/src/audio_timing.h b/src/audio_timing.h index 887903f7d..a755e3228 100644 --- a/src/audio_timing.h +++ b/src/audio_timing.h @@ -173,7 +173,7 @@ public: virtual void OnMarkerDrag(std::vector const& marker, int new_position, int snap_range) = 0; /// @brief Destructor - virtual ~AudioTimingController() { } + virtual ~AudioTimingController() = default; DEFINE_SIGNAL_ADDERS(AnnounceUpdatedPrimaryRange, AddUpdatedPrimaryRangeListener) DEFINE_SIGNAL_ADDERS(AnnounceUpdatedStyleRanges, AddUpdatedStyleRangesListener) diff --git a/src/audio_timing_karaoke.cpp b/src/audio_timing_karaoke.cpp index 4f5ed8314..5eb994eab 100644 --- a/src/audio_timing_karaoke.cpp +++ b/src/audio_timing_karaoke.cpp @@ -286,7 +286,7 @@ void AudioTimingControllerKaraoke::Revert() { for (auto it = kara->begin(); it != kara->end(); ++it) { if (it != kara->begin()) markers.emplace_back(it->start_time, &separator_pen, AudioMarker::Feet_None); - labels.emplace_back(to_wx(it->text), TimeRange(it->start_time, it->start_time + it->duration)); + labels.push_back(AudioLabel{to_wx(it->text), TimeRange(it->start_time, it->start_time + it->duration)}); } AnnounceUpdatedPrimaryRange(); diff --git a/src/auto4_base.h b/src/auto4_base.h index da71c5eb6..6b53bdb89 100644 --- a/src/auto4_base.h +++ b/src/auto4_base.h @@ -90,7 +90,7 @@ namespace Automation4 { /// panel class ScriptDialog { public: - virtual ~ScriptDialog() { } + virtual ~ScriptDialog() = default; /// Create a window with the given parent virtual wxWindow *CreateWindow(wxWindow *parent) = 0; @@ -155,7 +155,7 @@ namespace Automation4 { Script(agi::fs::path const& filename); public: - virtual ~Script() { } + virtual ~Script() = default; /// Reload this script virtual void Reload() = 0; @@ -253,7 +253,7 @@ namespace Automation4 { ScriptFactory(std::string engine_name, std::string filename_pattern); public: - virtual ~ScriptFactory() { } + virtual ~ScriptFactory() = default; /// Name of this automation engine const std::string& GetEngineName() const { return engine_name; } diff --git a/src/auto4_lua.h b/src/auto4_lua.h index 172fba4b7..c629bd3a2 100644 --- a/src/auto4_lua.h +++ b/src/auto4_lua.h @@ -196,7 +196,7 @@ namespace Automation4 { LuaDialogControl(lua_State *L); /// Virtual destructor so this can safely be inherited from - virtual ~LuaDialogControl() { } + virtual ~LuaDialogControl() = default; }; /// A lua-generated dialog or panel in the export options dialog diff --git a/src/command/command.h b/src/command/command.h index b43ba7bec..e6ff83a14 100644 --- a/src/command/command.h +++ b/src/command/command.h @@ -136,7 +136,7 @@ DEFINE_SIMPLE_EXCEPTION_NOINNER(CommandNotFound, CommandError, "command/notfound virtual bool IsActive(const agi::Context *c) { return false; } /// Destructor - virtual ~Command() { }; + virtual ~Command() = default; }; /// Init all builtin commands. diff --git a/src/dialog_autosave.cpp b/src/dialog_autosave.cpp index 30f0dd639..25df63304 100644 --- a/src/dialog_autosave.cpp +++ b/src/dialog_autosave.cpp @@ -114,8 +114,8 @@ void DialogAutosave::Populate(std::map &files_map, std:: auto it = files_map.find(name); if (it == files_map.end()) - it = files_map.insert(std::make_pair(name, name)).first; - it->second.versions.emplace_back(wxFileName(directory, fn).GetFullPath(), date, wxString::Format(name_fmt, date.Format())); + it = files_map.insert(std::make_pair(name, AutosaveFile{name})).first; + it->second.versions.push_back(Version{wxFileName(directory, fn).GetFullPath(), date, wxString::Format(name_fmt, date.Format())}); } while (dir.GetNext(&fn)); } diff --git a/src/dialog_autosave.h b/src/dialog_autosave.h index cc5969f3f..1581c9ba6 100644 --- a/src/dialog_autosave.h +++ b/src/dialog_autosave.h @@ -29,14 +29,11 @@ class DialogAutosave final : public wxDialog { wxString filename; wxDateTime date; wxString display; - Version(wxString const& filename, wxDateTime date, wxString const& display) - : filename(filename), date(std::move(date)), display(display) { } }; struct AutosaveFile { wxString name; std::vector versions; - AutosaveFile(wxString const& name) : name(name) { } }; std::vector files; diff --git a/src/dialog_kara_timing_copy.cpp b/src/dialog_kara_timing_copy.cpp index 5c903f8ce..f5f1660f1 100644 --- a/src/dialog_kara_timing_copy.cpp +++ b/src/dialog_kara_timing_copy.cpp @@ -73,8 +73,7 @@ class KaraokeLineMatchDisplay final : public wxControl { struct MatchGroup { std::vector src; std::string dst; - int last_render_width; - MatchGroup() : last_render_width(0) { } + int last_render_width = 0; }; std::vector matched_groups; diff --git a/src/dialog_version_check.cpp b/src/dialog_version_check.cpp index 050ce085a..e3247d500 100644 --- a/src/dialog_version_check.cpp +++ b/src/dialog_version_check.cpp @@ -86,9 +86,6 @@ struct AegisubUpdateDescription { std::string url; std::string friendly_name; std::string description; - - AegisubUpdateDescription(std::string url, std::string friendly_name, std::string description) - : url(std::move(url)), friendly_name(std::move(friendly_name)), description(std::move(description)) { } }; class VersionCheckerResultDialog final : public wxDialog { @@ -340,16 +337,15 @@ void DoCheck(bool interactive) { boost::split(parsed, line, boost::is_any_of("|")); if (parsed.size() != 6) continue; - // 0 and 2 being things that never got used - std::string revision = parsed[1]; - std::string url = inline_string_decode(parsed[3]); - std::string friendlyname = inline_string_decode(parsed[4]); - std::string description = inline_string_decode(parsed[5]); - - if (atoi(revision.c_str()) <= GetSVNRevision()) + if (atoi(parsed[1].c_str()) <= GetSVNRevision()) continue; - results.emplace_back(url, friendlyname, description); + // 0 and 2 being things that never got used + results.push_back(AegisubUpdateDescription{ + inline_string_decode(parsed[3]), + inline_string_decode(parsed[4]), + inline_string_decode(parsed[5]) + }); } if (!results.empty() || interactive) { diff --git a/src/gl_text.cpp b/src/gl_text.cpp index 48c6bfa1c..22e2f4ae3 100644 --- a/src/gl_text.cpp +++ b/src/gl_text.cpp @@ -56,22 +56,17 @@ namespace { /// @brief Struct storing the information needed to draw a glyph struct OpenGLTextGlyph { wxString str; ///< String containing the glyph(s) this is for - int tex; ///< OpenGL texture to draw for this glyph - float x1; ///< Left x coordinate of this glyph in the containing texture - float x2; ///< Right x coordinate of this glyph in the containing texture - float y1; ///< Left y coordinate of this glyph in the containing texture - float y2; ///< Right y coordinate of this glyph in the containing texture - int w; ///< Width of the glyph in pixels - int h; ///< Height of the glyph in pixels + int tex = 0; ///< OpenGL texture to draw for this glyph + float x1 = 0; ///< Left x coordinate of this glyph in the containing texture + float x2 = 0; ///< Right x coordinate of this glyph in the containing texture + float y1 = 0; ///< Left y coordinate of this glyph in the containing texture + float y2 = 0; ///< Right y coordinate of this glyph in the containing texture + int w = 0; ///< Width of the glyph in pixels + int h = 0; ///< Height of the glyph in pixels wxFont font; ///< Font used for this glyph OpenGLTextGlyph(int value, wxFont const& font) : str(wxChar(value)) - , tex(0) - , x1(0) - , x2(0) - , y1(0) - , y2(0) , font(font) { wxCoord desc,lead; @@ -113,13 +108,13 @@ struct OpenGLTextGlyph { /// @class OpenGLTextTexture /// @brief OpenGL texture which stores one or more glyphs as sprites class OpenGLTextTexture final : boost::noncopyable { - int x; ///< Next x coordinate at which a glyph can be inserted - int y; ///< Next y coordinate at which a glyph can be inserted - int nextY; ///< Y coordinate of the next line; tracked due to that lines - ///< are only as tall as needed to fit the glyphs in them - int width; ///< Width of the texture - int height; ///< Height of the texture - GLuint tex; ///< The texture + int x = 0; ///< Next x coordinate at which a glyph can be inserted + int y = 0; ///< Next y coordinate at which a glyph can be inserted + int nextY = 0; ///< Y coordinate of the next line; tracked due to that lines + ///< are only as tall as needed to fit the glyphs in them + int width; ///< Width of the texture + int height; ///< Height of the texture + GLuint tex = 0; ///< The texture /// Insert the glyph into this texture at the current coordinates void Insert(OpenGLTextGlyph &glyph) { @@ -161,12 +156,8 @@ class OpenGLTextTexture final : boost::noncopyable { public: OpenGLTextTexture(OpenGLTextGlyph &glyph) - : x(0) - , y(0) - , nextY(0) - , width(std::max(SmallestPowerOf2(glyph.w), 64)) + : width(std::max(SmallestPowerOf2(glyph.w), 64)) , height(std::max(SmallestPowerOf2(glyph.h), 64)) - , tex(0) { width = height = std::max(width, height); diff --git a/src/hotkey_data_view_model.cpp b/src/hotkey_data_view_model.cpp index d7657e44a..c94011bd3 100644 --- a/src/hotkey_data_view_model.cpp +++ b/src/hotkey_data_view_model.cpp @@ -41,8 +41,8 @@ using namespace agi::hotkey; /// @class HotkeyModelItem /// @brief A base class for things exposed by HotkeyDataViewModel class HotkeyModelItem { - protected: - ~HotkeyModelItem() { } +protected: + ~HotkeyModelItem() = default; public: virtual unsigned int GetChildren(wxDataViewItemArray &children) const=0; virtual wxDataViewItem GetParent() const=0; diff --git a/src/include/aegisub/audio_player.h b/src/include/aegisub/audio_player.h index 7638633f8..5293e13cd 100644 --- a/src/include/aegisub/audio_player.h +++ b/src/include/aegisub/audio_player.h @@ -48,7 +48,7 @@ protected: public: AudioPlayer(AudioProvider *provider); - virtual ~AudioPlayer() { } + virtual ~AudioPlayer() = default; virtual void Play(int64_t start,int64_t count)=0; // Play sample range virtual void Stop()=0; // Stop playing diff --git a/src/include/aegisub/audio_provider.h b/src/include/aegisub/audio_provider.h index ccfc6ffa2..b433aabba 100644 --- a/src/include/aegisub/audio_provider.h +++ b/src/include/aegisub/audio_provider.h @@ -57,7 +57,7 @@ protected: void ZeroFill(void *buf, int64_t count) const; public: - virtual ~AudioProvider() { } + virtual ~AudioProvider() = default; void GetAudio(void *buf, int64_t start, int64_t count) const; void GetAudioWithVolume(void *buf, int64_t start, int64_t count, double volume) const; diff --git a/src/include/aegisub/subtitles_provider.h b/src/include/aegisub/subtitles_provider.h index e10b97752..af2adb35b 100644 --- a/src/include/aegisub/subtitles_provider.h +++ b/src/include/aegisub/subtitles_provider.h @@ -43,7 +43,7 @@ struct VideoFrame; class SubtitlesProvider { public: - virtual ~SubtitlesProvider() { } + virtual ~SubtitlesProvider() = default; virtual void LoadSubtitles(AssFile *subs)=0; virtual void DrawSubtitles(VideoFrame &dst, double time)=0; }; diff --git a/src/preferences.cpp b/src/preferences.cpp index 2d2f4093c..40570d783 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -331,12 +331,11 @@ public: class HotkeyRenderer final : public wxDataViewCustomRenderer { wxString value; - wxTextCtrl *ctrl; + wxTextCtrl *ctrl = nullptr; public: HotkeyRenderer() : wxDataViewCustomRenderer("string", wxDATAVIEW_CELL_EDITABLE) - , ctrl(nullptr) { } wxWindow *CreateEditorCtrl(wxWindow *parent, wxRect label_rect, wxVariant const& var) override { diff --git a/src/preferences_base.cpp b/src/preferences_base.cpp index 3e3020898..1e6051e98 100644 --- a/src/preferences_base.cpp +++ b/src/preferences_base.cpp @@ -260,7 +260,6 @@ struct disabler { wxControl *ctrl; bool enable; - disabler(wxControl *ctrl, bool enable) : ctrl(ctrl), enable(enable) { } void operator()(wxCommandEvent &evt) { ctrl->Enable(!!evt.GetInt() == enable); evt.Skip(); @@ -272,7 +271,7 @@ void OptionPage::EnableIfChecked(wxControl *cbx, wxControl *ctrl) { if (!cb) return; ctrl->Enable(cb->IsChecked()); - cb->Bind(wxEVT_CHECKBOX, disabler(ctrl, true)); + cb->Bind(wxEVT_CHECKBOX, disabler{ctrl, true}); } void OptionPage::DisableIfChecked(wxControl *cbx, wxControl *ctrl) { @@ -280,5 +279,5 @@ void OptionPage::DisableIfChecked(wxControl *cbx, wxControl *ctrl) { if (!cb) return; ctrl->Enable(!cb->IsChecked()); - cb->Bind(wxEVT_CHECKBOX, disabler(ctrl, false)); + cb->Bind(wxEVT_CHECKBOX, disabler{ctrl, false}); } diff --git a/src/search_replace_engine.cpp b/src/search_replace_engine.cpp index d680fff76..584e66d5c 100644 --- a/src/search_replace_engine.cpp +++ b/src/search_replace_engine.cpp @@ -53,10 +53,10 @@ typedef std::function matcher; class noop_accessor { boost::flyweight AssDialogueBase::*field; - size_t start; + size_t start = 0; public: - noop_accessor(SearchReplaceSettings::Field f) : field(get_dialogue_field(f)), start(0) { } + noop_accessor(SearchReplaceSettings::Field f) : field(get_dialogue_field(f)) { } std::string get(const AssDialogue *d, size_t s) { start = s; @@ -64,14 +64,14 @@ public: } MatchState make_match_state(size_t s, size_t e, boost::u32regex *r = nullptr) { - return MatchState(s + start, e + start, r); + return {r, s + start, e + start}; } }; class skip_tags_accessor { boost::flyweight AssDialogueBase::*field; std::vector> blocks; - size_t start; + size_t start = 0; void parse_str(std::string const& str) { blocks.clear(); @@ -90,7 +90,7 @@ class skip_tags_accessor { } public: - skip_tags_accessor(SearchReplaceSettings::Field f) : field(get_dialogue_field(f)), start(0) { } + skip_tags_accessor(SearchReplaceSettings::Field f) : field(get_dialogue_field(f)) { } std::string get(const AssDialogue *d, size_t s) { auto const& str = get_normalized(d, field); @@ -140,7 +140,7 @@ public: // Note that blocks cannot be partially within the match e += block.second - block.first + 1; } - return MatchState(s, e, r); + return {r, s, e}; } }; @@ -157,7 +157,7 @@ matcher get_matcher(SearchReplaceSettings const& settings, Accessor&& a) { boost::smatch result; auto const& str = a.get(diag, start); if (!u32regex_search(str, result, regex, start > 0 ? boost::match_not_bol : boost::match_default)) - return MatchState(); + return {nullptr, 0, -1}; return a.make_match_state(result.position(), result.position() + result.length(), ®ex); }; } @@ -169,18 +169,19 @@ matcher get_matcher(SearchReplaceSettings const& settings, Accessor&& a) { if (!settings.match_case) look_for = boost::locale::fold_case(look_for); + MatchState invalid{nullptr, 0, -1}; return [=](const AssDialogue *diag, size_t start) mutable -> MatchState { const auto str = a.get(diag, start); if (full_match_only && str.size() != look_for.size()) - return MatchState(); + return invalid; if (match_case) { const auto pos = str.find(look_for); - return pos == std::string::npos ? MatchState() : a.make_match_state(pos, pos + look_for.size()); + return pos == std::string::npos ? invalid : a.make_match_state(pos, pos + look_for.size()); } const auto pos = agi::util::ifind(str, look_for); - return pos.first == bad_pos ? MatchState() : a.make_match_state(pos.first, pos.second); + return pos.first == bad_pos ? invalid : a.make_match_state(pos.first, pos.second); }; } diff --git a/src/search_replace_engine.h b/src/search_replace_engine.h index a81b5164a..7db497c8b 100644 --- a/src/search_replace_engine.h +++ b/src/search_replace_engine.h @@ -25,8 +25,6 @@ struct MatchState { boost::u32regex *re; size_t start, end; - MatchState() : re(nullptr), start(0), end(-1) { } - MatchState(size_t s, size_t e, boost::u32regex *re) : re(re), start(s), end(e) { } operator bool() const { return end != (size_t)-1; } }; diff --git a/src/subtitle_format.cpp b/src/subtitle_format.cpp index c5f4d5c12..8df9bf0ab 100644 --- a/src/subtitle_format.cpp +++ b/src/subtitle_format.cpp @@ -70,8 +70,6 @@ SubtitleFormat::SubtitleFormat(std::string name) { } -SubtitleFormat::~SubtitleFormat() { } - bool SubtitleFormat::CanReadFile(agi::fs::path const& filename, std::string const&) const { auto wildcards = GetReadWildcards(); return any_of(begin(wildcards), end(wildcards), diff --git a/src/subtitle_format.h b/src/subtitle_format.h index 6e64a9c2b..41b97e55c 100644 --- a/src/subtitle_format.h +++ b/src/subtitle_format.h @@ -71,7 +71,7 @@ public: /// @param Subtitle format name SubtitleFormat(std::string name); /// Destructor - virtual ~SubtitleFormat(); + virtual ~SubtitleFormat() = default; /// Get this format's name std::string const& GetName() const { return name; } diff --git a/src/tooltip_manager.cpp b/src/tooltip_manager.cpp index 447dbef4b..4029119da 100644 --- a/src/tooltip_manager.cpp +++ b/src/tooltip_manager.cpp @@ -39,6 +39,7 @@ #include +#include #include #include @@ -48,36 +49,15 @@ struct ToolTipBinding { const char *command; const char *context; void Update(); - - ToolTipBinding(wxWindow *window, wxString toolTip, const char *command, const char *context) - : window(window) - , toolTip(toolTip) - , command(command) - , context(context) - { - } - - // clang doesn't like wxWeakRef's copy constructor, so use the assignment - // operator instead - ToolTipBinding(ToolTipBinding const& other) - : toolTip(other.toolTip) - , command(other.command) - , context(other.context) - { - window = other.window; - } }; -ToolTipManager::ToolTipManager() { } -ToolTipManager::~ToolTipManager() { } - void ToolTipManager::Bind(wxWindow *window, wxString tooltip, const char *context, const char *command) { - ToolTipBinding tip(window, tooltip, command, context); + ToolTipBinding tip{window, tooltip, command, context}; tip.Update(); - static ToolTipManager instance; - instance.tips.push_back(tip); - hotkey::inst->AddHotkeyChangeListener(&ToolTipBinding::Update, &instance.tips.back()); + static std::list tips; + tips.push_back(tip); + hotkey::inst->AddHotkeyChangeListener(&ToolTipBinding::Update, &tips.back()); } void ToolTipBinding::Update() { diff --git a/src/tooltip_manager.h b/src/tooltip_manager.h index 187ede62d..698f0f607 100644 --- a/src/tooltip_manager.h +++ b/src/tooltip_manager.h @@ -27,26 +27,10 @@ // // Aegisub Project http://www.aegisub.org/ -/// @file tooltip_manager.h -/// @see tooltip_manager.cpp -/// @ingroup custom_control -/// - -#include - -struct ToolTipBinding; - class wxString; class wxWindow; class ToolTipManager { - ToolTipManager(); - ~ToolTipManager(); - ToolTipManager(ToolTipManager const&); - ToolTipManager& operator=(ToolTipManager const&); - - boost::container::list tips; - public: static void Bind(wxWindow *window, wxString tooltip, const char *context, const char *command); }; diff --git a/src/visual_tool.h b/src/visual_tool.h index abf95cf5e..b4696df4f 100644 --- a/src/visual_tool.h +++ b/src/visual_tool.h @@ -142,7 +142,7 @@ public: virtual void Draw()=0; virtual void SetDisplayArea(int x, int y, int w, int h); virtual void SetToolbar(wxToolBar *) { } - virtual ~VisualToolBase() { } + virtual ~VisualToolBase() = default; }; /// Visual tool base class containing all common feature-related functionality diff --git a/src/visual_tool_clip.h b/src/visual_tool_clip.h index 409d375ef..52e4977ad 100644 --- a/src/visual_tool_clip.h +++ b/src/visual_tool_clip.h @@ -24,9 +24,9 @@ /// VisualDraggableFeature with siblings struct ClipCorner final : public VisualDraggableFeature { - ClipCorner *horiz; ///< Other corner on this corner's horizontal line - ClipCorner *vert; ///< Other corner on this corner's vertical line - ClipCorner() : VisualDraggableFeature() , horiz(nullptr) , vert(nullptr) { type = DRAG_SMALL_CIRCLE; } + ClipCorner *horiz = nullptr; ///< Other corner on this corner's horizontal line + ClipCorner *vert = nullptr; ///< Other corner on this corner's vertical line + ClipCorner() { type = DRAG_SMALL_CIRCLE; } }; class VisualToolClip final : public VisualTool { diff --git a/src/visual_tool_drag.h b/src/visual_tool_drag.h index 8aa14a362..70dade63f 100644 --- a/src/visual_tool_drag.h +++ b/src/visual_tool_drag.h @@ -26,9 +26,8 @@ /// @brief VisualDraggableFeature with a time value class VisualToolDragDraggableFeature final : public VisualDraggableFeature { public: - int time; - VisualToolDragDraggableFeature *parent; - VisualToolDragDraggableFeature() : VisualDraggableFeature(), time(0), parent(nullptr) { } + int time = 0; + VisualToolDragDraggableFeature *parent = nullptr; }; class wxBitmapButton; diff --git a/src/visual_tool_vector_clip.h b/src/visual_tool_vector_clip.h index 703363dd5..b0c11191e 100644 --- a/src/visual_tool_vector_clip.h +++ b/src/visual_tool_vector_clip.h @@ -32,12 +32,7 @@ struct VisualToolVectorClipDraggableFeature final : public VisualDraggableFeatur /// Which curve in the spline this feature is a point on Spline::iterator curve; /// 0-3; indicates which part of the curve this point is - int point; - /// @brief Constructor - VisualToolVectorClipDraggableFeature() - : VisualDraggableFeature() - , point(0) - { } + int point = 0; }; class VisualToolVectorClip final : public VisualTool {