Use auto more places

This commit is contained in:
Thomas Goyne 2013-09-16 12:10:00 -07:00
parent 0d50820178
commit 6cd6ee9845
10 changed files with 23 additions and 25 deletions

View file

@ -78,9 +78,8 @@ void AudioMarkerProviderKeyframes::Update() {
void AudioMarkerProviderKeyframes::GetMarkers(TimeRange const& range, AudioMarkerVector &out) const {
// Find first and last keyframes inside the range
std::vector<AudioMarkerKeyframe>::const_iterator
a = lower_bound(markers.begin(), markers.end(), range.begin()),
b = upper_bound(markers.begin(), markers.end(), range.end());
auto a = lower_bound(markers.begin(), markers.end(), range.begin());
auto b = upper_bound(markers.begin(), markers.end(), range.end());
// Place pointers to the markers in the output vector
for (; a != b; ++a)

View file

@ -224,7 +224,7 @@ struct time_snap_scene : public validate_video_loaded {
int prev = 0;
int next = 0;
const std::vector<int> &keyframes = con->GetKeyFrames();
auto const& keyframes = con->GetKeyFrames();
if (curFrame < keyframes.front())
next = keyframes.front();
else if (curFrame >= keyframes.back()) {
@ -232,7 +232,7 @@ struct time_snap_scene : public validate_video_loaded {
next = con->GetLength();
}
else {
std::vector<int>::const_iterator kf = std::lower_bound(keyframes.begin(), keyframes.end(), curFrame);
auto kf = std::lower_bound(keyframes.begin(), keyframes.end(), curFrame);
if (*kf == curFrame) {
prev = *kf;
next = *(kf + 1);

View file

@ -360,8 +360,8 @@ struct video_frame_next_keyframe : public validator_video_loaded {
STR_HELP("Seek to the next keyframe")
void operator()(agi::Context *c) {
std::vector<int> const& kf = c->videoController->GetKeyFrames();
std::vector<int>::const_iterator pos = lower_bound(kf.begin(), kf.end(), c->videoController->GetFrameN() + 1);
auto const& kf = c->videoController->GetKeyFrames();
auto pos = lower_bound(kf.begin(), kf.end(), c->videoController->GetFrameN() + 1);
c->videoController->JumpToFrame(pos == kf.end() ? c->videoController->GetLength() - 1 : *pos);
}
@ -431,14 +431,13 @@ struct video_frame_prev_keyframe : public validator_video_loaded {
STR_HELP("Seek to the previous keyframe")
void operator()(agi::Context *c) {
std::vector<int> const& kf = c->videoController->GetKeyFrames();
auto const& kf = c->videoController->GetKeyFrames();
if (kf.empty()) {
c->videoController->JumpToFrame(0);
return;
}
std::vector<int>::const_iterator pos =
lower_bound(kf.begin(), kf.end(), c->videoController->GetFrameN());
auto pos = lower_bound(kf.begin(), kf.end(), c->videoController->GetFrameN());
if (pos != kf.begin())
--pos;

View file

@ -102,8 +102,8 @@ public:
/// @return A pointer to a DialogType or nullptr if no dialog of the given type has been created
template<class DialogType>
DialogType *Get() const {
DialogMap::const_iterator it = created_dialogs.find(&typeid(DialogType));
return it != created_dialogs.end() ? static_cast<DialogType*>(it->second) : 0;
auto it = created_dialogs.find(&typeid(DialogType));
return it != created_dialogs.end() ? static_cast<DialogType*>(it->second) : nullptr;
}
~DialogManager() {

View file

@ -81,7 +81,7 @@ static wxString get_history_string(json::Object &obj) {
lines = wxString::Format(_("from %d onward"), (int)(int64_t)sel.front()["start"]);
else {
lines += _("sel ");
for (json::Array::const_iterator it = sel.begin(); it != sel.end(); ++it) {
for (auto it = sel.begin(); it != sel.end(); ++it) {
int beg = (int64_t)(*it)["start"];
int end = (int64_t)(*it)["end"];
if (beg == end)

View file

@ -110,7 +110,7 @@ void FontCollector::ProcessDialogueLine(const AssDialogue *line, int index) {
if (overriden)
used_styles[style].lines.insert(index);
std::set<wxUniChar>& chars = used_styles[style].chars;
for (wxString::const_iterator it = text.begin(); it != text.end(); ++it) {
for (auto it = text.begin(); it != text.end(); ++it) {
wxUniChar cur = *it;
if (cur == L'\\' && it + 1 != text.end()) {
wxUniChar next = *++it;

View file

@ -279,7 +279,7 @@ struct CommandMenuBar : public wxMenuBar {
/// @param[out] value Output value to write to
/// @return Was the requested index found
bool read_entry(json::Object const& obj, const char *name, std::string *value) {
json::Object::const_iterator it = obj.find(name);
auto it = obj.find(name);
if (it == obj.end()) return false;
*value = static_cast<json::String const&>(it->second);
return true;
@ -313,7 +313,7 @@ menu_map const& get_menus_root() {
menu_items const& get_menu(std::string const& name) {
menu_map const& root = get_menus_root();
menu_map::const_iterator it = root.find(name);
auto it = root.find(name);
if (it == root.end()) throw menu::UnknownMenu("Menu named " + name + " not found");
return it->second;
}

View file

@ -69,14 +69,14 @@ std::string Spline::EncodeToAss() const {
result.reserve(size() * 10);
char last = 0;
for (const_iterator cur = begin(); cur != end(); ++cur) {
switch (cur->type) {
for (auto const& pt : *this) {
switch (pt.type) {
case SplineCurve::POINT:
if (last != 'm') {
result += "m ";
last = 'm';
}
result += ToScript(cur->p1).DStr(' ');
result += ToScript(pt.p1).DStr(' ');
break;
case SplineCurve::LINE:
@ -84,7 +84,7 @@ std::string Spline::EncodeToAss() const {
result += "l ";
last = 'l';
}
result += ToScript(cur->p2).DStr(' ');
result += ToScript(pt.p2).DStr(' ');
break;
case SplineCurve::BICUBIC:
@ -92,9 +92,9 @@ std::string Spline::EncodeToAss() const {
result += "b ";
last = 'b';
}
result += ToScript(cur->p2).DStr(' ') + " ";
result += ToScript(cur->p3).DStr(' ') + " ";
result += ToScript(cur->p4).DStr(' ');
result += ToScript(pt.p2).DStr(' ') + " ";
result += ToScript(pt.p3).DStr(' ') + " ";
result += ToScript(pt.p4).DStr(' ');
break;
default: break;

View file

@ -101,7 +101,7 @@ namespace {
/// Populate the toolbar with buttons
void Populate() {
json::Object const& root = get_root();
json::Object::const_iterator root_it = root.find(name);
auto root_it = root.find(name);
if (root_it == root.end()) {
// Toolbar names are all hardcoded so this should never happen
throw agi::InternalError("Toolbar named " + name + " not found.", 0);

View file

@ -127,7 +127,7 @@ void VideoSlider::OnMouse(wxMouseEvent &event) {
// Shift click to snap to keyframe
if (event.ShiftDown() && keyframes.size()) {
int clickedFrame = GetValueAtX(x);
std::vector<int>::const_iterator pos = lower_bound(keyframes.begin(), keyframes.end(), clickedFrame);
auto pos = lower_bound(keyframes.begin(), keyframes.end(), clickedFrame);
if (pos == keyframes.end())
--pos;
else if (pos + 1 != keyframes.end() && clickedFrame - *pos > (*pos + 1) - clickedFrame)