Skip to content
Snippets Groups Projects
Commit 7ed09b90 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #28351: videov4l2: use range-based for loops

parent 4461bd9e
No related branches found
No related tags found
No related merge requests found
...@@ -121,10 +121,9 @@ static const unsigned pixelformats_supported[] = { ...@@ -121,10 +121,9 @@ static const unsigned pixelformats_supported[] = {
namespace { namespace {
unsigned int pixelformat_score(unsigned pixelformat) unsigned int pixelformat_score(unsigned pixelformat)
{ {
size_t n = sizeof pixelformats_supported / sizeof *pixelformats_supported; for (const auto &iter : pixelformats_supported)
for (unsigned int i = 0; i < n ; ++i) if (iter == pixelformat)
if (pixelformats_supported[i] == pixelformat) return iter;
return i;
return UINT_MAX - 1; return UINT_MAX - 1;
} }
...@@ -137,9 +136,9 @@ vector<string> VideoV4l2Size::getRateList() ...@@ -137,9 +136,9 @@ vector<string> VideoV4l2Size::getRateList()
{ {
vector<string> v; vector<string> v;
for (vector<float>::const_iterator i = rates_.begin() ; i != rates_.end(); ++i) { for (const auto &iter : rates_) {
std::stringstream ss; std::stringstream ss;
ss << *i; ss << iter;
v.push_back(ss.str()); v.push_back(ss.str());
} }
...@@ -201,9 +200,9 @@ vector<string> VideoV4l2Channel::getSizeList() const ...@@ -201,9 +200,9 @@ vector<string> VideoV4l2Channel::getSizeList() const
{ {
vector<string> v; vector<string> v;
for (vector<VideoV4l2Size>::const_iterator itr = sizes_.begin(); itr != sizes_.end(); ++itr) { for (const auto &iter : sizes_) {
std::stringstream ss; std::stringstream ss;
ss << itr->width << "x" << itr->height; ss << iter.width << "x" << iter.height;
v.push_back(ss.str()); v.push_back(ss.str());
} }
...@@ -309,11 +308,11 @@ void VideoV4l2Channel::getFormat(int fd) ...@@ -309,11 +308,11 @@ void VideoV4l2Channel::getFormat(int fd)
VideoV4l2Size VideoV4l2Channel::getSize(const string &name) const VideoV4l2Size VideoV4l2Channel::getSize(const string &name) const
{ {
for (vector<VideoV4l2Size>::const_iterator i = sizes_.begin(); i != sizes_.end(); ++i) { for (const auto &iter : sizes_) {
std::stringstream ss; std::stringstream ss;
ss << i->width << "x" << i->height; ss << iter.width << "x" << iter.height;
if (ss.str() == name) if (ss.str() == name)
return *i; return iter;
} }
// fallback to last size // fallback to last size
...@@ -354,8 +353,8 @@ vector<string> VideoV4l2Device::getChannelList() const ...@@ -354,8 +353,8 @@ vector<string> VideoV4l2Device::getChannelList() const
{ {
vector<string> v; vector<string> v;
for (vector<VideoV4l2Channel>::const_iterator itr = channels_.begin(); itr != channels_.end(); ++itr) for (const auto &itr : channels_)
v.push_back(itr->name); v.push_back(itr.name);
return v; return v;
} }
...@@ -363,9 +362,9 @@ vector<string> VideoV4l2Device::getChannelList() const ...@@ -363,9 +362,9 @@ vector<string> VideoV4l2Device::getChannelList() const
const VideoV4l2Channel & const VideoV4l2Channel &
VideoV4l2Device::getChannel(const string &name) const VideoV4l2Device::getChannel(const string &name) const
{ {
for (vector<VideoV4l2Channel>::const_iterator itr = channels_.begin(); itr != channels_.end(); ++itr) for (const auto &iter : channels_)
if (itr->name == name) if (iter.name == name)
return *itr; return iter;
return channels_.back(); return channels_.back();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment