]> sigrok.org Git - pulseview.git/commitdiff
Replaced lengthy iterator types with the auto keyword
authorJoel Holdsworth <redacted>
Tue, 20 May 2014 18:21:06 +0000 (19:21 +0100)
committerJoel Holdsworth <redacted>
Fri, 23 May 2014 22:24:23 +0000 (23:24 +0100)
13 files changed:
pv/data/decode/decoder.cpp
pv/data/decode/rowdata.cpp
pv/data/decoderstack.cpp
pv/devicemanager.cpp
pv/dialogs/connect.cpp
pv/popups/probes.cpp
pv/prop/binding/decoderoptions.cpp
pv/sigsession.cpp
pv/toolbars/samplingbar.cpp
pv/view/decodetrace.cpp
pv/view/header.cpp
pv/view/logicsignal.cpp
pv/view/view.cpp

index 44e474b942c4bfbd82281b42c8d7d909b7430d6f..13c40a355aafdad2aa3961e7be524bfb8a510616 100644 (file)
@@ -42,8 +42,7 @@ Decoder::Decoder(const srd_decoder *const dec) :
 
 Decoder::~Decoder()
 {
-       for (map<string, GVariant*>::const_iterator i = _options.begin();
-               i != _options.end(); i++)
+       for (auto i = _options.begin(); i != _options.end(); i++)
                g_variant_unref((*i).second);
 }
 
