Run clang-modernize on things

This commit is contained in:
Thomas Goyne 2013-11-21 09:13:36 -08:00
parent 2e051a8fde
commit a7f4fb5b87
180 changed files with 1045 additions and 1048 deletions

View file

@ -39,7 +39,7 @@ class UCDetect : public nsUniversalDetector {
/// List of detected character sets
CharsetListDetected list;
void Report(const char* aCharset) {}
void Report(const char*) override {}
public:
/// @brief Detect character set of a file using UniversalCharDetect
@ -90,17 +90,16 @@ public:
list.emplace_back(1.f, mDetectedCharset);
else {
switch (mInputState) {
case eHighbyte: {
for (PRInt32 i=0; i<NUM_OF_CHARSET_PROBERS; i++) {
if (!mCharSetProbers[i]) continue;
case eHighbyte:
for (auto& elem : mCharSetProbers) {
if (!elem) continue;
float conf = mCharSetProbers[i]->GetConfidence();
float conf = elem->GetConfidence();
if (conf > 0.01f)
list.emplace_back(conf, mCharSetProbers[i]->GetCharSetName());
list.emplace_back(conf, elem->GetCharSetName());
}
break;
}
case ePureAscii:
list.emplace_back(1.f, "US-ASCII");
break;

View file

@ -241,7 +241,7 @@ namespace {
~ConverterImpl() {
if (cd != iconv_invalid) iconv_close(cd);
}
size_t Convert(const char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft) {
size_t Convert(const char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft) override {
eat_bom(cd, bomSize, inbuf, inbytesleft, outbuf, outbytesleft);
size_t res = iconv(cd, ICONV_CONST_CAST(inbuf), inbytesleft, outbuf, outbytesleft);

View file

@ -33,13 +33,13 @@ namespace {
std::atomic<uint_fast32_t> threads_running;
class MainQueue : public agi::dispatch::Queue {
void DoInvoke(agi::dispatch::Thunk thunk) {
void DoInvoke(agi::dispatch::Thunk thunk) override {
invoke_main(thunk);
}
};
class BackgroundQueue : public agi::dispatch::Queue {
void DoInvoke(agi::dispatch::Thunk thunk) {
void DoInvoke(agi::dispatch::Thunk thunk) override {
service->post(thunk);
}
};
@ -47,7 +47,7 @@ namespace {
class SerialQueue : public agi::dispatch::Queue {
boost::asio::io_service::strand strand;
void DoInvoke(agi::dispatch::Thunk thunk) {
void DoInvoke(agi::dispatch::Thunk thunk) override {
strand.post(thunk);
}
public:

View file

@ -56,7 +56,7 @@ MRUManager::~MRUManager() {
}
MRUManager::MRUListMap &MRUManager::Find(std::string const& key) {
MRUMap::iterator index = mru.find(key);
auto index = mru.find(key);
if (index == mru.end())
throw MRUErrorInvalidKey("Invalid key value");
return index->second;

View file

@ -67,11 +67,11 @@ std::unique_ptr<OptionValue> ConfigVisitor::ReadArray(json::Array const& src, st
for (json::Object const& obj : src) {
if (obj.size() != 1) {
Error<OptionJsonValueArray>("Invalid array member");
return 0;
return nullptr;
}
if (obj.begin()->first != array_type) {
Error<OptionJsonValueArray>("Attempt to insert value into array of wrong type");
return 0;
return nullptr;
}
arr.push_back(ValueType(obj.begin()->second));

View file

@ -66,7 +66,7 @@ fs::path Path::Decode(std::string const& path) const {
fs::path Path::MakeRelative(fs::path const& path, std::string const& token) const {
const auto it = tokens.find(token);
if (it == tokens.end()) throw agi::InternalError("Bad token: " + token, 0);
if (it == tokens.end()) throw agi::InternalError("Bad token: " + token, nullptr);
return MakeRelative(path, it->second);
}
@ -97,7 +97,7 @@ fs::path Path::MakeRelative(fs::path const& path, fs::path const& base) const {
fs::path Path::MakeAbsolute(fs::path path, std::string const& token) const {
const auto it = tokens.find(token);
if (it == tokens.end()) throw agi::InternalError("Bad token: " + token, 0);
if (it == tokens.end()) throw agi::InternalError("Bad token: " + token, nullptr);
if (path.empty()) return path;
path.make_preferred();
@ -127,7 +127,7 @@ std::string Path::Encode(fs::path const& path) const {
void Path::SetToken(std::string const& token_name, fs::path const& token_value) {
const auto it = tokens.find(token_name);
if (it == tokens.end()) throw agi::InternalError("Bad token: " + token_name, 0);
if (it == tokens.end()) throw agi::InternalError("Bad token: " + token_name, nullptr);
if (token_value.empty())
it->second = token_value;

View file

@ -179,8 +179,8 @@ void Framerate::SetFromTimecodes() {
last = (timecodes.size() - 1) * denominator * 1000;
}
Framerate::Framerate(std::vector<int> const& timecodes)
: timecodes(timecodes)
Framerate::Framerate(std::vector<int> timecodes)
: timecodes(std::move(timecodes))
, drop(false)
{
SetFromTimecodes();

View file

@ -31,9 +31,9 @@ public:
// problems such as errant characters or corrupt/incomplete documents
class ScanException : public Exception {
public:
ScanException(std::string const& sMessage, Reader::Location const& locError)
ScanException(std::string const& sMessage, Reader::Location locError)
: Exception(sMessage)
, m_locError(locError)
, m_locError(std::move(locError))
{ }
Reader::Location m_locError;
@ -43,10 +43,10 @@ public:
// higher-level problems such as missing commas or brackets
class ParseException : public Exception {
public:
ParseException(std::string const& sMessage, Reader::Location const& locTokenBegin, Reader::Location const& locTokenEnd)
ParseException(std::string const& sMessage, Reader::Location locTokenBegin, Reader::Location locTokenEnd)
: Exception(sMessage)
, m_locTokenBegin(locTokenBegin)
, m_locTokenEnd(locTokenEnd)
, m_locTokenBegin(std::move(locTokenBegin))
, m_locTokenEnd(std::move(locTokenEnd))
{ }
Reader::Location m_locTokenBegin;

View file

@ -26,13 +26,13 @@ class Writer : private ConstVisitor {
void Write(const Null& null);
void Write(const UnknownElement& unknown);
void Visit(const Array& array);
void Visit(const Object& object);
void Visit(const Integer& number);
void Visit(const Double& number);
void Visit(const String& string);
void Visit(const Boolean& boolean);
void Visit(const Null& null);
void Visit(const Array& array) override;
void Visit(const Object& object) override;
void Visit(const Integer& number) override;
void Visit(const Double& number) override;
void Visit(const String& string) override;
void Visit(const Boolean& boolean) override;
void Visit(const Null& null) override;
std::ostream& m_ostr;
int tab_depth;

View file

@ -100,7 +100,7 @@ namespace agi {
///
/// Deriving classes should always use this constructor for initialising
/// the base class.
Exception(const std::string &msg, const Exception *inr = 0) : message(msg) {
Exception(std::string msg, const Exception *inr = nullptr) : message(std::move(msg)) {
if (inr)
inner.reset(inr->Copy());
}

View file

@ -34,8 +34,8 @@ namespace agi {
namespace hotkey {
/// @class Combo
/// A Combo represents a linear sequence of characters set in an std::vector. This makes up
/// a single combination, or "Hotkey".
/// A Combo represents a linear sequence of characters set in an std::vector.
/// This makes up a single combination, or "Hotkey".
class Combo {
std::vector<std::string> key_map;
std::string cmd_name;
@ -44,10 +44,10 @@ public:
/// Constructor
/// @param ctx Context
/// @param cmd Command name
Combo(std::string const& ctx, std::string const& cmd, std::vector<std::string> const& keys)
: key_map(keys)
, cmd_name(cmd)
, context(ctx)
Combo(std::string ctx, std::string cmd, std::vector<std::string> keys)
: key_map(std::move(keys))
, cmd_name(std::move(cmd))
, context(std::move(ctx))
{
}

View file

@ -85,7 +85,7 @@ public:
/// @brief Invalid iterator constructor; use for end iterator
line_iterator()
: stream(0)
: stream(nullptr)
, valid(false)
{
}

View file

@ -43,9 +43,9 @@ namespace agi {
template<class StartCont, class Iter, class WidthCont>
inline void get_line_widths(StartCont const& line_start_points, Iter begin, Iter end, WidthCont &line_widths) {
size_t line_start = 0;
for (size_t i = 0; i < line_start_points.size(); ++i) {
line_widths.push_back(std::accumulate(begin + line_start, begin + line_start_points[i], 0));
line_start = line_start_points[i];
for (auto & line_start_point : line_start_points) {
line_widths.push_back(std::accumulate(begin + line_start, begin + line_start_point, 0));
line_start = line_start_point;
}
line_widths.push_back(std::accumulate(begin + line_start, end, 0));
}

View file

@ -132,7 +132,7 @@ public:
/// Destructor
~JsonEmitter();
void log(SinkMessage *);
void log(SinkMessage *) override;
};
/// Generates a message and submits it to the log sink.
@ -149,7 +149,7 @@ public:
/// Emit log entries to stdout.
class EmitSTDOUT: public Emitter {
public:
void log(SinkMessage *sm);
void log(SinkMessage *sm) override;
};
} // namespace log

View file

@ -54,7 +54,7 @@ public:
/// @brief Constructor
/// @param config File to load MRU values from
MRUManager(agi::fs::path const& config, std::string const& default_config, agi::Options *options = 0);
MRUManager(agi::fs::path const& config, std::string const& default_config, agi::Options *options = nullptr);
/// Destructor
~MRUManager();

View file

@ -139,7 +139,7 @@ namespace detail {
SlotMap slots; /// Signals currently connected to this slot
void Disconnect(ConnectionToken *tok) {
void Disconnect(ConnectionToken *tok) override {
slots.erase(tok);
}

View file

@ -107,7 +107,7 @@ public:
/// @brief VFR from frame times
/// @param timecodes Vector of frame start times in milliseconds
Framerate(std::vector<int> const& timecodes);
Framerate(std::vector<int> timecodes);
/// Helper function for the std::swap specialization
void swap(Framerate &right) throw();

View file

@ -93,12 +93,12 @@ wxString AegisubLocale::PickLanguage() {
// Generate names
wxArrayString langNames;
for (size_t i = 0; i < langs.size(); ++i) {
const wxLanguageInfo *info = wxLocale::FindLanguageInfo(langs[i]);
for (auto const& lang : langs) {
const wxLanguageInfo *info = wxLocale::FindLanguageInfo(lang);
if (info)
langNames.push_back(wxLocale::GetLanguageName(info->Language));
else
langNames.push_back(langs[i]);
langNames.push_back(lang);
}
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCENTRE;
@ -107,7 +107,7 @@ wxString AegisubLocale::PickLanguage() {
wxSingleChoiceDialog dialog(nullptr, "Please choose a language:", "Language", langNames,
#if wxCHECK_VERSION(2, 9, 4)
(void **)0,
(void **)nullptr,
#else
0,
#endif

View file

@ -52,7 +52,7 @@ AssAttachment::AssAttachment(agi::fs::path const& name, AssEntryGroup group)
}
AssEntry *AssAttachment::Clone() const {
AssAttachment *clone = new AssAttachment(filename, group);
auto clone = new AssAttachment(filename, group);
clone->entry_data = entry_data;
return clone;
}

View file

@ -96,7 +96,7 @@ public:
agi::StringRange next_tok() {
if (pos.eof())
throw SubtitleFormatParseError("Failed parsing line: " + std::string(str.begin(), str.end()), 0);
throw SubtitleFormatParseError("Failed parsing line: " + std::string(str.begin(), str.end()), nullptr);
return *pos++;
}
@ -115,7 +115,7 @@ void AssDialogue::Parse(std::string const& raw) {
str = agi::StringRange(raw.begin() + 9, raw.end());
}
else
throw SubtitleFormatParseError("Failed parsing line: " + raw, 0);
throw SubtitleFormatParseError("Failed parsing line: " + raw, nullptr);
tokenizer tkn(str);
@ -169,8 +169,8 @@ std::string AssDialogue::GetData(bool ssa) const {
append_str(str, End.GetAssFormated());
append_unsafe_str(str, Style);
append_unsafe_str(str, Actor);
for (int i = 0; i < 3; ++i)
append_int(str, Margin[i]);
for (auto margin : Margin)
append_int(str, margin);
append_unsafe_str(str, Effect);
str += Text.get();
@ -224,7 +224,7 @@ std::auto_ptr<boost::ptr_vector<AssDialogueBlock>> AssDialogue::ParseTags() cons
}
else {
// Create block
AssDialogueBlockOverride *block = new AssDialogueBlockOverride(work);
auto block = new AssDialogueBlockOverride(work);
block->ParseTags();
Blocks.push_back(block);
@ -282,7 +282,7 @@ std::string AssDialogue::GetStrippedText() const {
}
AssEntry *AssDialogue::Clone() const {
AssDialogue *clone = new AssDialogue(*this);
auto clone = new AssDialogue(*this);
*const_cast<int *>(&clone->Id) = Id;
return clone;
}

View file

@ -75,7 +75,7 @@ protected:
/// Text of this block
std::string text;
public:
AssDialogueBlock(std::string const& text) : text(text) { }
AssDialogueBlock(std::string text) : text(std::move(text)) { }
virtual ~AssDialogueBlock() { }
virtual AssBlockType GetType() const = 0;
@ -174,7 +174,7 @@ public:
/// Does this line collide with the passed line?
bool CollidesWith(const AssDialogue *target) const;
AssEntry *Clone() const;
AssEntry *Clone() const override;
AssDialogue();
AssDialogue(AssDialogue const&);

View file

@ -43,10 +43,10 @@ static FilterList& filters() {
return instance;
}
AssExportFilter::AssExportFilter(std::string const& name, std::string const& description, int priority)
: name(name)
AssExportFilter::AssExportFilter(std::string name, std::string description, int priority)
: name(std::move(name))
, priority(priority)
, description(description)
, description(std::move(description))
{
}

View file

@ -59,7 +59,7 @@ class AssExportFilter : public boost::intrusive::make_list_base_hook<boost::intr
std::string description;
public:
AssExportFilter(std::string const& name, std::string const& description, int priority = 0);
AssExportFilter(std::string name, std::string description, int priority = 0);
virtual ~AssExportFilter() { };
std::string const& GetName() const { return name; }
@ -69,12 +69,12 @@ public:
/// @param subs Subtitles to process
/// @param parent_window Window to use as the parent if the filter wishes
/// to open a progress dialog
virtual void ProcessSubs(AssFile *subs, wxWindow *parent_window=0)=0;
virtual void ProcessSubs(AssFile *subs, wxWindow *parent_window=nullptr)=0;
/// Draw setup controls
/// @param parent Parent window to add controls to
/// @param c Project context
virtual wxWindow *GetConfigDialogWindow(wxWindow *parent, agi::Context *c) { return 0; }
virtual wxWindow *GetConfigDialogWindow(wxWindow *parent, agi::Context *c) { return nullptr; }
/// Load settings to use from the configuration dialog
/// @param is_default If true use default settings instead

View file

@ -74,7 +74,7 @@ public:
/// @param file Target filename
/// @param charset Target charset
/// @param parent_window Parent window the filters should use when opening dialogs
void Export(agi::fs::path const& file, std::string const& charset, wxWindow *parent_window= 0);
void Export(agi::fs::path const& file, std::string const& charset, wxWindow *parent_window= nullptr);
/// Add configuration panels for all registered filters to the target sizer
/// @param parent Parent window for controls

View file

@ -138,7 +138,7 @@ public:
/// @param commitId Commit to amend rather than pushing a new commit
/// @param single_line Line which was changed, if only one line was
/// @return Unique identifier for the new undo group
int Commit(wxString const& desc, int type, int commitId = -1, AssEntry *single_line = 0);
int Commit(wxString const& desc, int type, int commitId = -1, AssEntry *single_line = nullptr);
/// Comparison function for use when sorting
typedef bool (*CompFunc)(const AssDialogue* lft, const AssDialogue* rgt);

View file

@ -24,7 +24,7 @@ class AssInfo : public AssEntry {
public:
AssInfo(AssInfo const& o) : key(o.key), value(o.value) { }
AssInfo(std::string const& key, std::string const& value) : key(key), value(value) { }
AssInfo(std::string key, std::string value) : key(std::move(key)), value(std::move(value)) { }
AssEntry *Clone() const override { return new AssInfo(*this); }
AssEntryGroup Group() const override { return AssEntryGroup::INFO; }

View file

@ -294,7 +294,7 @@ void AssKaraoke::SplitLines(std::set<AssDialogue*> const& lines, agi::Context *c
bool in_sel = sel.count(diag) > 0;
for (auto const& syl : kara) {
AssDialogue *new_line = new AssDialogue(*diag);
auto new_line = new AssDialogue(*diag);
new_line->Start = syl.start_time;
new_line->End = syl.start_time + syl.duration;

View file

@ -60,7 +60,7 @@ public:
/// @param line Initial line
/// @param auto_split Should the line automatically be split on spaces if there are no k tags?
/// @param normalize Should the total duration of the syllables be forced to equal the line duration?
AssKaraoke(AssDialogue *line = 0, bool auto_split = false, bool normalize = true);
AssKaraoke(AssDialogue *line = nullptr, bool auto_split = false, bool normalize = true);
/// Parse a dialogue line
void SetLine(AssDialogue *line, bool auto_split = false, bool normalize = true);

View file

@ -79,7 +79,7 @@ AssOverrideParameter::~AssOverrideParameter() {
}
template<> std::string AssOverrideParameter::Get<std::string>() const {
if (omitted) throw agi::InternalError("AssOverrideParameter::Get() called on omitted parameter", 0);
if (omitted) throw agi::InternalError("AssOverrideParameter::Get() called on omitted parameter", nullptr);
if (block.get()) {
std::string str(block->GetText());
if (boost::starts_with(str, "{")) str.erase(begin(str));

View file

@ -81,7 +81,7 @@ void AssParser::ParseScriptInfoLine(std::string const& data) {
else if (version_str == "v4.00+")
version = 1;
else
throw SubtitleFormatParseError("Unknown SSA file format version", 0);
throw SubtitleFormatParseError("Unknown SSA file format version", nullptr);
}
// Nothing actually supports the Collisions property and malformed values

View file

@ -80,7 +80,7 @@ class parser {
std::string next_tok() {
if (pos.eof())
throw SubtitleFormatParseError("Malformed style: not enough fields", 0);
throw SubtitleFormatParseError("Malformed style: not enough fields", nullptr);
return agi::str(trim_copy(*pos++));
}
@ -93,7 +93,7 @@ public:
void check_done() const {
if (!pos.eof())
throw SubtitleFormatParseError("Malformed style: too many fields", 0);
throw SubtitleFormatParseError("Malformed style: too many fields", nullptr);
}
std::string next_str() { return next_tok(); }
@ -104,7 +104,7 @@ public:
return boost::lexical_cast<int>(next_tok());
}
catch (boost::bad_lexical_cast const&) {
throw SubtitleFormatParseError("Malformed style: bad int field", 0);
throw SubtitleFormatParseError("Malformed style: bad int field", nullptr);
}
}
@ -113,7 +113,7 @@ public:
return boost::lexical_cast<double>(next_tok());
}
catch (boost::bad_lexical_cast const&) {
throw SubtitleFormatParseError("Malformed style: bad double field", 0);
throw SubtitleFormatParseError("Malformed style: bad double field", nullptr);
}
}

View file

@ -97,5 +97,5 @@ AssStyle *AssStyleStorage::GetStyle(std::string const& name) {
if (boost::iequals(cur->name, name))
return cur.get();
}
return 0;
return nullptr;
}

View file

@ -89,9 +89,9 @@ int AssTime::GetTimeSeconds() const { return (time % 60000) / 1000; }
int AssTime::GetTimeMiliseconds() const { return (time % 1000); }
int AssTime::GetTimeCentiseconds() const { return (time % 1000) / 10; }
SmpteFormatter::SmpteFormatter(agi::vfr::Framerate fps, std::string const& sep)
: fps(fps)
, sep(sep)
SmpteFormatter::SmpteFormatter(agi::vfr::Framerate fps, std::string sep)
: fps(std::move(fps))
, sep(std::move(sep))
{
}

View file

@ -56,7 +56,7 @@ class SmpteFormatter {
std::string sep;
public:
SmpteFormatter(agi::vfr::Framerate fps, std::string const& sep=":");
SmpteFormatter(agi::vfr::Framerate fps, std::string sep=":");
/// Convert an AssTime to a SMPTE timecode
std::string ToSMPTE(AssTime time) const;

View file

@ -105,7 +105,7 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
wxSizer *VertVolArea = new wxBoxSizer(wxVERTICAL);
VertVolArea->Add(VertVol,1,wxEXPAND,0);
ToggleBitmap *link_btn = new ToggleBitmap(panel, context, "audio/opt/vertical_link", 16, "Audio", wxSize(20, -1));
auto link_btn = new ToggleBitmap(panel, context, "audio/opt/vertical_link", 16, "Audio", wxSize(20, -1));
link_btn->SetMaxSize(wxDefaultSize);
VertVolArea->Add(link_btn, 0, wxRIGHT | wxALIGN_CENTER | wxEXPAND, 0);
OPT_SUB("Audio/Link", &AudioBox::OnVerticalLink, this);
@ -119,7 +119,7 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
context->karaoke = new AudioKaraoke(panel, context);
// Main sizer
wxBoxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
auto MainSizer = new wxBoxSizer(wxVERTICAL);
MainSizer->Add(TopSizer,1,wxEXPAND|wxALL,3);
MainSizer->Add(toolbar::GetToolbar(panel, "audio", context, "Audio"),0,wxEXPAND|wxLEFT|wxRIGHT,3);
MainSizer->Add(context->karaoke,0,wxEXPAND|wxALL,3);

View file

@ -55,7 +55,7 @@ AudioColorScheme::AudioColorScheme(int prec, std::string const& scheme_name, int
case AudioStyle_Inactive: opt_base += "Inactive/"; break;
case AudioStyle_Selected: opt_base += "Selection/"; break;
case AudioStyle_Primary: opt_base += "Primary/"; break;
default: throw agi::InternalError("Unknown audio rendering styling", 0);
default: throw agi::InternalError("Unknown audio rendering styling", nullptr);
}
double h_base = OPT_GET(opt_base + "Hue Offset")->GetDouble();

View file

@ -155,7 +155,7 @@ void AudioController::OnAudioProviderChanged()
void AudioController::OpenAudio(agi::fs::path const& url)
{
if (url.empty())
throw agi::InternalError("AudioController::OpenAudio() was passed an empty string. This must not happen.", 0);
throw agi::InternalError("AudioController::OpenAudio() was passed an empty string. This must not happen.", nullptr);
std::unique_ptr<AudioProvider> new_provider;
try {
@ -204,8 +204,8 @@ void AudioController::CloseAudio()
player.reset();
provider.reset();
player = 0;
provider = 0;
player = nullptr;
provider = nullptr;
audio_url.clear();

View file

@ -199,7 +199,7 @@ public:
RecalculateThumb();
}
bool OnMouseEvent(wxMouseEvent &event)
bool OnMouseEvent(wxMouseEvent &event) override
{
if (event.LeftIsDown())
{
@ -357,7 +357,7 @@ public:
pixel_left = std::max(new_pixel_left, 0);
}
bool OnMouseEvent(wxMouseEvent &event)
bool OnMouseEvent(wxMouseEvent &event) override
{
if (event.LeftDown())
{
@ -475,7 +475,7 @@ class AudioMarkerInteractionObject : public AudioDisplayInteractionObject {
public:
AudioMarkerInteractionObject(std::vector<AudioMarker*> markers, AudioTimingController *timing_controller, AudioDisplay *display, wxMouseButton button_used)
: markers(markers)
: markers(std::move(markers))
, timing_controller(timing_controller)
, display(display)
, button_used(button_used)
@ -484,7 +484,7 @@ public:
{
}
bool OnMouseEvent(wxMouseEvent &event)
bool OnMouseEvent(wxMouseEvent &event) override
{
if (event.Dragging())
{
@ -512,7 +512,7 @@ private:
void Split(int point)
{
iterator it = points.lower_bound(point);
auto it = points.lower_bound(point);
if (it == points.end() || it->first != point)
{
assert(it != points.begin());
@ -523,7 +523,7 @@ private:
void Restyle(int start, int end, AudioRenderingStyle style)
{
assert(points.lower_bound(end) != points.end());
for (iterator pt = points.lower_bound(start); pt->first < end; ++pt)
for (auto pt = points.lower_bound(start); pt->first < end; ++pt)
{
if (style > pt->second)
pt->second = style;
@ -536,7 +536,7 @@ public:
points[0] = AudioStyle_Normal;
}
void AddRange(int start, int end, AudioRenderingStyle style)
void AddRange(int start, int end, AudioRenderingStyle style) override
{
if (start < 0) start = 0;
@ -559,7 +559,7 @@ AudioDisplay::AudioDisplay(wxWindow *parent, AudioController *controller, agi::C
, controller(controller)
, scrollbar(agi::util::make_unique<AudioDisplayScrollbar>(this))
, timeline(agi::util::make_unique<AudioDisplayTimeline>(this))
, dragged_object(0)
, dragged_object(nullptr)
, scroll_left(0)
, pixel_audio_width(0)
, ms_per_pixel(0.0)
@ -1078,7 +1078,7 @@ bool AudioDisplay::ForwardMouseEvent(wxMouseEvent &event) {
if (!dragged_object->OnMouseEvent(event))
{
scroll_timer.Stop();
SetDraggedObject(0);
SetDraggedObject(nullptr);
SetCursor(wxNullCursor);
}
return true;
@ -1087,12 +1087,12 @@ bool AudioDisplay::ForwardMouseEvent(wxMouseEvent &event) {
{
// Something is wrong, we might have lost capture somehow.
// Fix state and pretend it didn't happen.
SetDraggedObject(0);
SetDraggedObject(nullptr);
SetCursor(wxNullCursor);
}
const wxPoint mousepos = event.GetPosition();
AudioDisplayInteractionObject *new_obj = 0;
AudioDisplayInteractionObject *new_obj = nullptr;
// Check for scrollbar action
if (scrollbar->GetBounds().Contains(mousepos))
{

View file

@ -54,7 +54,7 @@
template<class Container, class Value>
static inline size_t last_lt_or_eq(Container const& c, Value const& v) {
typename Container::const_iterator it = lower_bound(c.begin(), c.end(), v);
auto it = lower_bound(c.begin(), c.end(), v);
// lower_bound gives first >=
if (it == c.end() || *it > v)
--it;
@ -137,7 +137,7 @@ void AudioKaraoke::OnAudioOpened() {
}
void AudioKaraoke::OnAudioClosed() {
c->audioController->SetTimingController(0);
c->audioController->SetTimingController(nullptr);
}
void AudioKaraoke::SetEnabled(bool en) {
@ -236,8 +236,8 @@ void AudioKaraoke::RenderText() {
// Draw the lines between each syllable
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
for (size_t i = 0; i < syl_lines.size(); ++i)
dc.DrawLine(syl_lines[i], 0, syl_lines[i], bmp_size.GetHeight());
for (auto syl_line : syl_lines)
dc.DrawLine(syl_line, 0, syl_line, bmp_size.GetHeight());
}
void AudioKaraoke::AddMenuItem(wxMenu &menu, std::string const& tag, wxString const& help, std::string const& selected) {

View file

@ -37,10 +37,10 @@ class AudioMarkerKeyframe : public AudioMarker {
int position;
public:
AudioMarkerKeyframe(Pen *style, int position) : style(style), position(position) { }
int GetPosition() const { return position; }
FeetStyle GetFeet() const { return Feet_None; }
bool CanSnap() const { return true; }
wxPen GetStyle() const { return *style; }
int GetPosition() const override { return position; }
FeetStyle GetFeet() const override { return Feet_None; }
bool CanSnap() const override { return true; }
wxPen GetStyle() const override { return *style; }
operator int() const { return position; }
};
@ -99,10 +99,10 @@ public:
void SetPosition(int new_pos) { position = new_pos; }
int GetPosition() const { return position; }
FeetStyle GetFeet() const { return Feet_None; }
bool CanSnap() const { return true; }
wxPen GetStyle() const { return style; }
int GetPosition() const override { return position; }
FeetStyle GetFeet() const override { return Feet_None; }
bool CanSnap() const override { return true; }
wxPen GetStyle() const override { return style; }
operator int() const { return position; }
};

View file

@ -151,7 +151,7 @@ public:
/// Get all keyframe markers within a range
/// @param range Time range to get markers for
/// @param[out] out Vector to fill with markers in the range
void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const;
void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const override;
};
/// Marker provider for the current video playback position
@ -170,7 +170,7 @@ public:
VideoPositionMarkerProvider(agi::Context *c);
~VideoPositionMarkerProvider();
void GetMarkers(const TimeRange &range, AudioMarkerVector &out) const;
void GetMarkers(const TimeRange &range, AudioMarkerVector &out) const override;
};
/// Marker provider for lines every second
@ -180,10 +180,10 @@ class SecondsMarkerProvider : public AudioMarkerProvider {
int position;
Marker(Pen *style) : style(style), position(0) { }
int GetPosition() const { return position; }
FeetStyle GetFeet() const { return Feet_None; }
bool CanSnap() const { return false; }
wxPen GetStyle() const;
int GetPosition() const override { return position; }
FeetStyle GetFeet() const override { return Feet_None; }
bool CanSnap() const override { return false; }
wxPen GetStyle() const override;
operator int() const { return position; }
};
@ -203,5 +203,5 @@ class SecondsMarkerProvider : public AudioMarkerProvider {
public:
SecondsMarkerProvider();
void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const;
void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const override;
};

View file

@ -53,7 +53,7 @@ AudioPlayer::AudioPlayer(AudioProvider *provider)
std::unique_ptr<AudioPlayer> AudioPlayerFactory::GetAudioPlayer(AudioProvider *provider) {
std::vector<std::string> list = GetClasses(OPT_GET("Audio/Player")->GetString());
if (list.empty()) throw agi::NoAudioPlayersError("No audio players are available.", 0);
if (list.empty()) throw agi::NoAudioPlayersError("No audio players are available.", nullptr);
std::string error;
for (auto const& factory_name : list) {
@ -64,7 +64,7 @@ std::unique_ptr<AudioPlayer> AudioPlayerFactory::GetAudioPlayer(AudioProvider *p
error += factory_name + " factory: " + err.GetChainedMessage() + "\n";
}
}
throw agi::AudioPlayerOpenError(error, 0);
throw agi::AudioPlayerOpenError(error, nullptr);
}
void AudioPlayerFactory::RegisterProviders() {

View file

@ -59,8 +59,8 @@ OpenALPlayer::OpenALPlayer(AudioProvider *provider)
, start_frame(0)
, cur_frame(0)
, end_frame(0)
, device(0)
, context(0)
, device(nullptr)
, context(nullptr)
, source(0)
, buf_first_free(0)
, buf_first_queued(0)
@ -69,26 +69,26 @@ OpenALPlayer::OpenALPlayer(AudioProvider *provider)
{
try {
// Open device
device = alcOpenDevice(0);
if (!device) throw OpenALException("Failed opening default OpenAL device", 0);
device = alcOpenDevice(nullptr);
if (!device) throw OpenALException("Failed opening default OpenAL device", nullptr);
// Create context
context = alcCreateContext(device, 0);
if (!context) throw OpenALException("Failed creating OpenAL context", 0);
if (!alcMakeContextCurrent(context)) throw OpenALException("Failed selecting OpenAL context", 0);
context = alcCreateContext(device, nullptr);
if (!context) throw OpenALException("Failed creating OpenAL context", nullptr);
if (!alcMakeContextCurrent(context)) throw OpenALException("Failed selecting OpenAL context", nullptr);
// Clear error code
alGetError();
// Generate buffers
alGenBuffers(num_buffers, buffers);
if (alGetError() != AL_NO_ERROR) throw OpenALException("Error generating OpenAL buffers", 0);
if (alGetError() != AL_NO_ERROR) throw OpenALException("Error generating OpenAL buffers", nullptr);
// Generate source
alGenSources(1, &source);
if (alGetError() != AL_NO_ERROR) {
alDeleteBuffers(num_buffers, buffers);
throw OpenALException("Error generating OpenAL source", 0);
throw OpenALException("Error generating OpenAL source", nullptr);
}
}
catch (...)

View file

@ -92,20 +92,20 @@ class OpenALPlayer : public AudioPlayer, wxTimer {
protected:
/// wxTimer override to periodically fill available buffers
void Notify();
void Notify() override;
public:
OpenALPlayer(AudioProvider *provider);
~OpenALPlayer();
void Play(int64_t start,int64_t count);
void Stop();
bool IsPlaying() { return playing; }
void Play(int64_t start,int64_t count) override;
void Stop() override;
bool IsPlaying() override { return playing; }
int64_t GetEndPosition() { return end_frame; }
int64_t GetCurrentPosition();
void SetEndPosition(int64_t pos);
int64_t GetEndPosition() override { return end_frame; }
int64_t GetCurrentPosition() override;
void SetEndPosition(int64_t pos) override;
void SetVolume(double vol) { volume = vol; }
void SetVolume(double vol) override { volume = vol; }
};
#endif

View file

@ -59,7 +59,7 @@ void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count,
if (volume == 1.0) return;
if (bytes_per_sample != 2)
throw agi::InternalError("GetAudioWithVolume called on unconverted audio stream", 0);
throw agi::InternalError("GetAudioWithVolume called on unconverted audio stream", nullptr);
short *buffer = static_cast<int16_t *>(buf);
for (size_t i = 0; i < (size_t)count; ++i)
@ -159,7 +159,7 @@ std::unique_ptr<AudioProvider> AudioProviderFactory::GetProvider(agi::fs::path c
if (!provider) {
std::vector<std::string> list = GetClasses(OPT_GET("Audio/Provider")->GetString());
if (list.empty()) throw agi::NoAudioProvidersError("No audio providers are available.", 0);
if (list.empty()) throw agi::NoAudioProvidersError("No audio providers are available.", nullptr);
for (auto const& name : list) {
provider = creator.try_create(name, [&]() { return Create(name, filename); });
@ -169,9 +169,9 @@ std::unique_ptr<AudioProvider> AudioProviderFactory::GetProvider(agi::fs::path c
if (!provider) {
if (creator.found_audio)
throw agi::AudioProviderOpenError(creator.msg, 0);
throw agi::AudioProviderOpenError(creator.msg, nullptr);
if (creator.found_file)
throw agi::AudioDataNotFoundError(creator.msg, 0);
throw agi::AudioDataNotFoundError(creator.msg, nullptr);
throw agi::fs::FileNotFound(filename);
}
@ -194,7 +194,7 @@ std::unique_ptr<AudioProvider> AudioProviderFactory::GetProvider(agi::fs::path c
// Convert to HD
if (cache == 2) return agi::util::make_unique<HDAudioProvider>(std::move(provider), &progress);
throw agi::AudioCacheOpenError("Unknown caching method", 0);
throw agi::AudioCacheOpenError("Unknown caching method", nullptr);
}
void AudioProviderFactory::RegisterProviders() {

View file

@ -38,13 +38,13 @@ class BitdepthConvertAudioProvider : public AudioProviderWrapper {
public:
BitdepthConvertAudioProvider(std::unique_ptr<AudioProvider> src) : AudioProviderWrapper(std::move(src)) {
if (bytes_per_sample > 8)
throw agi::AudioProviderOpenError("Audio format converter: audio with bitdepths greater than 64 bits/sample is currently unsupported", 0);
throw agi::AudioProviderOpenError("Audio format converter: audio with bitdepths greater than 64 bits/sample is currently unsupported", nullptr);
src_bytes_per_sample = bytes_per_sample;
bytes_per_sample = sizeof(Target);
}
void FillBuffer(void *buf, int64_t start, int64_t count) const {
void FillBuffer(void *buf, int64_t start, int64_t count) const override {
std::vector<char> src_buf(count * src_bytes_per_sample * channels);
source->GetAudio(&src_buf[0], start, count);
@ -81,7 +81,7 @@ public:
float_samples = false;
}
void FillBuffer(void *buf, int64_t start, int64_t count) const {
void FillBuffer(void *buf, int64_t start, int64_t count) const override {
std::vector<Source> src_buf(count * channels);
source->GetAudio(&src_buf[0], start, count);