Make some stuff const

Originally committed to SVN as r6590.
This commit is contained in:
Thomas Goyne 2012-03-20 00:39:10 +00:00
parent 36d962931d
commit 75ae053958
21 changed files with 48 additions and 53 deletions

View file

@ -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<std::istream> 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

View file

@ -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; }

View file

@ -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));
}

View file

@ -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;

View file

@ -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();

View file

@ -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;
};

View file

@ -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<AssEntry*>::iterator cur = Line.begin(); cur != Line.end(); ++cur) {
for (std::list<AssEntry*>::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<AssEntry*>::const_iterator cur = Line.begin(); cur != Line.end(); ++cur) {
if (AssStyle *curstyle = dynamic_cast<AssStyle*>(*cur))
styles.Add(curstyle->name);
}

View file

@ -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

View file

@ -304,10 +304,6 @@ void AssOverrideTag::SetText(const wxString &text) {
valid = false;
}
bool AssOverrideTag::IsValid() {
return valid;
}
std::vector<wxString> tokenize(const wxString &text) {
std::vector<wxString> 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<AssOverrideParameter*>::iterator cur=Params.begin();cur!=Params.end();cur++) {
for (std::vector<AssOverrideParameter*>::const_iterator cur=Params.begin();cur!=Params.end();cur++) {
if ((*cur)->GetType() != VARDATA_NONE && !(*cur)->omitted) {
result += (*cur)->Get<wxString>();
result += ",";

View file

@ -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;
};

View file

@ -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);
}

View file

@ -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

View file

@ -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());
}

View file

@ -55,8 +55,11 @@ public:
~AssStyleStorage();
typedef std::deque<AssStyle*>::iterator iterator;
typedef std::deque<AssStyle*>::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)

View file

@ -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))
{

View file

@ -39,7 +39,7 @@
#include "kana_table.h"
KanaEntry KanaTable[] =
const KanaEntry KanaTable[] =
{
// Regular kana usage and combinations
{ L"\u3042", L"\u30a2", L"a" },

View file

@ -54,4 +54,4 @@ struct KanaEntry {
};
/// Table of Hiragana, Katakana and Hepburn romaji tuples.
extern KanaEntry KanaTable[];
extern const KanaEntry KanaTable[];

View file

@ -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') {

View file

@ -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);

View file

@ -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<int> SubtitlesGrid::GetAbsoluteSelection() {
std::vector<int> SubtitlesGrid::GetAbsoluteSelection() const {
Selection sel = GetSelectedSet();
std::vector<int> result;

View file

@ -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<int> GetAbsoluteSelection();
std::vector<int> GetAbsoluteSelection() const;
/// @brief Update list of selected lines from absolute selection
/// @param selection Sorted list of selections
void SetSelectionFromAbsolute(std::vector<int> &selection);