@@ -101,10 +100,7 @@ bool Decoder::have_required_probes() const
 set< shared_ptr<pv::data::Logic> > Decoder::get_data()
 {
        set< shared_ptr<pv::data::Logic> > data;
-       for(map<const srd_channel*, shared_ptr<view::LogicSignal> >::
-               const_iterator i = _probes.begin();
-               i != _probes.end(); i++)
-       {
+       for(auto i = _probes.cbegin(); i != _probes.cend(); i++) {
                shared_ptr<view::LogicSignal> signal((*i).second);
                assert(signal);
                data.insert(signal->logic_data());
@@ -118,8 +114,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_si
        GHashTable *const opt_hash = g_hash_table_new_full(g_str_hash,
                g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
 
-       for (map<string, GVariant*>::const_iterator i = _options.begin();
-               i != _options.end(); i++)
+       for (auto i = _options.cbegin(); i != _options.cend(); i++)
        {
                GVariant *const value = (*i).second;
                g_variant_ref(value);
@@ -138,9 +133,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_si
        GHashTable *const probes = g_hash_table_new_full(g_str_hash,
                g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
 
-       for(map<const srd_channel*, shared_ptr<view::LogicSignal> >::
-               const_iterator i = _probes.begin();
-               i != _probes.end(); i++)
+       for(auto i = _probes.cbegin(); i != _probes.cend(); i++)
        {
                shared_ptr<view::LogicSignal> signal((*i).second);
                GVariant *const gvar = g_variant_new_int32(
index 87da27cf5ce9d724e214f880f625a67eadc2c49a..299380c8053b8861143f5c2f9e1bb5bb6cd86bb0 100644 (file)
@@ -41,8 +41,7 @@ void RowData::get_annotation_subset(
        vector<pv::data::decode::Annotation> &dest,
        uint64_t start_sample, uint64_t end_sample) const
 {
-       for (vector<Annotation>::const_iterator i = _annotations.begin();
-               i != _annotations.end(); i++)
+       for (auto i = _annotations.cbegin(); i != _annotations.cend(); i++)
                if ((*i).end_sample() > start_sample &&
                        (*i).start_sample() <= end_sample)
                        dest.push_back(*i);
index c3bf26d25699c12135707b40512414c9ee0ef4f3..f82d3ecc1ef82f32dbfbee4f460d5af588a2fd1c 100644 (file)
@@ -106,7 +106,7 @@ void DecoderStack::remove(int index)
        assert(index < (int)_stack.size());
 
        // Find the decoder in the stack
-       list< shared_ptr<Decoder> >::iterator iter = _stack.begin();
+       auto iter = _stack.begin();
        for(int i = 0; i < index; i++, iter++)
                assert(iter != _stack.end());
 
@@ -159,8 +159,7 @@ void DecoderStack::get_annotation_subset(
 {
        lock_guard<mutex> lock(_output_mutex);
 
-       std::map<const Row, decode::RowData>::const_iterator iter =
-               _rows.find(row);
+       const auto iter = _rows.find(row);
        if (iter != _rows.end())
                (*iter).second.get_annotation_subset(dest,
                        start_sample, end_sample);
@@ -265,8 +264,7 @@ uint64_t DecoderStack::get_max_sample_count() const
 {
        uint64_t max_sample_count = 0;
 
-       for (map<const Row, RowData>::const_iterator i = _rows.begin();
-               i != _rows.end(); i++)
+       for (auto i = _rows.cbegin(); i != _rows.end(); i++)
                max_sample_count = max(max_sample_count,
                        (*i).second.get_max_sample());
 
@@ -396,11 +394,10 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder)
        const srd_decoder *const decc = pdata->pdo->di->decoder;
        assert(decc);
 
-       map<const Row, decode::RowData>::iterator row_iter = d->_rows.end();
+       auto row_iter = d->_rows.end();
        
        // Try looking up the sub-row of this class
-       const map<pair<const srd_decoder*, int>, Row>::const_iterator r =
-               d->_class_rows.find(make_pair(decc, a.format()));
+       const auto r = d->_class_rows.find(make_pair(decc, a.format()));
        if (r != d->_class_rows.end())
                row_iter = d->_rows.find((*r).second);
        else
index fb487a8163feb38861cf0f384a792d2704ebbf2c..7a986c5a35e86242aa6e446e5d55eaf69c8cd100 100644 (file)
@@ -65,7 +65,7 @@ list< shared_ptr<device::Device> > DeviceManager::driver_scan(
 
        // Remove any device instances from this driver from the device
        // list. They will not be valid after the scan.
-       list< shared_ptr<device::Device> >::iterator i = _devices.begin();
+       auto i = _devices.begin();
        while (i != _devices.end()) {
                if ((*i)->dev_inst()->driver == driver)
                        i = _devices.erase(i);
index d5ab9c4789f6dd9d79b4e601518bc9c4cd27bc44..1dd8c5077301dbebde604aa64fa9463328df5573 100644 (file)
@@ -92,8 +92,7 @@ shared_ptr<device::Device> Connect::get_selected_device() const
                Qt::UserRole).value<void*>();
        assert(sdi);
 
-       std::map<const sr_dev_inst*, boost::shared_ptr<pv::device::Device> >::
-               const_iterator iter = _device_map.find(sdi);
+       const auto iter = _device_map.find(sdi);
        assert(iter != _device_map.end());
 
        return (*iter).second;
index ca1a2fb609a5da541dceb0cd017dd8cb6f0960f3..8683ab248eb0965ce44289869c9f9160781edef4 100644 (file)
@@ -83,8 +83,7 @@ Probes::Probes(SigSession &session, QWidget *parent) :
                        const sr_channel *const probe = (const sr_channel*)p->data;
                        assert(probe);
 
-                       const map<const sr_channel*, shared_ptr<Signal> >::
-                               iterator iter = signal_map.find(probe);
+                       const auto iter = signal_map.find(probe);
                        assert(iter != signal_map.end());
 
                        group_sigs.push_back((*iter).second);
index 063daf8e13d08739bc7241e50e0f2480eb388021..6e0630c00dd1d55f853c8614d97589b9566b12b6 100644 (file)
@@ -111,7 +111,7 @@ GVariant* DecoderOptions::getter(const char *id)
 
        // Get the value from the hash table if it is already present
        const map<string, GVariant*>& options = _decoder->options();
-       map<string, GVariant*>::const_iterator iter = options.find(id);
+       const auto iter = options.find(id);
 
        if (iter != options.end())
                val = (*iter).second;
index 5ba2e5da06e1a366990824c7b8989526381f0631..6948ced138a43dcc6e0792b0d5c13f9a0eaf205f 100644 (file)
@@ -290,10 +290,7 @@ vector< shared_ptr<view::DecodeTrace> > SigSession::get_decode_signals() const
 
 void SigSession::remove_decode_signal(view::DecodeTrace *signal)
 {
-       for (vector< shared_ptr<view::DecodeTrace> >::iterator i =
-               _decode_traces.begin();
-               i != _decode_traces.end();
-               i++)
+       for (auto i = _decode_traces.begin(); i != _decode_traces.end(); i++)
                if ((*i).get() == signal)
                {
                        _decode_traces.erase(i);
index 085e0430582e08b5ff488b7b1d2a708ef35bca35..6d419f74dbef319905f31815956fda229d3398ee 100644 (file)
@@ -148,8 +148,7 @@ shared_ptr<pv::device::DevInst> SamplingBar::get_selected_device() const
                        index).value<void*>();
        assert(sdi);
 
-       map<const sr_dev_inst*, boost::weak_ptr<device::DevInst> >::
-               const_iterator iter = _device_selector_map.find(sdi);
+       const auto iter = _device_selector_map.find(sdi);
        if (iter == _device_selector_map.end())
                return shared_ptr<pv::device::DevInst>();
 
index 618de9a338fe88c566f3e2904a56ae483755d9b6..f82175107adc998f8cfce5288c9e468b1fd54ab1 100644 (file)
@@ -303,8 +303,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
        }
        else
        {
-               list< shared_ptr<Decoder> >::const_iterator iter =
-                       stack.begin();
+               auto iter = stack.cbegin();
                for (int i = 0; i < (int)stack.size(); i++, iter++) {
                        shared_ptr<Decoder> dec(*iter);
                        create_decoder_form(i, dec, parent, form);
@@ -592,9 +591,7 @@ QComboBox* DecodeTrace::create_probe_selector(
        const vector< shared_ptr<Signal> > sigs = _session.get_signals();
 
        assert(_decoder_stack);
-       const map<const srd_channel*,
-               shared_ptr<LogicSignal> >::const_iterator probe_iter =
-               dec->channels().find(pdch);
+       const auto probe_iter = dec->channels().find(pdch);
 
        QComboBox *selector = new QComboBox(parent);
 
@@ -705,7 +702,7 @@ void DecodeTrace::on_show_hide_decoder(int index)
        const list< shared_ptr<Decoder> > stack(_decoder_stack->stack());
 
        // Find the decoder in the stack
-       list< shared_ptr<Decoder> >::const_iterator iter = stack.begin();
+       auto iter = stack.cbegin();
        for(int i = 0; i < index; i++, iter++)
                assert(iter != stack.end());
 
index e7bfcbf01a1df5e5d6febc762a8219c78fc4b3b6..a00efb14664534e689464b398040b39d302011ab 100644 (file)
@@ -223,9 +223,7 @@ void Header::mouseMoveEvent(QMouseEvent *event)
 
                const int delta = event->pos().y() - _mouse_down_point.y();
 
-               for (std::list<std::pair<boost::weak_ptr<Trace>,
-                       int> >::iterator i = _drag_traces.begin();
-                       i != _drag_traces.end(); i++) {
+               for (auto i = _drag_traces.begin(); i != _drag_traces.end(); i++) {
                        const boost::shared_ptr<Trace> trace((*i).first);
                        if (trace) {
                                const int y = (*i).second + delta;
index 0b4426475d6e52a36e7f87f96a58933e144a903c..546743e337bd62caae00f836a31c09b0630f664d 100644 (file)
@@ -155,9 +155,7 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right)
        QLineF *const edge_lines = new QLineF[edge_count];
        line = edge_lines;
 
-       for (vector<pv::data::LogicSnapshot::EdgePair>::const_iterator i =
-                       edges.begin() + 1;
-               i != edges.end() - 1; i++) {
+       for (auto i = edges.cbegin() + 1; i != edges.cend() - 1; i++) {
                const float x = ((*i).first / samples_per_pixel -
                        pixels_offset) + left;
                *line++ = QLineF(x, high_offset, x, low_offset);
@@ -188,8 +186,7 @@ void LogicSignal::paint_caps(QPainter &p, QLineF *const lines,
 {
        QLineF *line = lines;
 
-       for (vector<pv::data::LogicSnapshot::EdgePair>::const_iterator i =
-               edges.begin(); i != (edges.end() - 1); i++)
+       for (auto i = edges.begin(); i != (edges.end() - 1); i++)
                if ((*i).second == level) {
                        *line++ = QLineF(
                                ((*i).first / samples_per_pixel -
index d117489577bc02e99edb171906e965eaeeaa15b3..3d3b8eb233c74a9cc2498de16e3a7b7522019cfe 100644 (file)
@@ -232,7 +232,7 @@ vector< shared_ptr<Trace> > View::get_traces() const
        vector< shared_ptr<Trace> > traces(sigs.size());
 #endif
 
-       vector< shared_ptr<Trace> >::iterator i = traces.begin();
+       auto i = traces.begin();
        i = copy(sigs.begin(), sigs.end(), i);
 #ifdef ENABLE_DECODE
        i = copy(decode_sigs.begin(), decode_sigs.end(), i);