diff --git a/aegisub/src/ass_attachment.cpp b/aegisub/src/ass_attachment.cpp index acacc4430..a9f5b4b5f 100644 --- a/aegisub/src/ass_attachment.cpp +++ b/aegisub/src/ass_attachment.cpp @@ -118,11 +118,11 @@ const wxString AssAttachment::GetEntryData() const { return entryData; } -void AssAttachment::Extract(wxString filename) { +void AssAttachment::Extract(wxString const& filename) const { agi::io::Save(STD_STR(filename)).Get().write(&(*data)[0], data->size()); } -void AssAttachment::Import(wxString filename) { +void AssAttachment::Import(wxString const& filename) { agi::scoped_ptr file(agi::io::Open(STD_STR(filename))); file->seekg(0, std::ios::end); data->resize(file->tellg()); @@ -130,7 +130,7 @@ void AssAttachment::Import(wxString filename) { file->read(&(*data)[0], data->size()); } -wxString AssAttachment::GetFileName(bool raw) { +wxString AssAttachment::GetFileName(bool raw) const { if (raw || filename.Right(4).Lower() != ".ttf") return filename; // Remove stuff after last underscore if it's a font diff --git a/aegisub/src/ass_attachment.h b/aegisub/src/ass_attachment.h index afe09b1dd..0e6f47988 100644 --- a/aegisub/src/ass_attachment.h +++ b/aegisub/src/ass_attachment.h @@ -59,21 +59,21 @@ public: /// Add a line of data (without newline) read from a subtitle file to the /// buffer waiting to be decoded - void AddData(wxString data) { buffer += data; } + void AddData(wxString const& data) { buffer += data; } /// Decode all data passed with AddData void Finish(); /// Extract the contents of this attachment to a file /// @param filename Path to save the attachment to - void Extract(wxString filename); + void Extract(wxString const& filename) const; /// Import the contents of a file as an attachment /// @param filename Path to import - void Import(wxString filename); + void Import(wxString const& filename); /// Get the name of the attached file /// @param raw If false, remove the SSA filename mangling - wxString GetFileName(bool raw=false); + wxString GetFileName(bool raw=false) const; const wxString GetEntryData() const; ASS_EntryType GetType() const { return ENTRY_ATTACHMENT; } diff --git a/aegisub/src/ass_dialogue.cpp b/aegisub/src/ass_dialogue.cpp index 49cbe865d..93f55731b 100644 --- a/aegisub/src/ass_dialogue.cpp +++ b/aegisub/src/ass_dialogue.cpp @@ -388,7 +388,7 @@ void AssDialogue::ProcessParameters(AssDialogueBlockOverride::ProcessParametersC //ClearBlocks(); } -bool AssDialogue::CollidesWith(AssDialogue *target) { +bool AssDialogue::CollidesWith(const AssDialogue *target) const { if (!target) return false; return ((Start < target->Start) ? (target->Start < End) : (Start < target->End)); } diff --git a/aegisub/src/ass_dialogue.h b/aegisub/src/ass_dialogue.h index 784fbd7a3..8bb594b98 100644 --- a/aegisub/src/ass_dialogue.h +++ b/aegisub/src/ass_dialogue.h @@ -81,11 +81,7 @@ public: AssDialogueBlock(wxString const& text) : text(text) { } virtual ~AssDialogueBlock() { } - virtual ASS_BlockType GetType() = 0; - - /// @brief DOCME - /// @return - /// + virtual ASS_BlockType GetType() const = 0; virtual wxString GetText() { return text; } }; @@ -95,7 +91,7 @@ public: /// DOCME class AssDialogueBlockPlain : public AssDialogueBlock { public: - ASS_BlockType GetType() { return BLOCK_PLAIN; } + ASS_BlockType GetType() const { return BLOCK_PLAIN; } AssDialogueBlockPlain(wxString const& text = wxString()) : AssDialogueBlock(text) { } }; @@ -108,7 +104,7 @@ public: /// DOCME int Scale; - ASS_BlockType GetType() { return BLOCK_DRAWING; } + ASS_BlockType GetType() const { return BLOCK_DRAWING; } AssDialogueBlockDrawing(wxString const& text, int scale) : AssDialogueBlock(text), Scale(scale) { } void TransformCoords(int trans_x,int trans_y,double mult_x,double mult_y); }; @@ -129,7 +125,7 @@ public: /// @brief DOCME /// @return /// - ASS_BlockType GetType() { return BLOCK_OVERRIDE; } + ASS_BlockType GetType() const { return BLOCK_OVERRIDE; } wxString GetText(); void ParseTags(); // Parses tags void AddTag(wxString const& tag); @@ -217,7 +213,7 @@ public: /// Get the line as SSA rather than ASS wxString GetSSAText() const; /// Does this line collide with the passed line? - bool CollidesWith(AssDialogue *target); + bool CollidesWith(const AssDialogue *target) const; AssEntry *Clone() const; diff --git a/aegisub/src/ass_exporter.cpp b/aegisub/src/ass_exporter.cpp index 490be6399..96013e18a 100644 --- a/aegisub/src/ass_exporter.cpp +++ b/aegisub/src/ass_exporter.cpp @@ -96,7 +96,7 @@ void AssExporter::AddAutoFilters() { } } -wxArrayString AssExporter::GetAllFilterNames() { +wxArrayString AssExporter::GetAllFilterNames() const { wxArrayString names; transform(filter_list_begin(), filter_list_end(), std::back_inserter(names), std::mem_fun(&AssExportFilter::GetName)); @@ -125,7 +125,7 @@ wxSizer *AssExporter::GetSettingsSizer(wxString const& name) { return pos->second; } -wxString const& AssExporter::GetDescription(wxString const& name) { +wxString const& AssExporter::GetDescription(wxString const& name) const { AssExportFilter *filter = AssExportFilterChain::GetFilter(name); if (filter) return filter->GetDescription(); diff --git a/aegisub/src/ass_exporter.h b/aegisub/src/ass_exporter.h index 938f8ea56..286001bb5 100644 --- a/aegisub/src/ass_exporter.h +++ b/aegisub/src/ass_exporter.h @@ -75,7 +75,7 @@ public: ~AssExporter(); /// Get the names of all registered export filters - wxArrayString GetAllFilterNames(); + wxArrayString GetAllFilterNames() const; /// Add the named filter to the list of filters to be run /// @throws wxString if filter is not found @@ -107,5 +107,5 @@ public: /// Get the description of the named export filter /// @throws wxString if filter is not found - wxString const& GetDescription(wxString const& name); + wxString const& GetDescription(wxString const& name) const; }; diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index 8d4944138..9bfbb642f 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -509,12 +509,12 @@ void AssFile::InsertDialogue(AssDialogue *diag) { Line.push_back(diag); } -wxString AssFile::GetScriptInfo(wxString key) { +wxString AssFile::GetScriptInfo(wxString key) const { key.MakeLower(); key += ":"; bool GotIn = false; - for (std::list::iterator cur = Line.begin(); cur != Line.end(); ++cur) { + for (std::list::const_iterator cur = Line.begin(); cur != Line.end(); ++cur) { if ((*cur)->group == "[Script Info]") { GotIn = true; wxString curText = (*cur)->GetEntryData(); @@ -527,7 +527,7 @@ wxString AssFile::GetScriptInfo(wxString key) { return ""; } -int AssFile::GetScriptInfoAsInt(const wxString key) { +int AssFile::GetScriptInfoAsInt(const wxString key) const { long temp = 0; GetScriptInfo(key).ToLong(&temp); return temp; @@ -574,7 +574,7 @@ void AssFile::SetScriptInfo(wxString const& key, wxString const& value) { } } -void AssFile::GetResolution(int &sw,int &sh) { +void AssFile::GetResolution(int &sw,int &sh) const { sw = GetScriptInfoAsInt("PlayResX"); sh = GetScriptInfoAsInt("PlayResY"); @@ -613,9 +613,9 @@ void AssFile::AddComment(wxString comment) { } } -wxArrayString AssFile::GetStyles() { +wxArrayString AssFile::GetStyles() const { wxArrayString styles; - for (entryIter cur = Line.begin(); cur != Line.end(); ++cur) { + for (std::list::const_iterator cur = Line.begin(); cur != Line.end(); ++cur) { if (AssStyle *curstyle = dynamic_cast(*cur)) styles.Add(curstyle->name); } diff --git a/aegisub/src/ass_file.h b/aegisub/src/ass_file.h index e39829fb4..739d2e17e 100644 --- a/aegisub/src/ass_file.h +++ b/aegisub/src/ass_file.h @@ -115,7 +115,7 @@ public: /// Add a dialogue line to the file void InsertDialogue(AssDialogue *diag); /// Get the names of all of the styles available - wxArrayString GetStyles(); + wxArrayString GetStyles() const; /// @brief Get a style by name /// @param name Style name /// @return Pointer to style or NULL @@ -154,11 +154,11 @@ public: /// @brief Get the script resolution /// @param[out] w Width /// @param[in] h Height - void GetResolution(int &w,int &h); + void GetResolution(int &w,int &h) const; /// Get the value in a [Script Info] key as int, or 0 if it is not present - int GetScriptInfoAsInt(const wxString key); + int GetScriptInfoAsInt(const wxString key) const; /// Get the value in a [Script Info] key as string. - wxString GetScriptInfo(wxString key); + wxString GetScriptInfo(wxString key) const; /// Set the value of a [Script Info] key. Adds it if it doesn't exist. void SetScriptInfo(wxString const& key, wxString const& value); // Add a ";" comment in the [Script Info] section diff --git a/aegisub/src/ass_override.cpp b/aegisub/src/ass_override.cpp index 8c84e4e06..c1fe06bfb 100644 --- a/aegisub/src/ass_override.cpp +++ b/aegisub/src/ass_override.cpp @@ -304,10 +304,6 @@ void AssOverrideTag::SetText(const wxString &text) { valid = false; } -bool AssOverrideTag::IsValid() { - return valid; -} - std::vector tokenize(const wxString &text) { std::vector paramList; paramList.reserve(6); @@ -439,7 +435,7 @@ void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto:: } } -AssOverrideTag::operator wxString() { +AssOverrideTag::operator wxString() const { wxString result = Name; // Determine if it needs parentheses @@ -456,7 +452,7 @@ AssOverrideTag::operator wxString() { // Add parameters bool any = false; - for (std::vector::iterator cur=Params.begin();cur!=Params.end();cur++) { + for (std::vector::const_iterator cur=Params.begin();cur!=Params.end();cur++) { if ((*cur)->GetType() != VARDATA_NONE && !(*cur)->omitted) { result += (*cur)->Get(); result += ","; diff --git a/aegisub/src/ass_override.h b/aegisub/src/ass_override.h index 151661747..c17c3e5c8 100644 --- a/aegisub/src/ass_override.h +++ b/aegisub/src/ass_override.h @@ -140,11 +140,11 @@ public: AssOverrideTag(wxString text); ~AssOverrideTag(); - bool IsValid(); + bool IsValid() const { return valid; } /// @brief Parses the parameters for the ass override tag /// @param text All text between the name and the next \ or the end of the override block void ParseParameters(const wxString &text, AssOverrideTagProto::iterator proto); void Clear(); void SetText(const wxString &text); - operator wxString(); + operator wxString() const; }; diff --git a/aegisub/src/ass_style.cpp b/aegisub/src/ass_style.cpp index d6681b02c..90f42c6e9 100644 --- a/aegisub/src/ass_style.cpp +++ b/aegisub/src/ass_style.cpp @@ -99,7 +99,7 @@ void AssColor::Parse(wxString const& value) { /// @brief Gets a wxColour /// @return -wxColour AssColor::GetWXColor() { +wxColour AssColor::GetWXColor() const { return wxColour(r,g,b,255-a); } diff --git a/aegisub/src/ass_style.h b/aegisub/src/ass_style.h index d066dc17d..88a964819 100644 --- a/aegisub/src/ass_style.h +++ b/aegisub/src/ass_style.h @@ -58,7 +58,7 @@ struct AssColor { bool operator==(const AssColor &col) const; bool operator!=(const AssColor &col) const; - wxColor GetWXColor(); // Return as a wxColor + wxColor GetWXColor() const; // Return as a wxColor void SetWXColor(const wxColor &color); // Sets from a wxColor void Parse(wxString const& value); // Parse SSA or ASS-style color wxString GetASSFormatted(bool alpha,bool stripped=false,bool isStyle=false) const; // Gets color formated in ASS format diff --git a/aegisub/src/ass_style_storage.cpp b/aegisub/src/ass_style_storage.cpp index 3edb1580a..b2225fd3a 100644 --- a/aegisub/src/ass_style_storage.cpp +++ b/aegisub/src/ass_style_storage.cpp @@ -52,7 +52,7 @@ AssStyleStorage::~AssStyleStorage() { delete_clear(style); } -void AssStyleStorage::Save() { +void AssStyleStorage::Save() const { if (storage_name.empty()) return; wxString dirname = StandardPaths::DecodePath("?user/catalog/"); @@ -60,7 +60,7 @@ void AssStyleStorage::Save() { throw "Failed creating directory for style catalogs"; TextFileWriter file(StandardPaths::DecodePath("?user/catalog/" + storage_name + ".sty"), "UTF-8"); - for (iterator cur = begin(); cur != end(); ++cur) + for (const_iterator cur = begin(); cur != end(); ++cur) file.WriteLineToFile((*cur)->GetEntryData()); } diff --git a/aegisub/src/ass_style_storage.h b/aegisub/src/ass_style_storage.h index c50922145..59fa0f7bc 100644 --- a/aegisub/src/ass_style_storage.h +++ b/aegisub/src/ass_style_storage.h @@ -55,8 +55,11 @@ public: ~AssStyleStorage(); typedef std::deque::iterator iterator; + typedef std::deque::const_iterator const_iterator; iterator begin() { return style.begin(); } iterator end() { return style.end(); } + const_iterator begin() const { return style.begin(); } + const_iterator end() const { return style.end(); } void push_back(AssStyle *new_style) { style.push_back(new_style); } AssStyle *back() { return style.back(); } AssStyle *operator[](size_t idx) const { return style[idx]; } @@ -77,7 +80,7 @@ public: AssStyle *GetStyle(wxString const& name); /// Save stored styles to a file - void Save(); + void Save() const; /// Load stored styles from a file /// @param name Catalog name (note: not file name) diff --git a/aegisub/src/dialog_kara_timing_copy.cpp b/aegisub/src/dialog_kara_timing_copy.cpp index b92e4e733..6100711b7 100644 --- a/aegisub/src/dialog_kara_timing_copy.cpp +++ b/aegisub/src/dialog_kara_timing_copy.cpp @@ -450,7 +450,7 @@ void KaraokeLineMatchDisplay::AutoMatchJapanese() { wxString dst_hira_rest, dst_kata_rest, src_rest; bool matched = false; - for (KanaEntry *ke = KanaTable; ke->hiragana; ++ke) + for (const KanaEntry *ke = KanaTable; ke->hiragana; ++ke) { if (src.StartsWith(ke->hepburn, &src_rest)) { @@ -521,7 +521,7 @@ void KaraokeLineMatchDisplay::AutoMatchJapanese() // Find a position where hiragana or katakana matches wxString matched_roma; wxString matched_kana; - for (KanaEntry *ke = KanaTable; ke->hiragana; ++ke) + for (const KanaEntry *ke = KanaTable; ke->hiragana; ++ke) { if (*ke->hiragana && dst.StartsWith(ke->hiragana)) { diff --git a/aegisub/src/kana_table.cpp b/aegisub/src/kana_table.cpp index 33b3e96e7..e24db4fad 100644 --- a/aegisub/src/kana_table.cpp +++ b/aegisub/src/kana_table.cpp @@ -39,7 +39,7 @@ #include "kana_table.h" -KanaEntry KanaTable[] = +const KanaEntry KanaTable[] = { // Regular kana usage and combinations { L"\u3042", L"\u30a2", L"a" }, diff --git a/aegisub/src/kana_table.h b/aegisub/src/kana_table.h index 7a5121bd6..3df7b12d3 100644 --- a/aegisub/src/kana_table.h +++ b/aegisub/src/kana_table.h @@ -54,4 +54,4 @@ struct KanaEntry { }; /// Table of Hiragana, Katakana and Hepburn romaji tuples. -extern KanaEntry KanaTable[]; +extern const KanaEntry KanaTable[]; diff --git a/aegisub/src/spline.cpp b/aegisub/src/spline.cpp index 3a9ba10dd..515e78237 100644 --- a/aegisub/src/spline.cpp +++ b/aegisub/src/spline.cpp @@ -67,12 +67,12 @@ void Spline::SetScale(int new_scale) { scale = 1 << (raw_scale - 1); } -wxString Spline::EncodeToASS() { +wxString Spline::EncodeToASS() const { wxString result; result.reserve(size() * 10); char last = 0; - for (iterator cur = begin(); cur != end(); ++cur) { + for (const_iterator cur = begin(); cur != end(); ++cur) { switch (cur->type) { case SplineCurve::POINT: if (last != 'm') { diff --git a/aegisub/src/spline.h b/aegisub/src/spline.h index 940aceef9..19bdf9fc1 100644 --- a/aegisub/src/spline.h +++ b/aegisub/src/spline.h @@ -64,7 +64,7 @@ public: Spline(const VisualToolBase &scale); /// Encode to an ASS vector drawing - wxString EncodeToASS(); + wxString EncodeToASS() const; /// Decode an ASS vector drawing void DecodeFromASS(wxString str); diff --git a/aegisub/src/subs_grid.cpp b/aegisub/src/subs_grid.cpp index 7d1397ab2..9f93319f2 100644 --- a/aegisub/src/subs_grid.cpp +++ b/aegisub/src/subs_grid.cpp @@ -376,7 +376,7 @@ void SubtitlesGrid::AdjoinLines(int n1,int n2,bool setStart) { /// @brief Retrieve a list of selected lines in the actual ASS file (ie. not as displayed in the grid but as represented in the file) /// @return /// -std::vector SubtitlesGrid::GetAbsoluteSelection() { +std::vector SubtitlesGrid::GetAbsoluteSelection() const { Selection sel = GetSelectedSet(); std::vector result; diff --git a/aegisub/src/subs_grid.h b/aegisub/src/subs_grid.h index 192b6327a..558871daa 100644 --- a/aegisub/src/subs_grid.h +++ b/aegisub/src/subs_grid.h @@ -75,7 +75,7 @@ public: void RecombineLines(); /// Retrieve a list of selected lines in the actual ASS file (i.e. not as displayed in the grid but as represented in the file) - std::vector GetAbsoluteSelection(); + std::vector GetAbsoluteSelection() const; /// @brief Update list of selected lines from absolute selection /// @param selection Sorted list of selections void SetSelectionFromAbsolute(std::vector &selection);