Replace most uses of type::iterator with auto

This commit is contained in:
Thomas Goyne 2012-12-22 15:35:13 -08:00
parent d0f4d9df99
commit 6e3cc883b3
16 changed files with 28 additions and 32 deletions

View File

@ -79,7 +79,7 @@ wxString AegisubLocale::PickLanguage() {
// Check if user local language is available, if so, make it first
const wxLanguageInfo *info = wxLocale::GetLanguageInfo(wxLocale::GetSystemLanguage());
if (info) {
wxArrayString::iterator it = std::find(langs.begin(), langs.end(), info->CanonicalName);
auto it = std::find(langs.begin(), langs.end(), info->CanonicalName);
if (it != langs.end())
std::rotate(langs.begin(), it, it + 1);
}

View File

@ -115,9 +115,8 @@ void AssExporter::Export(wxString const& filename, wxString const& charset, wxWi
}
wxSizer *AssExporter::GetSettingsSizer(wxString const& name) {
std::map<wxString, wxSizer*>::iterator pos = Sizers.find(name);
if (pos == Sizers.end()) return 0;
return pos->second;
auto pos = Sizers.find(name);
return pos == Sizers.end() ? nullptr : pos->second;
}
wxString const& AssExporter::GetDescription(wxString const& name) const {

View File

@ -212,7 +212,7 @@ void AssKaraoke::AddSplit(size_t syl_idx, size_t pos) {
// Move all override tags after the split to the new syllable and fix the indices
size_t text_len = syl.text.size();
for (ovr_iterator it = syl.ovr_tags.begin(); it != syl.ovr_tags.end(); ) {
for (auto it = syl.ovr_tags.begin(); it != syl.ovr_tags.end(); ) {
if (it->first < text_len)
++it;
else {

View File

@ -49,7 +49,6 @@ public:
wxString GetText(bool k_tag) const;
};
private:
typedef std::map<size_t, wxString>::iterator ovr_iterator;
std::vector<Syllable> syls;
AssDialogue *active_line;

View File

@ -493,7 +493,7 @@ void AssOverrideTag::Clear() {
void AssOverrideTag::SetText(const wxString &text) {
load_protos();
for (AssOverrideTagProto::iterator cur = proto.begin(); cur != proto.end(); ++cur) {
for (auto cur = proto.begin(); cur != proto.end(); ++cur) {
if (text.StartsWith(cur->name)) {
Name = cur->name;
parse_parameters(this, text.Mid(Name.length()), cur);

View File

@ -806,8 +806,8 @@ void AudioDisplay::OnPaint(wxPaintEvent&)
void AudioDisplay::PaintAudio(wxDC &dc, TimeRange updtime, wxRect updrect)
{
std::map<int, int>::iterator pt = style_ranges.upper_bound(updtime.begin());
std::map<int, int>::iterator pe = style_ranges.upper_bound(updtime.end());
auto pt = style_ranges.upper_bound(updtime.begin());
auto pe = style_ranges.upper_bound(updtime.end());
if (pt != style_ranges.begin())
--pt;

View File

@ -110,7 +110,7 @@ void PortAudioPlayer::GatherDevices(PaHostApiIndex host_idx) {
if (device_info->maxOutputChannels <= 0) continue;
// MME truncates device names so check for prefix rather than exact match
std::map<std::string, DeviceVec>::iterator dev_it = devices.lower_bound(device_info->name);
auto dev_it = devices.lower_bound(device_info->name);
if (dev_it == devices.end() || dev_it->first.find(device_info->name) != 0) {
devices[device_info->name];
--dev_it;
@ -275,7 +275,7 @@ wxArrayString PortAudioPlayer::GetOutputDevices() {
try {
PortAudioPlayer player(0);
for (std::map<std::string, DeviceVec>::iterator it = player.devices.begin(); it != player.devices.end(); ++it)
for (auto it = player.devices.begin(); it != player.devices.end(); ++it)
list.push_back(to_wx(it->first));
}
catch (PortAudioError const&) {

View File

@ -285,7 +285,7 @@ void AudioTimingControllerKaraoke::Revert() {
markers.reserve(kara->size());
labels.reserve(kara->size());
for (AssKaraoke::iterator it = kara->begin(); it != kara->end(); ++it) {
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(it->text, TimeRange(it->start_time, it->start_time + it->duration));

View File

@ -516,7 +516,7 @@ namespace Automation4 {
modification_type |= modification_mask(e);
// Find the appropriate place to put it
std::vector<AssEntry*>::iterator it = lines.end();
auto it = lines.end();
if (!lines.empty()) {
do {
--it;
@ -592,14 +592,14 @@ namespace Automation4 {
lua_rawseti(L, -2, idx++);
AssKaraoke kara(dia, false, false);
for (AssKaraoke::iterator it = kara.begin(); it != kara.end(); ++it) {
for (auto const& syl : kara) {
lua_newtable(L);
set_field(L, "duration", it->duration);
set_field(L, "start_time", it->start_time - dia->Start);
set_field(L, "end_time", it->start_time + it->duration - dia->Start);
set_field(L, "tag", it->tag_type);
set_field(L, "text", it->GetText(false));
set_field(L, "text_stripped", it->text);
set_field(L, "duration", syl.duration);
set_field(L, "start_time", syl.start_time - dia->Start);
set_field(L, "end_time", syl.start_time + syl.duration - dia->Start);
set_field(L, "tag", syl.tag_type);
set_field(L, "text", syl.GetText(false));
set_field(L, "text_stripped", syl.text);
lua_rawseti(L, -2, idx++);
}

View File

@ -209,7 +209,7 @@ public:
// Sum up data size until we hit the max
size_t cur_size = 0;
size_t block_size = factory.GetBlockSize();
typename AgeList::iterator it = age.begin();
auto it = age.begin();
for (; it != age.end() && cur_size < max_size; ++it)
{
BlockArray &ba = (*it)->blocks;

View File

@ -47,7 +47,7 @@ class DialogManager {
wxDialog *dialog = static_cast<wxDialog*>(evt.GetEventObject());
dialog->Destroy();
for (DialogMap::iterator it = created_dialogs.begin(); it != created_dialogs.end(); ++it) {
for (auto it = created_dialogs.begin(); it != created_dialogs.end(); ++it) {
if (it->second == dialog) {
created_dialogs.erase(it);
return;
@ -60,7 +60,7 @@ public:
/// @tparam DialogType Type of dialog to show
template<class DialogType>
void Show(agi::Context *c) {
DialogMap::iterator it = created_dialogs.find(&typeid(DialogType));
auto it = created_dialogs.find(&typeid(DialogType));
if (it != created_dialogs.end()) {
it->second->Show();

View File

@ -704,7 +704,7 @@ void DialogStyleManager::UpdateButtons() {
template<class Cont>
static void do_move(Cont& styls, int type, int& first, int& last, bool storage) {
typename Cont::iterator begin = styls.begin();
auto begin = styls.begin();
// Move up
if (type == 0) {

View File

@ -315,7 +315,7 @@ FrameMain::FrameMain (wxArrayString args)
static bool delete_children(wxWindow *window, wxWindow *keep) {
bool found = false;
while (window->GetChildren().size() > (size_t)found) {
wxWindowList::iterator it = window->GetChildren().begin();
auto it = window->GetChildren().begin();
if (*it == keep)
found = true;

View File

@ -338,10 +338,8 @@ void OpenGLText::GetExtent(wxString const& text, int &w, int &h) {
}
OpenGLTextGlyph const& OpenGLText::GetGlyph(int i) {
glyphMap::iterator res = glyphs.find(i);
if (res != glyphs.end()) return res->second;
return CreateGlyph(i);
auto res = glyphs.find(i);
return res != glyphs.end() ? res->second : CreateGlyph(i);
}
OpenGLTextGlyph const& OpenGLText::CreateGlyph(int n) {

View File

@ -80,7 +80,7 @@ wxString StandardPaths::DoDecodePath(wxString path) {
}
// Replace ?part if valid
std::map<wxString,wxString>::iterator iter = paths.find(path1);
auto iter = paths.find(path1);
if (iter == paths.end()) return path;
wxString final = iter->second + "/" + path2;
final.Replace("//","/");

View File

@ -185,7 +185,7 @@ void VisualToolVectorClip::MakeFeatures() {
sel_features.clear();
features.clear();
active_feature = features.end();
for (Spline::iterator it = spline.begin(); it != spline.end(); ++it)
for (auto it = spline.begin(); it != spline.end(); ++it)
MakeFeature(it);
}
@ -217,7 +217,7 @@ bool VisualToolVectorClip::InitializeDrag(feature_iterator feature) {
feature->curve->p2 = feature->curve->p4;
}
else {
Spline::iterator next = std::next(feature->curve);
auto next = std::next(feature->curve);
if (next != spline.end()) {
if (feature->curve->type == SplineCurve::POINT) {
next->p1 = next->EndPoint();