From: Uwe Hermann Date: Wed, 15 Mar 2017 22:16:05 +0000 (+0100) Subject: Don't use std:: in the code directly (where possible). X-Git-Tag: pulseview-0.4.0~143 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6f925ba9d6faf1077b73c5a5808259576081716a;p=pulseview.git Don't use std:: in the code directly (where possible). Use "using std::foo" to make the actual code itself a lot more readable. There are some exceptions where we usually cannot do this, e.g. std::thread often conflicts with "thread" from Qt or Boost. --- diff --git a/android/assetreader.cpp b/android/assetreader.cpp index f14e7b65..d0af1678 100644 --- a/android/assetreader.cpp +++ b/android/assetreader.cpp @@ -26,10 +26,13 @@ using namespace pv; +using std::string; +using std::unique_ptr; + AndroidAssetReader::~AndroidAssetReader() {} -void AndroidAssetReader::open(struct sr_resource *res, std::string name) +void AndroidAssetReader::open(struct sr_resource *res, string name) { if (res->type == SR_RESOURCE_FIRMWARE) { auto path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, @@ -37,7 +40,7 @@ void AndroidAssetReader::open(struct sr_resource *res, std::string name) if (path.isEmpty()) path = QString::fromStdString("assets:/sigrok-firmware/" + name); - std::unique_ptr file {new QFile{path}}; + unique_ptr file {new QFile{path}}; if (!file->open(QIODevice::ReadOnly)) throw sigrok::Error{SR_ERR}; @@ -60,7 +63,7 @@ void AndroidAssetReader::close(struct sr_resource *res) qCritical("AndroidAssetReader: Invalid handle"); throw sigrok::Error{SR_ERR_ARG}; } - const std::unique_ptr file {static_cast(res->handle)}; + const unique_ptr file {static_cast(res->handle)}; res->handle = nullptr; file->close(); diff --git a/android/assetreader.hpp b/android/assetreader.hpp index 74d49991..819945c2 100644 --- a/android/assetreader.hpp +++ b/android/assetreader.hpp @@ -22,6 +22,8 @@ #include +using std::string; + namespace pv { class AndroidAssetReader : public sigrok::ResourceReader @@ -31,7 +33,7 @@ public: virtual ~AndroidAssetReader(); private: - void open(struct sr_resource *res, std::string name) override; + void open(struct sr_resource *res, string name) override; void close(struct sr_resource *res) override; size_t read(const struct sr_resource *res, void *buf, size_t count) override; }; diff --git a/main.cpp b/main.cpp index 0881c184..51e61002 100644 --- a/main.cpp +++ b/main.cpp @@ -49,6 +49,10 @@ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) Q_IMPORT_PLUGIN(QSvgPlugin) #endif +using std::exception; +using std::shared_ptr; +using std::string; + void usage() { fprintf(stdout, @@ -69,8 +73,8 @@ void usage() int main(int argc, char *argv[]) { int ret = 0; - std::shared_ptr context; - std::string open_file, open_file_format; + shared_ptr context; + string open_file, open_file_format; Application a(argc, argv); @@ -182,7 +186,7 @@ int main(int argc, char *argv[]) // Run the application ret = a.exec(); - } catch (std::exception e) { + } catch (exception e) { qDebug() << e.what(); } diff --git a/pv/application.cpp b/pv/application.cpp index 80a22ab9..383b5c23 100644 --- a/pv/application.cpp +++ b/pv/application.cpp @@ -22,6 +22,10 @@ #include +using std::cerr; +using std::endl; +using std::exception; + Application::Application(int &argc, char* argv[]) : QApplication(argc, argv) { @@ -35,8 +39,8 @@ bool Application::notify(QObject *receiver, QEvent *event) { try { return QApplication::notify(receiver, event); - } catch (std::exception& e) { - std::cerr << "Caught exception: " << e.what() << std::endl; + } catch (exception& e) { + cerr << "Caught exception: " << e.what() << endl; exit(1); return false; } diff --git a/pv/binding/binding.cpp b/pv/binding/binding.cpp index 26cbce48..79ce90a3 100644 --- a/pv/binding/binding.cpp +++ b/pv/binding/binding.cpp @@ -26,11 +26,13 @@ #include "binding.hpp" using std::shared_ptr; +using std::string; +using std::vector; namespace pv { namespace binding { -const std::vector< std::shared_ptr >& Binding::properties() +const vector< shared_ptr >& Binding::properties() { return properties_; } @@ -78,7 +80,7 @@ QString Binding::print_gvariant(Glib::VariantBase gvar) s = QString::fromStdString("(null)"); else if (gvar.is_of_type(Glib::VariantType("s"))) s = QString::fromStdString( - Glib::VariantBase::cast_dynamic>( + Glib::VariantBase::cast_dynamic>( gvar).get()); else s = QString::fromStdString(gvar.print()); diff --git a/pv/binding/binding.hpp b/pv/binding/binding.hpp index 35492e30..aed8c34c 100644 --- a/pv/binding/binding.hpp +++ b/pv/binding/binding.hpp @@ -31,6 +31,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS #include +using std::shared_ptr; +using std::vector; + class QFormLayout; class QWidget; @@ -45,7 +48,7 @@ namespace binding { class Binding { public: - const std::vector< std::shared_ptr >& properties(); + const vector< shared_ptr >& properties(); void commit(); @@ -58,7 +61,7 @@ public: static QString print_gvariant(Glib::VariantBase gvar); protected: - std::vector< std::shared_ptr > properties_; + vector< shared_ptr > properties_; }; } // binding diff --git a/pv/binding/decoder.hpp b/pv/binding/decoder.hpp index dce95332..0e93cffe 100644 --- a/pv/binding/decoder.hpp +++ b/pv/binding/decoder.hpp @@ -24,6 +24,8 @@ #include +using std::shared_ptr; + struct srd_decoder_option; namespace pv { @@ -40,11 +42,11 @@ namespace binding { class Decoder : public Binding { public: - Decoder(std::shared_ptr decoder_stack, - std::shared_ptr decoder); + Decoder(shared_ptr decoder_stack, + shared_ptr decoder); private: - static std::shared_ptr bind_enum(const QString &name, + static shared_ptr bind_enum(const QString &name, const srd_decoder_option *option, prop::Property::Getter getter, prop::Property::Setter setter); @@ -53,8 +55,8 @@ private: void setter(const char *id, Glib::VariantBase value); private: - std::shared_ptr decoder_stack_; - std::shared_ptr decoder_; + shared_ptr decoder_stack_; + shared_ptr decoder_; }; } // binding diff --git a/pv/binding/device.cpp b/pv/binding/device.cpp index 8ef05f05..fe08d2b4 100644 --- a/pv/binding/device.cpp +++ b/pv/binding/device.cpp @@ -31,9 +31,11 @@ #include using boost::optional; + using std::function; using std::make_pair; using std::pair; +using std::set; using std::shared_ptr; using std::string; using std::vector; @@ -143,7 +145,7 @@ void Device::bind_bool(const QString &name, } void Device::bind_enum(const QString &name, - const ConfigKey *key, std::set capabilities, + const ConfigKey *key, set capabilities, Property::Getter getter, Property::Setter setter, function printer) { @@ -164,7 +166,7 @@ void Device::bind_enum(const QString &name, } void Device::bind_int(const QString &name, QString suffix, - optional< std::pair > range, + optional< pair > range, Property::Getter getter, Property::Setter setter) { assert(configurable_); diff --git a/pv/binding/device.hpp b/pv/binding/device.hpp index 81c50598..cd835f29 100644 --- a/pv/binding/device.hpp +++ b/pv/binding/device.hpp @@ -31,6 +31,11 @@ #include +using std::function; +using std::pair; +using std::set; +using std::shared_ptr; + namespace pv { namespace binding { @@ -40,7 +45,7 @@ class Device : public QObject, public Binding Q_OBJECT public: - Device(std::shared_ptr configurable); + Device(shared_ptr configurable); Q_SIGNALS: void config_changed(); @@ -50,11 +55,11 @@ private: prop::Property::Getter getter, prop::Property::Setter setter); void bind_enum(const QString &name, const sigrok::ConfigKey *key, - std::set capabilities, + set capabilities, prop::Property::Getter getter, prop::Property::Setter setter, - std::function printer = print_gvariant); + function printer = print_gvariant); void bind_int(const QString &name, QString suffix, - boost::optional< std::pair > range, + boost::optional< pair > range, prop::Property::Getter getter, prop::Property::Setter setter); static QString print_timebase(Glib::VariantBase gvar); @@ -63,7 +68,7 @@ private: static QString print_probe_factor(Glib::VariantBase gvar); protected: - std::shared_ptr configurable_; + shared_ptr configurable_; }; } // binding diff --git a/pv/binding/inputoutput.hpp b/pv/binding/inputoutput.hpp index 7cf535b2..3c64781f 100644 --- a/pv/binding/inputoutput.hpp +++ b/pv/binding/inputoutput.hpp @@ -28,6 +28,11 @@ #include +using std::map; +using std::shared_ptr; +using std::string; +using std::vector; + namespace sigrok { class Option; } @@ -45,15 +50,13 @@ public: * Constructs a new @c InputOutput binding. * @param options the map of options to use as a template. */ - InputOutput( - const std::map> - &options); + InputOutput(const map> &options); /** * Gets the map of selected options. * @return the options. */ - const std::map& options() const; + const map& options() const; private: /** @@ -63,15 +66,15 @@ private: * @param getter the getter that will read the values out of the map. * @param setter the setter that will set the values into the map. */ - std::shared_ptr bind_enum(const QString &name, - const std::vector &values, + shared_ptr bind_enum(const QString &name, + const vector &values, prop::Property::Getter getter, prop::Property::Setter setter); private: /** * The current map of options. */ - std::map options_; + map options_; }; } // binding diff --git a/pv/data/analog.cpp b/pv/data/analog.cpp index 1a244989..854dae3e 100644 --- a/pv/data/analog.cpp +++ b/pv/data/analog.cpp @@ -61,7 +61,7 @@ void Analog::clear() uint64_t Analog::max_sample_count() const { uint64_t l = 0; - for (const std::shared_ptr s : segments_) { + for (const shared_ptr s : segments_) { assert(s); l = max(l, s->get_sample_count()); } diff --git a/pv/data/analog.hpp b/pv/data/analog.hpp index 6fd01e03..5b6e5ee8 100644 --- a/pv/data/analog.hpp +++ b/pv/data/analog.hpp @@ -27,6 +27,10 @@ #include +using std::deque; +using std::shared_ptr; +using std::vector; + namespace pv { namespace data { @@ -39,13 +43,11 @@ class Analog : public QObject, public SignalData public: Analog(); - void push_segment( - std::shared_ptr &segment); + void push_segment(shared_ptr &segment); - const std::deque< std::shared_ptr >& - analog_segments() const; + const deque< shared_ptr >& analog_segments() const; - std::vector< std::shared_ptr > segments() const; + vector< shared_ptr > segments() const; void clear(); @@ -61,7 +63,7 @@ Q_SIGNALS: uint64_t end_sample); private: - std::deque< std::shared_ptr > segments_; + deque< shared_ptr > segments_; }; } // namespace data diff --git a/pv/data/analogsegment.cpp b/pv/data/analogsegment.cpp index 7458a074..6719340c 100644 --- a/pv/data/analogsegment.cpp +++ b/pv/data/analogsegment.cpp @@ -31,10 +31,12 @@ using std::lock_guard; using std::recursive_mutex; +using std::make_pair; using std::max; using std::max_element; using std::min; using std::min_element; +using std::pair; namespace pv { namespace data { @@ -101,9 +103,9 @@ const float* AnalogSegment::get_samples( return (float*)get_raw_samples(start_sample, (end_sample - start_sample)); } -const std::pair AnalogSegment::get_min_max() const +const pair AnalogSegment::get_min_max() const { - return std::make_pair(min_value_, max_value_); + return make_pair(min_value_, max_value_); } SegmentAnalogDataIterator* AnalogSegment::begin_sample_iteration(uint64_t start) diff --git a/pv/data/analogsegment.hpp b/pv/data/analogsegment.hpp index 27c9863b..8dd6f5f1 100644 --- a/pv/data/analogsegment.hpp +++ b/pv/data/analogsegment.hpp @@ -27,6 +27,8 @@ #include +using std::pair; + namespace AnalogSegmentTest { struct Basic; } @@ -87,7 +89,7 @@ public: const float* get_samples(int64_t start_sample, int64_t end_sample) const; - const std::pair get_min_max() const; + const pair get_min_max() const; SegmentAnalogDataIterator* begin_sample_iteration(uint64_t start); void continue_sample_iteration(SegmentAnalogDataIterator* it, uint64_t increase); diff --git a/pv/data/decode/annotation.cpp b/pv/data/decode/annotation.cpp index e47f8f03..7c720430 100644 --- a/pv/data/decode/annotation.cpp +++ b/pv/data/decode/annotation.cpp @@ -26,6 +26,8 @@ extern "C" { #include "annotation.hpp" +using std::vector; + namespace pv { namespace data { namespace decode { @@ -63,7 +65,7 @@ int Annotation::format() const return format_; } -const std::vector& Annotation::annotations() const +const vector& Annotation::annotations() const { return annotations_; } diff --git a/pv/data/decode/annotation.hpp b/pv/data/decode/annotation.hpp index 7e62cea1..2be8e88d 100644 --- a/pv/data/decode/annotation.hpp +++ b/pv/data/decode/annotation.hpp @@ -24,6 +24,8 @@ #include +using std::vector; + struct srd_proto_data; namespace pv { @@ -38,13 +40,13 @@ public: uint64_t start_sample() const; uint64_t end_sample() const; int format() const; - const std::vector& annotations() const; + const vector& annotations() const; private: uint64_t start_sample_; uint64_t end_sample_; int format_; - std::vector annotations_; + vector annotations_; }; } // namespace decode diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 5fae9258..d3ee3459 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -68,13 +68,13 @@ Decoder::channels() const return channels_; } -void Decoder::set_channels(std::map > channels) +void Decoder::set_channels(map > channels) { channels_ = channels; } -const std::map& Decoder::options() const +const map& Decoder::options() const { return options_; } diff --git a/pv/data/decode/decoder.hpp b/pv/data/decode/decoder.hpp index 3d3e01d4..1b323f0b 100644 --- a/pv/data/decode/decoder.hpp +++ b/pv/data/decode/decoder.hpp @@ -26,6 +26,11 @@ #include +using std::map; +using std::set; +using std::shared_ptr; +using std::string; + struct srd_decoder; struct srd_decoder_inst; struct srd_channel; @@ -52,12 +57,12 @@ public: bool shown() const; void show(bool show = true); - const std::map >& channels() const; - void set_channels(std::map > channels); + const map >& channels() const; + void set_channels(map > channels); - const std::map& options() const; + const map& options() const; void set_option(const char *id, GVariant *value); @@ -66,16 +71,15 @@ public: srd_decoder_inst* create_decoder_inst( srd_session *session) const; - std::set< std::shared_ptr > get_data(); + set< shared_ptr > get_data(); private: const srd_decoder *const decoder_; bool shown_; - std::map > - channels_; - std::map options_; + map > channels_; + map options_; }; } // namespace decode diff --git a/pv/data/decode/rowdata.hpp b/pv/data/decode/rowdata.hpp index b6271111..21543c5c 100644 --- a/pv/data/decode/rowdata.hpp +++ b/pv/data/decode/rowdata.hpp @@ -24,6 +24,8 @@ #include "annotation.hpp" +using std::vector; + namespace pv { namespace data { namespace decode { @@ -40,13 +42,13 @@ public: * Extracts sorted annotations between two period into a vector. */ void get_annotation_subset( - std::vector &dest, + vector &dest, uint64_t start_sample, uint64_t end_sample) const; void push_annotation(const Annotation &a); private: - std::vector annotations_; + vector annotations_; }; } diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 1f158c23..f393a1bb 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -34,7 +34,6 @@ using std::lock_guard; using std::mutex; -using boost::optional; using std::unique_lock; using std::deque; using std::make_pair; @@ -47,6 +46,8 @@ using std::shared_ptr; using std::make_shared; using std::vector; +using boost::optional; + using namespace pv::data::decode; namespace pv { @@ -87,13 +88,12 @@ DecoderStack::~DecoderStack() } } -const std::list< std::shared_ptr >& -DecoderStack::stack() const +const list< shared_ptr >& DecoderStack::stack() const { return stack_; } -void DecoderStack::push(std::shared_ptr decoder) +void DecoderStack::push(shared_ptr decoder) { assert(decoder); stack_.push_back(decoder); @@ -129,7 +129,7 @@ int64_t DecoderStack::samples_decoded() const return samples_decoded_; } -std::vector DecoderStack::get_visible_rows() const +vector DecoderStack::get_visible_rows() const { lock_guard lock(output_mutex_); @@ -160,7 +160,7 @@ std::vector DecoderStack::get_visible_rows() const } void DecoderStack::get_annotation_subset( - std::vector &dest, + vector &dest, const Row &row, uint64_t start_sample, uint64_t end_sample) const { diff --git a/pv/data/decoderstack.hpp b/pv/data/decoderstack.hpp index 19a060f2..8a9e0e45 100644 --- a/pv/data/decoderstack.hpp +++ b/pv/data/decoderstack.hpp @@ -38,6 +38,15 @@ #include #include +using std::atomic; +using std::condition_variable; +using std::list; +using std::map; +using std::mutex; +using std::pair; +using std::shared_ptr; +using std::vector; + struct srd_decoder; struct srd_decoder_annotation_row; struct srd_channel; @@ -82,8 +91,8 @@ public: virtual ~DecoderStack(); - const std::list< std::shared_ptr >& stack() const; - void push(std::shared_ptr decoder); + const list< shared_ptr >& stack() const; + void push(shared_ptr decoder); void remove(int index); double samplerate() const; @@ -92,13 +101,13 @@ public: int64_t samples_decoded() const; - std::vector get_visible_rows() const; + vector get_visible_rows() const; /** * Extracts sorted annotations between two period into a vector. */ void get_annotation_subset( - std::vector &dest, + vector &dest, const decode::Row &row, uint64_t start_sample, uint64_t end_sample) const; @@ -143,28 +152,28 @@ private: * @todo A proper solution should be implemented to allow multiple * decode operations in parallel. */ - static std::mutex global_srd_mutex_; + static mutex global_srd_mutex_; - std::list< std::shared_ptr > stack_; + list< shared_ptr > stack_; - std::shared_ptr segment_; + shared_ptr segment_; - mutable std::mutex input_mutex_; - mutable std::condition_variable input_cond_; + mutable mutex input_mutex_; + mutable condition_variable input_cond_; int64_t sample_count_; bool frame_complete_; - mutable std::mutex output_mutex_; + mutable mutex output_mutex_; int64_t samples_decoded_; - std::map rows_; + map rows_; - std::map, decode::Row> class_rows_; + map, decode::Row> class_rows_; QString error_message_; std::thread decode_thread_; - std::atomic interrupt_; + atomic interrupt_; friend struct DecoderStackTest::TwoDecoderStack; }; diff --git a/pv/data/logic.cpp b/pv/data/logic.cpp index cd80ac99..399c8134 100644 --- a/pv/data/logic.cpp +++ b/pv/data/logic.cpp @@ -69,7 +69,7 @@ void Logic::clear() uint64_t Logic::max_sample_count() const { uint64_t l = 0; - for (std::shared_ptr s : segments_) { + for (shared_ptr s : segments_) { assert(s); l = max(l, s->get_sample_count()); } diff --git a/pv/data/logic.hpp b/pv/data/logic.hpp index e7f7a055..c80f0151 100644 --- a/pv/data/logic.hpp +++ b/pv/data/logic.hpp @@ -26,6 +26,10 @@ #include +using std::deque; +using std::shared_ptr; +using std::vector; + namespace pv { namespace data { @@ -40,13 +44,11 @@ public: unsigned int num_channels() const; - void push_segment( - std::shared_ptr &segment); + void push_segment(shared_ptr &segment); - const std::deque< std::shared_ptr >& - logic_segments() const; + const deque< shared_ptr >& logic_segments() const; - std::vector< std::shared_ptr > segments() const; + vector< shared_ptr > segments() const; void clear(); @@ -63,7 +65,7 @@ Q_SIGNALS: private: const unsigned int num_channels_; - std::deque< std::shared_ptr > segments_; + deque< shared_ptr > segments_; }; } // namespace data diff --git a/pv/data/logicsegment.cpp b/pv/data/logicsegment.cpp index 5191a3f0..6350682f 100644 --- a/pv/data/logicsegment.cpp +++ b/pv/data/logicsegment.cpp @@ -35,6 +35,7 @@ using std::max; using std::min; using std::pair; using std::shared_ptr; +using std::vector; using sigrok::Logic; @@ -298,7 +299,7 @@ uint64_t LogicSegment::get_unpacked_sample(uint64_t index) const } void LogicSegment::get_subsampled_edges( - std::vector &edges, + vector &edges, uint64_t start, uint64_t end, float min_length, int sig_index) { diff --git a/pv/data/logicsegment.hpp b/pv/data/logicsegment.hpp index c450f0a9..b8e41835 100644 --- a/pv/data/logicsegment.hpp +++ b/pv/data/logicsegment.hpp @@ -27,6 +27,10 @@ #include +using std::pair; +using std::shared_ptr; +using std::vector; + namespace sigrok { class Logic; } @@ -70,14 +74,14 @@ private: static const uint64_t MipMapDataUnit; public: - typedef std::pair EdgePair; + typedef pair EdgePair; public: - LogicSegment(pv::data::Logic& owner, std::shared_ptr data, uint64_t samplerate); + LogicSegment(pv::data::Logic& owner, shared_ptr data, uint64_t samplerate); virtual ~LogicSegment(); - void append_payload(std::shared_ptr logic); + void append_payload(shared_ptr logic); const uint8_t* get_samples(int64_t start_sample, int64_t end_sample) const; @@ -106,7 +110,7 @@ public: * can be resolved at this level of detail. * @param[in] sig_index The index of the signal. */ - void get_subsampled_edges(std::vector &edges, + void get_subsampled_edges(vector &edges, uint64_t start, uint64_t end, float min_length, int sig_index); diff --git a/pv/data/segment.cpp b/pv/data/segment.cpp index a2a213af..86211f82 100644 --- a/pv/data/segment.cpp +++ b/pv/data/segment.cpp @@ -26,6 +26,7 @@ #include using std::lock_guard; +using std::min; using std::recursive_mutex; using std::vector; @@ -47,8 +48,7 @@ Segment::Segment(uint64_t samplerate, unsigned int unit_size) : // Determine the number of samples we can fit in one chunk // without exceeding MaxChunkSize - chunk_size_ = std::min(MaxChunkSize, - (MaxChunkSize / unit_size_) * unit_size_); + chunk_size_ = min(MaxChunkSize, (MaxChunkSize / unit_size_) * unit_size_); // Create the initial chunk current_chunk_ = new uint8_t[chunk_size_]; @@ -188,7 +188,7 @@ uint8_t* Segment::get_raw_samples(uint64_t start, uint64_t count) const while (count > 0) { const uint8_t* chunk = data_chunks_[chunk_num]; - uint64_t copy_size = std::min(count * unit_size_, + uint64_t copy_size = min(count * unit_size_, chunk_size_ - chunk_offs); memcpy(dest_ptr, chunk + chunk_offs, copy_size); diff --git a/pv/data/segment.hpp b/pv/data/segment.hpp index f1ff0f52..b46af492 100644 --- a/pv/data/segment.hpp +++ b/pv/data/segment.hpp @@ -27,6 +27,9 @@ #include #include +using std::recursive_mutex; +using std::vector; + namespace SegmentTest { struct SmallSize8Single; struct MediumSize8Single; @@ -78,8 +81,8 @@ protected: void continue_raw_sample_iteration(SegmentRawDataIterator* it, uint64_t increase); void end_raw_sample_iteration(SegmentRawDataIterator* it); - mutable std::recursive_mutex mutex_; - std::vector data_chunks_; + mutable recursive_mutex mutex_; + vector data_chunks_; uint8_t* current_chunk_; uint64_t used_samples_, unused_samples_; uint64_t sample_count_; diff --git a/pv/data/signalbase.cpp b/pv/data/signalbase.cpp index 561439a2..06b3e1d8 100644 --- a/pv/data/signalbase.cpp +++ b/pv/data/signalbase.cpp @@ -139,12 +139,12 @@ bool SignalBase::is_decode_signal() const return (decoder_stack_ != nullptr); } -std::shared_ptr SignalBase::decoder_stack() const +shared_ptr SignalBase::decoder_stack() const { return decoder_stack_; } -void SignalBase::set_decoder_stack(std::shared_ptr +void SignalBase::set_decoder_stack(shared_ptr decoder_stack) { decoder_stack_ = decoder_stack; diff --git a/pv/data/signalbase.hpp b/pv/data/signalbase.hpp index 6667dd76..8b60c366 100644 --- a/pv/data/signalbase.hpp +++ b/pv/data/signalbase.hpp @@ -28,6 +28,7 @@ #include +using std::shared_ptr; namespace sigrok { class Channel; @@ -50,14 +51,14 @@ private: static const int ColourBGAlpha; public: - SignalBase(std::shared_ptr channel); + SignalBase(shared_ptr channel); virtual ~SignalBase() {} public: /** * Returns the underlying SR channel. */ - std::shared_ptr channel() const; + shared_ptr channel() const; /** * Returns enabled status of this channel. @@ -113,25 +114,24 @@ public: /** * Sets the internal data object. */ - void set_data(std::shared_ptr data); + void set_data(shared_ptr data); /** * Get the internal data as analog data object in case of analog type. */ - std::shared_ptr analog_data() const; + shared_ptr analog_data() const; /** * Get the internal data as logic data object in case of logic type. */ - std::shared_ptr logic_data() const; + shared_ptr logic_data() const; #ifdef ENABLE_DECODE bool is_decode_signal() const; - std::shared_ptr decoder_stack() const; + shared_ptr decoder_stack() const; - void set_decoder_stack(std::shared_ptr - decoder_stack); + void set_decoder_stack(shared_ptr decoder_stack); #endif void save_settings(QSettings &settings) const; @@ -146,11 +146,11 @@ Q_SIGNALS: void colour_changed(const QColor &colour); private: - std::shared_ptr channel_; - std::shared_ptr data_; + shared_ptr channel_; + shared_ptr data_; #ifdef ENABLE_DECODE - std::shared_ptr decoder_stack_; + shared_ptr decoder_stack_; #endif QString internal_name_, name_; diff --git a/pv/data/signaldata.hpp b/pv/data/signaldata.hpp index f8ae9728..034703e1 100644 --- a/pv/data/signaldata.hpp +++ b/pv/data/signaldata.hpp @@ -24,6 +24,9 @@ #include #include +using std::shared_ptr; +using std::vector; + namespace pv { namespace data { @@ -36,7 +39,7 @@ public: virtual ~SignalData() {} public: - virtual std::vector< std::shared_ptr > segments() const = 0; + virtual vector< shared_ptr > segments() const = 0; virtual void clear() = 0; diff --git a/pv/devicemanager.cpp b/pv/devicemanager.cpp index 9e3944b5..bd41eb8d 100644 --- a/pv/devicemanager.cpp +++ b/pv/devicemanager.cpp @@ -64,7 +64,7 @@ DeviceManager::DeviceManager(shared_ptr context) : driver_scan(entry.second, map()); } -const std::shared_ptr& DeviceManager::context() const +const shared_ptr& DeviceManager::context() const { return context_; } diff --git a/pv/devicemanager.hpp b/pv/devicemanager.hpp index 145f9e80..43d93a7a 100644 --- a/pv/devicemanager.hpp +++ b/pv/devicemanager.hpp @@ -25,6 +25,11 @@ #include #include +using std::list; +using std::map; +using std::shared_ptr; +using std::string; + namespace Glib { class VariantBase; } @@ -47,34 +52,33 @@ class Session; class DeviceManager { public: - DeviceManager(std::shared_ptr context); + DeviceManager(shared_ptr context); ~DeviceManager() = default; - const std::shared_ptr& context() const; + const shared_ptr& context() const; - std::shared_ptr context(); + shared_ptr context(); - const std::list< std::shared_ptr >& - devices() const; + const list< shared_ptr >& devices() const; - std::list< std::shared_ptr > driver_scan( - std::shared_ptr driver, - std::map drvopts); + list< shared_ptr > driver_scan( + shared_ptr driver, + map drvopts); - const std::map get_device_info( - const std::shared_ptr device); + const map get_device_info( + const shared_ptr device); - const std::shared_ptr find_device_from_info( - const std::map search_info); + const shared_ptr find_device_from_info( + const map search_info); private: - bool compare_devices(std::shared_ptr a, - std::shared_ptr b); + bool compare_devices(shared_ptr a, + shared_ptr b); protected: - std::shared_ptr context_; - std::list< std::shared_ptr > devices_; + shared_ptr context_; + list< shared_ptr > devices_; }; } // namespace pv diff --git a/pv/devices/device.cpp b/pv/devices/device.cpp index c6784d40..de489bc2 100644 --- a/pv/devices/device.cpp +++ b/pv/devices/device.cpp @@ -25,6 +25,7 @@ using std::map; using std::set; +using std::shared_ptr; using sigrok::ConfigKey; using sigrok::Capability; @@ -42,12 +43,12 @@ Device::~Device() session_->remove_datafeed_callbacks(); } -std::shared_ptr Device::session() const +shared_ptr Device::session() const { return session_; } -std::shared_ptr Device::device() const +shared_ptr Device::device() const { return device_; } diff --git a/pv/devices/device.hpp b/pv/devices/device.hpp index b4518fbe..fd78960c 100644 --- a/pv/devices/device.hpp +++ b/pv/devices/device.hpp @@ -23,6 +23,9 @@ #include #include +using std::shared_ptr; +using std::string; + namespace sigrok { class ConfigKey; class Device; @@ -43,9 +46,9 @@ protected: public: virtual ~Device(); - std::shared_ptr session() const; + shared_ptr session() const; - std::shared_ptr device() const; + shared_ptr device() const; template T read_config(const sigrok::ConfigKey *key, const T default_value = 0); @@ -53,14 +56,14 @@ public: /** * Builds the full name. It only contains all the fields. */ - virtual std::string full_name() const = 0; + virtual string full_name() const = 0; /** * Builds the display name. It only contains fields as required. * @param device_manager a reference to the device manager is needed * so that other similarly titled devices can be detected. */ - virtual std::string display_name( + virtual string display_name( const DeviceManager &device_manager) const = 0; virtual void open() = 0; @@ -74,8 +77,8 @@ public: virtual void stop(); protected: - std::shared_ptr session_; - std::shared_ptr device_; + shared_ptr session_; + shared_ptr device_; }; } // namespace devices diff --git a/pv/devices/file.cpp b/pv/devices/file.cpp index 04c8be37..dc64246a 100644 --- a/pv/devices/file.cpp +++ b/pv/devices/file.cpp @@ -21,20 +21,22 @@ #include "file.hpp" +using std::string; + namespace pv { namespace devices { -File::File(const std::string &file_name) : +File::File(const string &file_name) : file_name_(file_name) { } -std::string File::full_name() const +string File::full_name() const { return file_name_; } -std::string File::display_name(const DeviceManager&) const +string File::display_name(const DeviceManager&) const { return boost::filesystem::path(file_name_).filename().string(); } diff --git a/pv/devices/file.hpp b/pv/devices/file.hpp index acaac847..d8e9ae9a 100644 --- a/pv/devices/file.hpp +++ b/pv/devices/file.hpp @@ -24,27 +24,29 @@ #include "device.hpp" +using std::string; + namespace pv { namespace devices { class File : public Device { protected: - File(const std::string &file_name); + File(const string &file_name); public: /** * Builds the full name. It only contains all the fields. */ - std::string full_name() const; + string full_name() const; /** * Builds the display name. It only contains fields as required. */ - std::string display_name(const DeviceManager&) const; + string display_name(const DeviceManager&) const; protected: - const std::string file_name_; + const string file_name_; }; } // namespace devices diff --git a/pv/devices/hardwaredevice.cpp b/pv/devices/hardwaredevice.cpp index 591c756b..0ed5c4ae 100644 --- a/pv/devices/hardwaredevice.cpp +++ b/pv/devices/hardwaredevice.cpp @@ -40,8 +40,8 @@ using sigrok::HardwareDevice; namespace pv { namespace devices { -HardwareDevice::HardwareDevice(const std::shared_ptr &context, - std::shared_ptr device) : +HardwareDevice::HardwareDevice(const shared_ptr &context, + shared_ptr device) : context_(context), device_open_(false) { diff --git a/pv/devices/hardwaredevice.hpp b/pv/devices/hardwaredevice.hpp index ed479c4f..32f5b644 100644 --- a/pv/devices/hardwaredevice.hpp +++ b/pv/devices/hardwaredevice.hpp @@ -22,6 +22,9 @@ #include "device.hpp" +using std::shared_ptr; +using std::string; + namespace sigrok { class Context; class HardwareDevice; @@ -33,31 +36,31 @@ namespace devices { class HardwareDevice final : public Device { public: - HardwareDevice(const std::shared_ptr &context, - std::shared_ptr device); + HardwareDevice(const shared_ptr &context, + shared_ptr device); ~HardwareDevice(); - std::shared_ptr hardware_device() const; + shared_ptr hardware_device() const; /** * Builds the full name. It only contains all the fields. */ - std::string full_name() const; + string full_name() const; /** * Builds the display name. It only contains fields as required. * @param device_manager a reference to the device manager is needed * so that other similarly titled devices can be detected. */ - std::string display_name(const DeviceManager &device_manager) const; + string display_name(const DeviceManager &device_manager) const; void open(); void close(); private: - const std::shared_ptr context_; + const shared_ptr context_; bool device_open_; }; diff --git a/pv/devices/inputfile.cpp b/pv/devices/inputfile.cpp index 7c981f1a..58c60d70 100644 --- a/pv/devices/inputfile.cpp +++ b/pv/devices/inputfile.cpp @@ -24,15 +24,22 @@ #include "inputfile.hpp" +using std::map; +using std::shared_ptr; +using std::streamsize; +using std::string; +using std::ifstream; +using std::ios; + namespace pv { namespace devices { -const std::streamsize InputFile::BufferSize = 16384; +const streamsize InputFile::BufferSize = 16384; -InputFile::InputFile(const std::shared_ptr &context, - const std::string &file_name, - std::shared_ptr format, - const std::map &options) : +InputFile::InputFile(const shared_ptr &context, + const string &file_name, + shared_ptr format, + const map &options) : File(file_name), context_(context), format_(format), @@ -55,11 +62,11 @@ void InputFile::open() // open() should add the input device to the session but // we can't open the device without sending some data first - f = new std::ifstream(file_name_, std::ios::binary); + f = new ifstream(file_name_, ios::binary); char buffer[BufferSize]; f->read(buffer, BufferSize); - const std::streamsize size = f->gcount(); + const streamsize size = f->gcount(); if (size == 0) return; @@ -90,14 +97,14 @@ void InputFile::run() if (!f) { // Previous call to run() processed the entire file already - f = new std::ifstream(file_name_, std::ios::binary); + f = new ifstream(file_name_, ios::binary); input_->reset(); } interrupt_ = false; while (!interrupt_ && !f->eof()) { f->read(buffer, BufferSize); - const std::streamsize size = f->gcount(); + const streamsize size = f->gcount(); if (size == 0) break; diff --git a/pv/devices/inputfile.hpp b/pv/devices/inputfile.hpp index 3efaf795..41698e6d 100644 --- a/pv/devices/inputfile.hpp +++ b/pv/devices/inputfile.hpp @@ -26,19 +26,26 @@ #include "file.hpp" +using std::atomic; +using std::ifstream; +using std::map; +using std::shared_ptr; +using std::streamsize; +using std::string; + namespace pv { namespace devices { class InputFile final : public File { private: - static const std::streamsize BufferSize; + static const streamsize BufferSize; public: - InputFile(const std::shared_ptr &context, - const std::string &file_name, - std::shared_ptr format, - const std::map &options); + InputFile(const shared_ptr &context, + const string &file_name, + shared_ptr format, + const map &options); void open(); @@ -51,13 +58,13 @@ public: void stop(); private: - const std::shared_ptr context_; - const std::shared_ptr format_; - const std::map options_; - std::shared_ptr input_; + const shared_ptr context_; + const shared_ptr format_; + const map options_; + shared_ptr input_; - std::ifstream *f; - std::atomic interrupt_; + ifstream *f; + atomic interrupt_; }; } // namespace devices diff --git a/pv/devices/sessionfile.cpp b/pv/devices/sessionfile.cpp index 1e8c3acd..0ba64a9b 100644 --- a/pv/devices/sessionfile.cpp +++ b/pv/devices/sessionfile.cpp @@ -23,11 +23,14 @@ #include "sessionfile.hpp" +using std::shared_ptr; +using std::string; + namespace pv { namespace devices { -SessionFile::SessionFile(const std::shared_ptr context, - const std::string &file_name) : +SessionFile::SessionFile(const shared_ptr context, + const string &file_name) : File(file_name), context_(context) { diff --git a/pv/devices/sessionfile.hpp b/pv/devices/sessionfile.hpp index 42078ec1..1e34ce05 100644 --- a/pv/devices/sessionfile.hpp +++ b/pv/devices/sessionfile.hpp @@ -24,6 +24,9 @@ #include "file.hpp" +using std::shared_ptr; +using std::string; + namespace sigrok { class Context; } // sigrok @@ -34,15 +37,15 @@ namespace devices { class SessionFile final : public File { public: - SessionFile(const std::shared_ptr context, - const std::string &file_name); + SessionFile(const shared_ptr context, + const string &file_name); void open(); void close(); private: - const std::shared_ptr context_; + const shared_ptr context_; }; } // namespace devices diff --git a/pv/dialogs/connect.hpp b/pv/dialogs/connect.hpp index e14972ab..b35f5899 100644 --- a/pv/dialogs/connect.hpp +++ b/pv/dialogs/connect.hpp @@ -34,6 +34,8 @@ #include #include +using std::shared_ptr; + namespace sigrok { class Driver; } @@ -44,8 +46,8 @@ class HardwareDevice; } } -Q_DECLARE_METATYPE(std::shared_ptr); -Q_DECLARE_METATYPE(std::shared_ptr); +Q_DECLARE_METATYPE(shared_ptr); +Q_DECLARE_METATYPE(shared_ptr); namespace pv { @@ -60,12 +62,12 @@ class Connect : public QDialog public: Connect(QWidget *parent, pv::DeviceManager &device_manager); - std::shared_ptr get_selected_device() const; + shared_ptr get_selected_device() const; private: void populate_drivers(); - void populate_serials(std::shared_ptr driver); + void populate_serials(shared_ptr driver); void unset_connection(); diff --git a/pv/dialogs/inputoutputoptions.hpp b/pv/dialogs/inputoutputoptions.hpp index 037f3d41..5d5ab55a 100644 --- a/pv/dialogs/inputoutputoptions.hpp +++ b/pv/dialogs/inputoutputoptions.hpp @@ -27,6 +27,10 @@ #include +using std::map; +using std::shared_ptr; +using std::string; + namespace pv { namespace dialogs { @@ -45,15 +49,14 @@ public: * @param parent the parent widget of the dialog. */ InputOutputOptions(const QString &title, - const std::map> - &options, + const map> &options, QWidget *parent); /** * Gets the map of selected options. * @return the options. */ - const std::map& options() const; + const map& options() const; protected: void accept(); diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index 068d99b3..cf475733 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -40,6 +40,8 @@ #include #endif +using std::shared_ptr; + namespace pv { namespace dialogs { @@ -159,7 +161,7 @@ QWidget *Settings::get_about_page(QWidget *parent) const QApplication::organizationDomain())); version_info->setOpenExternalLinks(true); - std::shared_ptr context = device_manager_.context(); + shared_ptr context = device_manager_.context(); QString s; s.append(""); diff --git a/pv/dialogs/storeprogress.cpp b/pv/dialogs/storeprogress.cpp index b9c87ee7..4ef34045 100644 --- a/pv/dialogs/storeprogress.cpp +++ b/pv/dialogs/storeprogress.cpp @@ -26,6 +26,8 @@ #include "storeprogress.hpp" using std::map; +using std::pair; +using std::shared_ptr; using std::string; using Glib::VariantBase; @@ -34,9 +36,9 @@ namespace pv { namespace dialogs { StoreProgress::StoreProgress(const QString &file_name, - const std::shared_ptr output_format, + const shared_ptr output_format, const map &options, - const std::pair sample_range, + const pair sample_range, const Session &session, QWidget *parent) : QProgressDialog(tr("Saving..."), tr("Cancel"), 0, 0, parent), session_(file_name.toStdString(), output_format, options, sample_range, @@ -78,7 +80,7 @@ void StoreProgress::closeEvent(QCloseEvent*) void StoreProgress::on_progress_updated() { - const std::pair p = session_.progress(); + const pair p = session_.progress(); assert(p.first <= p.second); if (p.second) { diff --git a/pv/dialogs/storeprogress.hpp b/pv/dialogs/storeprogress.hpp index e968ce41..b54eb47f 100644 --- a/pv/dialogs/storeprogress.hpp +++ b/pv/dialogs/storeprogress.hpp @@ -27,6 +27,11 @@ #include +using std::map; +using std::pair; +using std::shared_ptr; +using std::string; + namespace pv { class Session; @@ -39,9 +44,9 @@ class StoreProgress : public QProgressDialog public: StoreProgress(const QString &file_name, - const std::shared_ptr output_format, - const std::map &options, - const std::pair sample_range, + const shared_ptr output_format, + const map &options, + const pair sample_range, const Session &session, QWidget *parent = 0); diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index e0b7197b..7bd77f69 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -19,6 +19,10 @@ #include "globalsettings.hpp" +using std::function; +using std::map; +using std::multimap; + namespace pv { const QString GlobalSettings::Key_View_AlwaysZoomToFit = "View_AlwaysZoomToFit"; @@ -26,9 +30,9 @@ const QString GlobalSettings::Key_View_ColouredBG = "View_ColouredBG"; const QString GlobalSettings::Key_View_StickyScrolling = "View_StickyScrolling"; const QString GlobalSettings::Key_View_ShowSamplingPoints = "View_ShowSamplingPoints"; -std::multimap< QString, std::function > GlobalSettings::callbacks_; +multimap< QString, function > GlobalSettings::callbacks_; bool GlobalSettings::tracking_ = false; -std::map GlobalSettings::tracked_changes_; +map GlobalSettings::tracked_changes_; GlobalSettings::GlobalSettings() : QSettings() @@ -37,7 +41,7 @@ GlobalSettings::GlobalSettings() : } void GlobalSettings::register_change_handler(const QString key, - std::function cb) + function cb) { callbacks_.emplace(key, cb); } diff --git a/pv/globalsettings.hpp b/pv/globalsettings.hpp index 1b6560f9..45247377 100644 --- a/pv/globalsettings.hpp +++ b/pv/globalsettings.hpp @@ -27,6 +27,10 @@ #include #include +using std::function; +using std::map; +using std::multimap; + namespace pv { class GlobalSettings : public QSettings @@ -43,7 +47,7 @@ public: GlobalSettings(); static void register_change_handler(const QString key, - std::function cb); + function cb); void setValue(const QString& key, const QVariant& value); @@ -66,10 +70,10 @@ public: void undo_tracked_changes(); private: - static std::multimap< QString, std::function > callbacks_; + static multimap< QString, function > callbacks_; static bool tracking_; - static std::map tracked_changes_; + static map tracked_changes_; }; } // namespace pv diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index b6cca7b2..46f8a123 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -50,10 +50,12 @@ #include +using std::bind; using std::dynamic_pointer_cast; using std::list; using std::make_shared; using std::map; +using std::placeholders::_1; using std::shared_ptr; using std::string; @@ -65,9 +67,6 @@ class ViewItem; using toolbars::MainBar; -using std::bind; -using std::placeholders::_1; - const QString MainWindow::WindowTitle = tr("PulseView"); MainWindow::MainWindow(DeviceManager &device_manager, @@ -474,7 +473,7 @@ void MainWindow::restore_ui_settings() } } -std::shared_ptr MainWindow::get_tab_session(int index) const +shared_ptr MainWindow::get_tab_session(int index) const { // Find the session that belongs to the tab's main window for (auto entry : session_windows_) @@ -539,7 +538,7 @@ void MainWindow::on_add_view(const QString &title, views::ViewType type, Session *session) { // We get a pointer and need a reference - for (std::shared_ptr s : sessions_) + for (shared_ptr s : sessions_) if (s.get() == session) add_view(title, type, *s); } @@ -659,7 +658,7 @@ void MainWindow::on_capture_state_changed(QObject *obj) void MainWindow::on_new_view(Session *session) { // We get a pointer and need a reference - for (std::shared_ptr s : sessions_) + for (shared_ptr s : sessions_) if (s.get() == session) add_view(session->name(), views::ViewTypeTrace, *s); } diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index 90e91503..0611e002 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -33,6 +33,11 @@ #include "session.hpp" #include "views/viewbase.hpp" +using std::list; +using std::map; +using std::shared_ptr; +using std::string; + struct srd_decoder; class QVBoxLayout; @@ -65,22 +70,22 @@ private: public: explicit MainWindow(DeviceManager &device_manager, - std::string open_file_name = std::string(), - std::string open_file_format = std::string(), + string open_file_name = string(), + string open_file_format = string(), QWidget *parent = 0); ~MainWindow(); - std::shared_ptr get_active_view() const; + shared_ptr get_active_view() const; - std::shared_ptr add_view(const QString &title, + shared_ptr add_view(const QString &title, views::ViewType type, Session &session); - void remove_view(std::shared_ptr view); + void remove_view(shared_ptr view); - std::shared_ptr add_session(); + shared_ptr add_session(); - void remove_session(std::shared_ptr session); + void remove_session(shared_ptr session); private: void setup_ui(); @@ -89,7 +94,7 @@ private: void restore_ui_settings(); - std::shared_ptr get_tab_session(int index) const; + shared_ptr get_tab_session(int index) const; void closeEvent(QCloseEvent *event); @@ -106,7 +111,7 @@ private Q_SLOTS: Session *session); void on_focus_changed(); - void on_focused_session_changed(std::shared_ptr session); + void on_focused_session_changed(shared_ptr session); void on_new_session_clicked(); void on_run_stop_clicked(); @@ -133,12 +138,12 @@ private Q_SLOTS: private: DeviceManager &device_manager_; - std::list< std::shared_ptr > sessions_; - std::shared_ptr last_focused_session_; + list< shared_ptr > sessions_; + shared_ptr last_focused_session_; - std::map< QDockWidget*, std::shared_ptr > view_docks_; + map< QDockWidget*, shared_ptr > view_docks_; - std::map< std::shared_ptr, QMainWindow*> session_windows_; + map< shared_ptr, QMainWindow*> session_windows_; QWidget *static_tab_widget_; QToolButton *new_session_button_, *run_stop_button_, *settings_button_; diff --git a/pv/popups/channels.hpp b/pv/popups/channels.hpp index 6fe9159d..e525b4ba 100644 --- a/pv/popups/channels.hpp +++ b/pv/popups/channels.hpp @@ -31,6 +31,10 @@ #include +using std::map; +using std::shared_ptr; +using std::vector; + class QCheckBox; class QGridLayout; @@ -66,11 +70,11 @@ public: private: void set_all_channels(bool set); - void populate_group(std::shared_ptr group, - const std::vector< std::shared_ptr > sigs); + void populate_group(shared_ptr group, + const vector< shared_ptr > sigs); QGridLayout* create_channel_group_grid( - const std::vector< std::shared_ptr > sigs); + const vector< shared_ptr > sigs); private: void showEvent(QShowEvent *event); @@ -88,9 +92,8 @@ private: bool updating_channels_; - std::vector< std::shared_ptr > - group_bindings_; - std::map< QCheckBox*, std::shared_ptr > + vector< shared_ptr > group_bindings_; + map< QCheckBox*, shared_ptr > check_box_signal_map_; QHBoxLayout buttons_bar_; diff --git a/pv/popups/deviceoptions.hpp b/pv/popups/deviceoptions.hpp index 0ad0f5ad..21f88e90 100644 --- a/pv/popups/deviceoptions.hpp +++ b/pv/popups/deviceoptions.hpp @@ -26,6 +26,8 @@ #include #include +using std::shared_ptr; + namespace sigrok { class Device; } @@ -38,13 +40,12 @@ class DeviceOptions : public pv::widgets::Popup Q_OBJECT public: - DeviceOptions(std::shared_ptr device, - QWidget *parent); + DeviceOptions(shared_ptr device, QWidget *parent); pv::binding::Device& binding(); private: - std::shared_ptr device_; + shared_ptr device_; QVBoxLayout layout_; diff --git a/pv/prop/double.hpp b/pv/prop/double.hpp index df4a254f..666ece97 100644 --- a/pv/prop/double.hpp +++ b/pv/prop/double.hpp @@ -26,6 +26,8 @@ #include "property.hpp" +using std::pair; + class QDoubleSpinBox; namespace pv { @@ -37,7 +39,7 @@ class Double : public Property public: Double(QString name, int decimals, QString suffix, - boost::optional< std::pair > range, + boost::optional< pair > range, boost::optional step, Getter getter, Setter setter); @@ -54,7 +56,7 @@ private Q_SLOTS: private: const int decimals_; const QString suffix_; - const boost::optional< std::pair > range_; + const boost::optional< pair > range_; const boost::optional step_; QDoubleSpinBox *spin_box_; diff --git a/pv/prop/enum.hpp b/pv/prop/enum.hpp index 7216508c..b3ce26cc 100644 --- a/pv/prop/enum.hpp +++ b/pv/prop/enum.hpp @@ -27,6 +27,9 @@ #include +using std::pair; +using std::vector; + Q_DECLARE_METATYPE(Glib::VariantBase); class QComboBox; @@ -39,7 +42,7 @@ class Enum : public Property Q_OBJECT; public: - Enum(QString name, std::vector > values, + Enum(QString name, vector > values, Getter getter, Setter setter); virtual ~Enum() = default; @@ -52,7 +55,7 @@ private Q_SLOTS: void on_current_item_changed(int); private: - const std::vector< std::pair > values_; + const vector< pair > values_; QComboBox *selector_; }; diff --git a/pv/prop/int.hpp b/pv/prop/int.hpp index 92d7c62c..e94f6cbf 100644 --- a/pv/prop/int.hpp +++ b/pv/prop/int.hpp @@ -26,6 +26,8 @@ #include "property.hpp" +using std::pair; + class QSpinBox; namespace pv { @@ -37,7 +39,7 @@ class Int : public Property public: Int(QString name, QString suffix, - boost::optional< std::pair > range, + boost::optional< pair > range, Getter getter, Setter setter); virtual ~Int() = default; @@ -51,7 +53,7 @@ private Q_SLOTS: private: const QString suffix_; - const boost::optional< std::pair > range_; + const boost::optional< pair > range_; Glib::VariantBase value_; QSpinBox *spin_box_; diff --git a/pv/prop/property.hpp b/pv/prop/property.hpp index 6a4dd9ab..1a7b264d 100644 --- a/pv/prop/property.hpp +++ b/pv/prop/property.hpp @@ -30,6 +30,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS #include #include +using std::function; + class QWidget; namespace pv { @@ -40,8 +42,8 @@ class Property : public QObject Q_OBJECT; public: - typedef std::function Getter; - typedef std::function Setter; + typedef function Getter; + typedef function Setter; protected: Property(QString name, Getter getter, Setter setter); diff --git a/pv/session.cpp b/pv/session.cpp index 0077ccfd..e84f7804 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -66,17 +66,23 @@ using boost::shared_lock; using boost::shared_mutex; using boost::unique_lock; +using std::bad_alloc; using std::dynamic_pointer_cast; +using std::find_if; using std::function; using std::lock_guard; using std::list; +using std::make_pair; +using std::make_shared; using std::map; +using std::max; +using std::move; using std::mutex; using std::pair; using std::recursive_mutex; +using std::runtime_error; using std::set; using std::shared_ptr; -using std::make_shared; using std::string; using std::unordered_set; using std::vector; @@ -154,17 +160,17 @@ void Session::set_name(QString name) name_changed(); } -const std::list< std::shared_ptr > Session::views() const +const list< shared_ptr > Session::views() const { return views_; } -std::shared_ptr Session::main_view() const +shared_ptr Session::main_view() const { return main_view_; } -void Session::set_main_bar(std::shared_ptr main_bar) +void Session::set_main_bar(shared_ptr main_bar) { main_bar_ = main_bar; } @@ -229,7 +235,7 @@ void Session::save_settings(QSettings &settings) const if (base->is_decode_signal()) { shared_ptr decoder_stack = base->decoder_stack(); - std::shared_ptr top_decoder = + shared_ptr top_decoder = decoder_stack->stack().front(); settings.beginGroup("decoder_stack" + QString::number(stacks++)); @@ -290,7 +296,7 @@ void Session::restore_settings(QSettings &settings) const string value = settings.value(k).toString().toStdString(); if (!value.empty()) - dev_info.insert(std::make_pair(key, value)); + dev_info.insert(make_pair(key, value)); } if (dev_info.count("model") > 0) @@ -389,7 +395,7 @@ void Session::set_device(shared_ptr device) name_changed(); // Remove all stored data - for (std::shared_ptr view : views_) { + for (shared_ptr view : views_) { view->clear_signals(); #ifdef ENABLE_DECODE view->clear_decode_signals(); @@ -410,7 +416,7 @@ void Session::set_device(shared_ptr device) signals_changed(); - device_ = std::move(device); + device_ = move(device); try { device_->open(); @@ -439,15 +445,13 @@ void Session::set_default_device() return; // Try and find the demo device and select that by default - const auto iter = std::find_if(devices.begin(), devices.end(), + const auto iter = find_if(devices.begin(), devices.end(), [] (const shared_ptr &d) { - return d->hardware_device()->driver()->name() == - "demo"; }); + return d->hardware_device()->driver()->name() == "demo"; }); set_device((iter == devices.end()) ? devices.front() : *iter); } -void Session::load_init_file(const std::string &file_name, - const std::string &format) +void Session::load_init_file(const string &file_name, const string &format) { shared_ptr input_format; @@ -470,8 +474,8 @@ void Session::load_init_file(const std::string &file_name, } void Session::load_file(QString file_name, - std::shared_ptr format, - const std::map &options) + shared_ptr format, + const map &options) { const QString errorMessage( QString("Failed to load file %1").arg(file_name)); @@ -522,7 +526,7 @@ void Session::start_capture(function error_handler) const shared_ptr sr_dev = device_->device(); if (sr_dev) { const auto channels = sr_dev->channels(); - if (!std::any_of(channels.begin(), channels.end(), + if (!any_of(channels.begin(), channels.end(), [](shared_ptr channel) { return channel->enabled(); })) { error_handler(tr("No channels enabled.")); @@ -559,7 +563,7 @@ void Session::stop_capture() sampling_thread_.join(); } -void Session::register_view(std::shared_ptr view) +void Session::register_view(shared_ptr view) { if (views_.empty()) { main_view_ = view; @@ -570,10 +574,9 @@ void Session::register_view(std::shared_ptr view) update_signals(); } -void Session::deregister_view(std::shared_ptr view) +void Session::deregister_view(shared_ptr view) { - views_.remove_if([&](std::shared_ptr v) { - return v == view; }); + views_.remove_if([&](shared_ptr v) { return v == view; }); if (views_.empty()) { main_view_.reset(); @@ -583,9 +586,9 @@ void Session::deregister_view(std::shared_ptr view) } } -bool Session::has_view(std::shared_ptr view) +bool Session::has_view(shared_ptr view) { - for (std::shared_ptr v : views_) + for (shared_ptr v : views_) if (v == view) return true; @@ -601,7 +604,7 @@ double Session::get_samplerate() const const vector< shared_ptr > segments = d->segments(); for (const shared_ptr &s : segments) - samplerate = std::max(samplerate, s->samplerate()); + samplerate = max(samplerate, s->samplerate()); } // If there is no sample rate given we use samples as unit if (samplerate == 0.0) @@ -610,8 +613,7 @@ double Session::get_samplerate() const return samplerate; } -const std::unordered_set< std::shared_ptr > - Session::signalbases() const +const unordered_set< shared_ptr > Session::signalbases() const { return signalbases_; } @@ -627,7 +629,7 @@ bool Session::add_decoder(srd_decoder *const dec) decoder_stack = make_shared(*this, dec); // Make a list of all the channels - std::vector all_channels; + vector all_channels; for (const GSList *i = dec->channels; i; i = i->next) all_channels.push_back((const srd_channel*)i->data); for (const GSList *i = dec->opt_channels; i; i = i->next) @@ -655,9 +657,9 @@ bool Session::add_decoder(srd_decoder *const dec) signalbase->set_decoder_stack(decoder_stack); signalbases_.insert(signalbase); - for (std::shared_ptr view : views_) + for (shared_ptr view : views_) view->add_decode_signal(signalbase); - } catch (std::runtime_error e) { + } catch (runtime_error e) { return false; } @@ -673,7 +675,7 @@ void Session::remove_decode_signal(shared_ptr signalbase) { signalbases_.erase(signalbase); - for (std::shared_ptr view : views_) + for (shared_ptr view : views_) view->remove_decode_signal(signalbase); signals_changed(); @@ -699,7 +701,7 @@ void Session::update_signals() if (!device_) { signalbases_.clear(); logic_data_.reset(); - for (std::shared_ptr view : views_) { + for (shared_ptr view : views_) { view->clear_signals(); #ifdef ENABLE_DECODE view->clear_decode_signals(); @@ -714,7 +716,7 @@ void Session::update_signals() if (!sr_dev) { signalbases_.clear(); logic_data_.reset(); - for (std::shared_ptr view : views_) { + for (shared_ptr view : views_) { view->clear_signals(); #ifdef ENABLE_DECODE view->clear_decode_signals(); @@ -725,7 +727,7 @@ void Session::update_signals() // Detect what data types we will receive auto channels = sr_dev->channels(); - unsigned int logic_channel_count = std::count_if( + unsigned int logic_channel_count = count_if( channels.begin(), channels.end(), [] (shared_ptr channel) { return channel->type() == ChannelType::LOGIC; }); @@ -745,7 +747,7 @@ void Session::update_signals() } // Make the signals list - for (std::shared_ptr viewbase : views_) { + for (shared_ptr viewbase : views_) { views::TraceView::View *trace_view = qobject_cast(viewbase.get()); @@ -759,7 +761,7 @@ void Session::update_signals() shared_ptr signal; // Find the channel in the old signals - const auto iter = std::find_if( + const auto iter = find_if( prev_sigs.cbegin(), prev_sigs.cend(), [&](const shared_ptr &s) { return s->base()->channel() == channel; @@ -1065,7 +1067,7 @@ void Session::data_feed_in(shared_ptr device, case SR_DF_LOGIC: try { feed_in_logic(dynamic_pointer_cast(packet->payload())); - } catch (std::bad_alloc) { + } catch (bad_alloc) { out_of_memory_ = true; device_->stop(); } @@ -1074,7 +1076,7 @@ void Session::data_feed_in(shared_ptr device, case SR_DF_ANALOG: try { feed_in_analog(dynamic_pointer_cast(packet->payload())); - } catch (std::bad_alloc) { + } catch (bad_alloc) { out_of_memory_ = true; device_->stop(); } diff --git a/pv/session.hpp b/pv/session.hpp index bd403605..4ac7f509 100644 --- a/pv/session.hpp +++ b/pv/session.hpp @@ -43,6 +43,15 @@ #include "util.hpp" #include "views/viewbase.hpp" +using std::function; +using std::list; +using std::map; +using std::mutex; +using std::recursive_mutex; +using std::shared_ptr; +using std::string; +using std::unordered_set; + struct srd_decoder; struct srd_channel; @@ -103,21 +112,21 @@ public: const DeviceManager& device_manager() const; - std::shared_ptr session() const; + shared_ptr session() const; - std::shared_ptr device() const; + shared_ptr device() const; QString name() const; void set_name(QString name); - const std::list< std::shared_ptr > views() const; + const list< shared_ptr > views() const; - std::shared_ptr main_view() const; + shared_ptr main_view() const; - std::shared_ptr main_bar() const; + shared_ptr main_bar() const; - void set_main_bar(std::shared_ptr main_bar); + void set_main_bar(shared_ptr main_bar); /** * Indicates whether the captured data was saved to disk already or not @@ -131,44 +140,43 @@ public: /** * Attempts to set device instance, may fall back to demo if needed */ - void select_device(std::shared_ptr device); + void select_device(shared_ptr device); /** * Sets device instance that will be used in the next capture session. */ - void set_device(std::shared_ptr device); + void set_device(shared_ptr device); void set_default_device(); - void load_init_file(const std::string &file_name, - const std::string &format); + void load_init_file(const string &file_name, const string &format); void load_file(QString file_name, - std::shared_ptr format = nullptr, - const std::map &options = - std::map()); + shared_ptr format = nullptr, + const map &options = + map()); capture_state get_capture_state() const; - void start_capture(std::function error_handler); + void start_capture(function error_handler); void stop_capture(); double get_samplerate() const; - void register_view(std::shared_ptr view); + void register_view(shared_ptr view); - void deregister_view(std::shared_ptr view); + void deregister_view(shared_ptr view); - bool has_view(std::shared_ptr view); + bool has_view(shared_ptr view); - const std::unordered_set< std::shared_ptr > + const unordered_set< shared_ptr > signalbases() const; #ifdef ENABLE_DECODE bool add_decoder(srd_decoder *const dec); - void remove_decode_signal(std::shared_ptr signalbase); + void remove_decode_signal(shared_ptr signalbase); #endif private: @@ -176,50 +184,50 @@ private: void update_signals(); - std::shared_ptr signalbase_from_channel( - std::shared_ptr channel) const; + shared_ptr signalbase_from_channel( + shared_ptr channel) const; private: - void sample_thread_proc(std::function error_handler); + void sample_thread_proc(function error_handler); void free_unused_memory(); void feed_in_header(); - void feed_in_meta(std::shared_ptr meta); + void feed_in_meta(shared_ptr meta); void feed_in_trigger(); void feed_in_frame_begin(); - void feed_in_logic(std::shared_ptr logic); + void feed_in_logic(shared_ptr logic); - void feed_in_analog(std::shared_ptr analog); + void feed_in_analog(shared_ptr analog); - void data_feed_in(std::shared_ptr device, - std::shared_ptr packet); + void data_feed_in(shared_ptr device, + shared_ptr packet); private: DeviceManager &device_manager_; - std::shared_ptr device_; + shared_ptr device_; QString default_name_, name_; - std::list< std::shared_ptr > views_; - std::shared_ptr main_view_; + list< shared_ptr > views_; + shared_ptr main_view_; - std::shared_ptr main_bar_; + shared_ptr main_bar_; - mutable std::mutex sampling_mutex_; //!< Protects access to capture_state_. + mutable mutex sampling_mutex_; //!< Protects access to capture_state_. capture_state capture_state_; - std::unordered_set< std::shared_ptr > signalbases_; - std::unordered_set< std::shared_ptr > all_signal_data_; + unordered_set< shared_ptr > signalbases_; + unordered_set< shared_ptr > all_signal_data_; - mutable std::recursive_mutex data_mutex_; - std::shared_ptr logic_data_; + mutable recursive_mutex data_mutex_; + shared_ptr logic_data_; uint64_t cur_samplerate_; - std::shared_ptr cur_logic_segment_; - std::map< std::shared_ptr, std::shared_ptr > + shared_ptr cur_logic_segment_; + map< shared_ptr, shared_ptr > cur_analog_segments_; std::thread sampling_thread_; diff --git a/pv/storesession.cpp b/pv/storesession.cpp index 52a6be34..c2135ab3 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -55,7 +55,6 @@ using std::pair; using std::set; using std::shared_ptr; using std::string; -using std::thread; using std::unordered_set; using std::vector; @@ -71,10 +70,10 @@ namespace pv { const size_t StoreSession::BlockSize = 10 * 1024 * 1024; -StoreSession::StoreSession(const std::string &file_name, +StoreSession::StoreSession(const string &file_name, const shared_ptr &output_format, const map &options, - const std::pair sample_range, + const pair sample_range, const Session &session) : file_name_(file_name), output_format_(output_format), @@ -240,13 +239,13 @@ void StoreSession::store_proc(vector< shared_ptr > achannel_li unit_count_ = sample_count_ >> progress_scale; const unsigned int samples_per_block = - std::min(asamples_per_block, lsamples_per_block); + min(asamples_per_block, lsamples_per_block); while (!interrupt_ && sample_count_) { progress_updated(); const uint64_t packet_len = - std::min((uint64_t)samples_per_block, sample_count_); + min((uint64_t)samples_per_block, sample_count_); try { const auto context = session_.device_manager().context(); diff --git a/pv/storesession.hpp b/pv/storesession.hpp index e89b3fd2..64913a74 100644 --- a/pv/storesession.hpp +++ b/pv/storesession.hpp @@ -34,6 +34,16 @@ #include +using std::atomic; +using std::string; +using std::shared_ptr; +using std::pair; +using std::map; +using std::vector; +using std::thread; +using std::mutex; +using std::ofstream; + namespace sigrok { class Output; class OutputFormat; @@ -57,15 +67,15 @@ private: static const size_t BlockSize; public: - StoreSession(const std::string &file_name, - const std::shared_ptr &output_format, - const std::map &options, - const std::pair sample_range, + StoreSession(const string &file_name, + const shared_ptr &output_format, + const map &options, + const pair sample_range, const Session &session); ~StoreSession(); - std::pair progress() const; + pair progress() const; const QString& error() const; @@ -76,9 +86,9 @@ public: void cancel(); private: - void store_proc(std::vector< std::shared_ptr > achannel_list, - std::vector< std::shared_ptr > asegment_list, - std::shared_ptr lsegment); + void store_proc(vector< shared_ptr > achannel_list, + vector< shared_ptr > asegment_list, + shared_ptr lsegment); Q_SIGNALS: void progress_updated(); @@ -86,22 +96,22 @@ Q_SIGNALS: void store_successful(); private: - const std::string file_name_; - const std::shared_ptr output_format_; - const std::map options_; - const std::pair sample_range_; + const string file_name_; + const shared_ptr output_format_; + const map options_; + const pair sample_range_; const Session &session_; - std::shared_ptr output_; - std::ofstream output_stream_; + shared_ptr output_; + ofstream output_stream_; std::thread thread_; - std::atomic interrupt_; + atomic interrupt_; - std::atomic units_stored_, unit_count_; + atomic units_stored_, unit_count_; - mutable std::mutex mutex_; + mutable mutex mutex_; QString error_; uint64_t start_sample_, sample_count_; diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index 188786f1..736ef80b 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -60,9 +60,12 @@ using std::cerr; using std::copy; using std::endl; using std::list; +using std::make_pair; using std::map; using std::max; using std::min; +using std::pair; +using std::set; using std::shared_ptr; using std::string; using std::vector; @@ -145,15 +148,15 @@ MainBar::MainBar(Session &session, QWidget *parent, session.device_manager().context()); menu_file_export->setTitle(tr("&Export")); connect(menu_file_export, - SIGNAL(format_selected(std::shared_ptr)), - this, SLOT(export_file(std::shared_ptr))); + SIGNAL(format_selected(shared_ptr)), + this, SLOT(export_file(shared_ptr))); widgets::ImportMenu *menu_file_import = new widgets::ImportMenu(this, session.device_manager().context()); menu_file_import->setTitle(tr("&Import")); connect(menu_file_import, - SIGNAL(format_selected(std::shared_ptr)), - this, SLOT(import_file(std::shared_ptr))); + SIGNAL(format_selected(shared_ptr)), + this, SLOT(import_file(shared_ptr))); action_connect_->setText(tr("&Connect to Device...")); connect(action_connect_, SIGNAL(triggered(bool)), @@ -163,9 +166,9 @@ MainBar::MainBar(Session &session, QWidget *parent, widgets::ImportMenu *import_menu = new widgets::ImportMenu(this, session.device_manager().context(), action_open_); connect(import_menu, - SIGNAL(format_selected(std::shared_ptr)), + SIGNAL(format_selected(shared_ptr)), this, - SLOT(import_file(std::shared_ptr))); + SLOT(import_file(shared_ptr))); open_button_->setMenu(import_menu); open_button_->setDefaultAction(action_open_); @@ -180,9 +183,9 @@ MainBar::MainBar(Session &session, QWidget *parent, session.device_manager().context(), open_actions); connect(export_menu, - SIGNAL(format_selected(std::shared_ptr)), + SIGNAL(format_selected(shared_ptr)), this, - SLOT(export_file(std::shared_ptr))); + SLOT(export_file(shared_ptr))); save_button_->setMenu(export_menu); save_button_->setDefaultAction(action_save_as_); @@ -250,7 +253,6 @@ void MainBar::update_device_list() update_device_config_widgets(); } - void MainBar::set_capture_state(pv::Session::capture_state state) { bool ui_enabled = (state == pv::Session::Stopped) ? true : false; @@ -293,7 +295,7 @@ void MainBar::update_sample_rate_selector() GVariant *gvar_list; const uint64_t *elements = nullptr; gsize num_elements; - map< const ConfigKey*, std::set > keys; + map< const ConfigKey*, set > keys; if (updating_sample_rate_) { sample_rate_.show_none(); @@ -592,7 +594,7 @@ void MainBar::export_file(shared_ptr format, QSettings settings; const QString dir = settings.value(SettingSaveDirectory).toString(); - std::pair sample_range; + pair sample_range; // Selection only? Verify that the cursors are active and fetch their values if (selection_only) { @@ -611,14 +613,14 @@ void MainBar::export_file(shared_ptr format, const pv::util::Timestamp& start_time = trace_view->cursors()->first()->time(); const pv::util::Timestamp& end_time = trace_view->cursors()->second()->time(); - const uint64_t start_sample = (uint64_t)std::max( + const uint64_t start_sample = (uint64_t)max( (double)0, start_time.convert_to() * samplerate); - const uint64_t end_sample = (uint64_t)std::max( + const uint64_t end_sample = (uint64_t)max( (double)0, end_time.convert_to() * samplerate); - sample_range = std::make_pair(start_sample, end_sample); + sample_range = make_pair(start_sample, end_sample); } else { - sample_range = std::make_pair(0, 0); + sample_range = make_pair(0, 0); } // Construct the filter diff --git a/pv/toolbars/mainbar.hpp b/pv/toolbars/mainbar.hpp index 0242dc9d..0e58fbae 100644 --- a/pv/toolbars/mainbar.hpp +++ b/pv/toolbars/mainbar.hpp @@ -39,13 +39,15 @@ #include #include +using std::shared_ptr; + namespace sigrok { class Device; class InputFormat; class OutputFormat; } -Q_DECLARE_METATYPE(std::shared_ptr) +Q_DECLARE_METATYPE(shared_ptr) class QAction; @@ -126,9 +128,9 @@ private Q_SLOTS: void add_decoder(srd_decoder *decoder); - void export_file(std::shared_ptr format, + void export_file(shared_ptr format, bool selection_only = false); - void import_file(std::shared_ptr format); + void import_file(shared_ptr format); void on_device_selected(); void on_device_changed(); diff --git a/pv/util.cpp b/pv/util.cpp index c25c373b..c5f9c832 100644 --- a/pv/util.cpp +++ b/pv/util.cpp @@ -28,6 +28,14 @@ #include #include +using std::fixed; +using std::max; +using std::ostringstream; +using std::setfill; +using std::setprecision; +using std::showpos; +using std::string; + using namespace Qt; namespace pv { @@ -82,18 +90,18 @@ static QTextStream& operator<<(QTextStream& stream, const Timestamp& t) int precision = stream.realNumberPrecision(); - std::ostringstream ss; - ss << std::fixed; + ostringstream ss; + ss << fixed; if (stream.numberFlags() & QTextStream::ForceSign) - ss << std::showpos; + ss << showpos; if (0 == precision) - ss << std::setprecision(1) << round(t); + ss << setprecision(1) << round(t); else - ss << std::setprecision(precision) << t; + ss << setprecision(precision) << t; - std::string str(ss.str()); + string str(ss.str()); if (0 == precision) { // remove the separator and the unwanted decimal place str.resize(str.size() - 2); @@ -157,7 +165,7 @@ QString format_time_si_adjusted( const unsigned int relative_prec = (prefix >= SIPrefix::none) ? precision : - std::max((int)(precision - prefix_order), 0); + max((int)(precision - prefix_order), 0); return format_time_si(t, prefix, relative_prec, unit, sign); } @@ -212,13 +220,9 @@ QString format_time_minutes(const Timestamp& t, signed precision, bool sign) const Timestamp fraction = fabs(t) - whole_seconds; - std::ostringstream ss; - ss - << std::fixed - << std::setprecision(precision) - << std::setfill('0') - << fraction; - std::string fs = ss.str(); + ostringstream ss; + ss << fixed << setprecision(precision) << setfill('0') << fraction; + string fs = ss.str(); // Copy all digits, inserting spaces as unit separators for (int i = 1; i <= precision; i++) { diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index c64d86af..04f0a7fb 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -42,11 +42,15 @@ #include +using std::deque; +using std::div; +using std::div_t; using std::max; using std::make_pair; using std::min; +using std::numeric_limits; +using std::pair; using std::shared_ptr; -using std::deque; namespace pv { namespace views { @@ -125,7 +129,7 @@ void AnalogSignal::restore_settings(QSettings &settings) autoranging_ = settings.value("autoranging").toBool(); } -std::pair AnalogSignal::v_extents() const +pair AnalogSignal::v_extents() const { const int ph = pos_vdivs_ * div_height_; const int nh = neg_vdivs_ * div_height_; @@ -368,9 +372,8 @@ float AnalogSignal::get_resolution(int scale_index) { const float seq[] = {1.0f, 2.0f, 5.0f}; - const int offset = std::numeric_limits::max() / (2 * countof(seq)); - const std::div_t d = std::div( - (int)(scale_index + countof(seq) * offset), + const int offset = numeric_limits::max() / (2 * countof(seq)); + const div_t d = div((int)(scale_index + countof(seq) * offset), countof(seq)); return powf(10.0f, d.quot - offset) * seq[d.rem]; @@ -394,7 +397,7 @@ void AnalogSignal::perform_autoranging(bool force_update) double min = 0, max = 0; for (shared_ptr segment : segments) { - std::pair mm = segment->get_min_max(); + pair mm = segment->get_min_max(); min = std::min(min, mm.first); max = std::max(max, mm.second); } diff --git a/pv/view/analogsignal.hpp b/pv/view/analogsignal.hpp index fa105831..a27f6696 100644 --- a/pv/view/analogsignal.hpp +++ b/pv/view/analogsignal.hpp @@ -26,6 +26,9 @@ #include +using std::pair; +using std::shared_ptr; + namespace pv { namespace data { @@ -53,12 +56,11 @@ private: static const int InfoTextMarginRight, InfoTextMarginBottom; public: - AnalogSignal(pv::Session &session, - std::shared_ptr base); + AnalogSignal(pv::Session &session, shared_ptr base); virtual ~AnalogSignal() = default; - std::shared_ptr data() const; + shared_ptr data() const; virtual void save_settings(QSettings &settings) const; @@ -68,7 +70,7 @@ public: * Computes the vertical extents of the contents of this row item. * @return A pair containing the minimum and maximum y-values. */ - std::pair v_extents() const; + pair v_extents() const; /** * Returns the offset to show the drag handle. @@ -111,12 +113,12 @@ private: void paint_grid(QPainter &p, int y, int left, int right); void paint_trace(QPainter &p, - const std::shared_ptr &segment, + const shared_ptr &segment, int y, int left, const int64_t start, const int64_t end, const double pixels_offset, const double samples_per_pixel); void paint_envelope(QPainter &p, - const std::shared_ptr &segment, + const shared_ptr &segment, int y, int left, const int64_t start, const int64_t end, const double pixels_offset, const double samples_per_pixel); diff --git a/pv/view/cursor.hpp b/pv/view/cursor.hpp index 79a0c7f8..e78920e2 100644 --- a/pv/view/cursor.hpp +++ b/pv/view/cursor.hpp @@ -26,6 +26,8 @@ #include +using std::shared_ptr; + class QPainter; namespace pv { @@ -66,7 +68,7 @@ public: QRectF label_rect(const QRectF &rect) const; private: - std::shared_ptr get_other_cursor() const; + shared_ptr get_other_cursor() const; }; } // namespace TraceView diff --git a/pv/view/cursorpair.hpp b/pv/view/cursorpair.hpp index e63113c0..458f5cac 100644 --- a/pv/view/cursorpair.hpp +++ b/pv/view/cursorpair.hpp @@ -26,6 +26,9 @@ #include +using std::pair; +using std::shared_ptr; + class QPainter; namespace pv { @@ -54,12 +57,12 @@ public: /** * Returns a pointer to the first cursor. */ - std::shared_ptr first() const; + shared_ptr first() const; /** * Returns a pointer to the second cursor. */ - std::shared_ptr second() const; + shared_ptr second() const; /** * Sets the time of the marker. @@ -97,10 +100,10 @@ public: void compute_text_size(QPainter &p); - std::pair get_cursor_offsets() const; + pair get_cursor_offsets() const; private: - std::shared_ptr first_, second_; + shared_ptr first_, second_; QSizeF text_size_; }; diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 164c7e5a..c650ee14 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -56,6 +56,8 @@ extern "C" { using boost::shared_lock; using boost::shared_mutex; + +using std::all_of; using std::dynamic_pointer_cast; using std::list; using std::lock_guard; @@ -64,6 +66,7 @@ using std::max; using std::make_pair; using std::map; using std::min; +using std::out_of_range; using std::pair; using std::shared_ptr; using std::make_shared; @@ -137,8 +140,7 @@ DecodeTrace::DecodeTrace(pv::Session &session, delete_mapper_(this), show_hide_mapper_(this) { - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); // Determine shortest string we want to see displayed in full QFontMetrics m(QApplication::font()); @@ -160,7 +162,7 @@ bool DecodeTrace::enabled() const return true; } -std::shared_ptr DecodeTrace::base() const +shared_ptr DecodeTrace::base() const { return base_; } @@ -185,8 +187,7 @@ void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp) { using namespace pv::data::decode; - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); const int text_height = ViewItemPaintParams::text_height(); row_height_ = (text_height * 6) / 4; @@ -217,7 +218,7 @@ void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp) int row_title_width; try { row_title_width = row_title_widths_.at(row); - } catch (std::out_of_range) { + } catch (out_of_range) { const int w = p.boundingRect(QRectF(), 0, row.title()).width() + RowTitleMargin; row_title_widths_[row] = w; @@ -251,7 +252,7 @@ void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp) owner_->extents_changed(false, true); // Update the maximum row count if needed - max_visible_rows_ = std::max(max_visible_rows_, (int)visible_rows_.size()); + max_visible_rows_ = max(max_visible_rows_, (int)visible_rows_.size()); } void DecodeTrace::paint_fore(QPainter &p, const ViewItemPaintParams &pp) @@ -298,8 +299,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form) { using pv::data::decode::Decoder; - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); assert(form); assert(parent); @@ -488,7 +488,7 @@ void DecodeTrace::draw_annotation_block( // Check if all annotations are of the same type (i.e. we can use one color) // or if we should use a neutral color (i.e. gray) const int format = annotations.front().format(); - const bool single_format = std::all_of( + const bool single_format = all_of( annotations.begin(), annotations.end(), [&](const Annotation &a) { return a.format() == format; }); @@ -547,8 +547,8 @@ void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p, const int ann_start = start + cap_width; const int ann_end = end - cap_width; - const int real_start = std::max(ann_start, pp.left() + row_title_width); - const int real_end = std::min(ann_end, pp.right()); + const int real_start = max(ann_start, pp.left() + row_title_width); + const int real_end = min(ann_end, pp.right()); const int real_width = real_end - real_start; QRectF rect(real_start, y - h / 2, real_width, h); @@ -604,8 +604,7 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, double samples_per_pixel, pixels_offset; - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); assert(decoder_stack); @@ -659,8 +658,7 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, pair DecodeTrace::get_pixels_offset_samples_per_pixel() const { - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); assert(owner_); assert(decoder_stack); @@ -732,8 +730,7 @@ const QString DecodeTrace::get_annotation_at_point(const QPoint &point) vector annotations; - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); assert(decoder_stack); decoder_stack->get_annotation_subset(annotations, visible_rows_[row], @@ -841,8 +838,7 @@ void DecodeTrace::create_decoder_form(int index, channel_selectors_.push_back(s); } - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); // Add the options shared_ptr binding( @@ -864,7 +860,7 @@ QComboBox* DecodeTrace::create_channel_selector( const auto sigs(session_.signalbases()); vector< shared_ptr > sig_list(sigs.begin(), sigs.end()); - std::sort(sig_list.begin(), sig_list.end(), + sort(sig_list.begin(), sig_list.end(), [](const shared_ptr &a, const shared_ptr &b) { return strnatcasecmp(a->name().toStdString(), @@ -924,8 +920,7 @@ void DecodeTrace::commit_decoder_channels(shared_ptr &dec void DecodeTrace::commit_channels() { - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); assert(decoder_stack); for (shared_ptr dec : decoder_stack->stack()) @@ -957,8 +952,7 @@ void DecodeTrace::on_channel_selected(int) void DecodeTrace::on_stack_decoder(srd_decoder *decoder) { - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); assert(decoder); assert(decoder_stack); @@ -970,8 +964,7 @@ void DecodeTrace::on_stack_decoder(srd_decoder *decoder) void DecodeTrace::on_delete_decoder(int index) { - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); decoder_stack->remove(index); @@ -985,8 +978,7 @@ void DecodeTrace::on_show_hide_decoder(int index) { using pv::data::decode::Decoder; - std::shared_ptr decoder_stack = - base_->decoder_stack(); + shared_ptr decoder_stack = base_->decoder_stack(); const list< shared_ptr > stack(decoder_stack->stack()); diff --git a/pv/view/decodetrace.hpp b/pv/view/decodetrace.hpp index 6d703ec5..3103a3c0 100644 --- a/pv/view/decodetrace.hpp +++ b/pv/view/decodetrace.hpp @@ -33,6 +33,12 @@ #include #include +using std::list; +using std::map; +using std::pair; +using std::shared_ptr; +using std::vector; + struct srd_channel; struct srd_decoder; @@ -68,7 +74,7 @@ private: struct ChannelSelector { const QComboBox *combo_; - const std::shared_ptr decoder_; + const shared_ptr decoder_; const srd_channel *pdch_; }; @@ -86,20 +92,20 @@ private: static const QColor OutlineColours[16]; public: - DecodeTrace(pv::Session &session, std::shared_ptr signalbase, + DecodeTrace(pv::Session &session, shared_ptr signalbase, int index); bool enabled() const; - const std::shared_ptr& decoder() const; + const shared_ptr& decoder() const; - std::shared_ptr base() const; + shared_ptr base() const; /** * Computes the vertical extents of the contents of this row item. * @return A pair containing the minimum and maximum y-values. */ - std::pair v_extents() const; + pair v_extents() const; /** * Paints the background layer of the trace with a QPainter @@ -129,7 +135,7 @@ public: void delete_pressed(); private: - void draw_annotations(std::vector annotations, + void draw_annotations(vector annotations, QPainter &p, int h, const ViewItemPaintParams &pp, int y, size_t base_colour, int row_title_width); @@ -137,7 +143,7 @@ private: int h, const ViewItemPaintParams &pp, int y, size_t base_colour, int row_title_width) const; - void draw_annotation_block(std::vector annotations, + void draw_annotation_block(vector annotations, QPainter &p, int h, int y, size_t base_colour) const; void draw_instant(const pv::data::decode::Annotation &a, QPainter &p, @@ -153,7 +159,7 @@ private: void draw_unresolved_period(QPainter &p, int h, int left, int right) const; - std::pair get_pixels_offset_samples_per_pixel() const; + pair get_pixels_offset_samples_per_pixel() const; /** * Determines the start and end sample for a given pixel range. @@ -162,22 +168,22 @@ private: * @return Returns a pair containing the start sample and the end * sample that correspond to the start and end coordinates. */ - std::pair get_sample_range(int x_start, int x_end) const; + pair get_sample_range(int x_start, int x_end) const; int get_row_at_point(const QPoint &point); const QString get_annotation_at_point(const QPoint &point); void create_decoder_form(int index, - std::shared_ptr &dec, + shared_ptr &dec, QWidget *parent, QFormLayout *form); QComboBox* create_channel_selector(QWidget *parent, - const std::shared_ptr &dec, + const shared_ptr &dec, const srd_channel *const pdch); void commit_decoder_channels( - std::shared_ptr &dec); + shared_ptr &dec); void commit_channels(); @@ -200,16 +206,15 @@ private Q_SLOTS: private: pv::Session &session_; - std::vector visible_rows_; + vector visible_rows_; uint64_t decode_start_, decode_end_; - std::list< std::shared_ptr > - bindings_; + list< shared_ptr > bindings_; - std::list channel_selectors_; - std::vector decoder_forms_; + list channel_selectors_; + vector decoder_forms_; - std::map row_title_widths_; + map row_title_widths_; int row_height_, max_visible_rows_; int min_useful_label_width_; diff --git a/pv/view/flag.cpp b/pv/view/flag.cpp index 95cee716..662a6d02 100644 --- a/pv/view/flag.cpp +++ b/pv/view/flag.cpp @@ -29,6 +29,7 @@ #include +using std::enable_shared_from_this; using std::shared_ptr; namespace pv { @@ -45,7 +46,7 @@ Flag::Flag(View &view, const pv::util::Timestamp& time, const QString &text) : Flag::Flag(const Flag &flag) : TimeMarker(flag.view_, FillColour, flag.time_), - std::enable_shared_from_this(flag) + enable_shared_from_this(flag) { } diff --git a/pv/view/flag.hpp b/pv/view/flag.hpp index 092a4b5a..5dec187c 100644 --- a/pv/view/flag.hpp +++ b/pv/view/flag.hpp @@ -24,14 +24,15 @@ #include "timemarker.hpp" +using std::enable_shared_from_this; + class QMenu; namespace pv { namespace views { namespace TraceView { -class Flag : public TimeMarker, - public std::enable_shared_from_this +class Flag : public TimeMarker, public enable_shared_from_this { Q_OBJECT diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 8849ee3f..ad91cd12 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -38,6 +38,8 @@ #include using boost::make_filter_iterator; + +using std::count_if; using std::dynamic_pointer_cast; using std::max; using std::make_pair; @@ -138,8 +140,7 @@ void Header::contextMenuEvent(QContextMenuEvent *event) const vector< shared_ptr > items( view_.list_by_type()); - if (std::count_if(items.begin(), items.end(), item_selected) > 1) - { + if (count_if(items.begin(), items.end(), item_selected) > 1) { menu->addSeparator(); QAction *const group = new QAction(tr("Group"), this); @@ -178,7 +179,7 @@ void Header::on_group() shared_ptr group(new TraceGroup()); shared_ptr mouse_down_item( - std::dynamic_pointer_cast(mouse_down_item_)); + dynamic_pointer_cast(mouse_down_item_)); shared_ptr focus_item( mouse_down_item ? mouse_down_item : selected_items.front()); diff --git a/pv/view/header.hpp b/pv/view/header.hpp index f8462c28..c6f81ae5 100644 --- a/pv/view/header.hpp +++ b/pv/view/header.hpp @@ -26,6 +26,9 @@ #include "marginwidget.hpp" +using std::shared_ptr; +using std::vector; + namespace pv { namespace views { namespace TraceView { @@ -63,7 +66,7 @@ private: /** * Gets the row items. */ - std::vector< std::shared_ptr > items(); + vector< shared_ptr > items(); /** * Gets the first view item which has a label that contains @c pt . @@ -71,7 +74,7 @@ private: * @return the view item that has been found, or and empty * @c shared_ptr if no item was found. */ - std::shared_ptr get_mouse_over_item(const QPoint &pt); + shared_ptr get_mouse_over_item(const QPoint &pt); private: void paintEvent(QPaintEvent *event); diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 251190ec..f78170b0 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -46,6 +46,7 @@ using std::deque; using std::max; using std::make_pair; using std::min; +using std::none_of; using std::pair; using std::shared_ptr; using std::vector; @@ -136,7 +137,7 @@ shared_ptr LogicSignal::logic_data() const return base_->logic_data(); } -std::pair LogicSignal::v_extents() const +pair LogicSignal::v_extents() const { const int signal_margin = QFontMetrics(QApplication::font()).height() / 2; @@ -446,7 +447,7 @@ void LogicSignal::modify_trigger() if (trigger) { for (auto stage : trigger->stages()) { const auto &matches = stage->matches(); - if (std::none_of(matches.begin(), matches.end(), + if (none_of(matches.begin(), matches.end(), [&](shared_ptr match) { return match->channel() != base_->channel(); })) continue; diff --git a/pv/view/logicsignal.hpp b/pv/view/logicsignal.hpp index cd4f0e23..417530cb 100644 --- a/pv/view/logicsignal.hpp +++ b/pv/view/logicsignal.hpp @@ -26,6 +26,10 @@ #include +using std::pair; +using std::shared_ptr; +using std::vector; + class QIcon; class QToolBar; @@ -66,20 +70,20 @@ private: public: LogicSignal(pv::Session &session, - std::shared_ptr device, - std::shared_ptr base); + shared_ptr device, + shared_ptr base); virtual ~LogicSignal() = default; - std::shared_ptr data() const; + shared_ptr data() const; - std::shared_ptr logic_data() const; + shared_ptr logic_data() const; /** * Computes the vertical extents of the contents of this row item. * @return A pair containing the minimum and maximum y-values. */ - std::pair v_extents() const; + pair v_extents() const; /** * Returns the offset to show the drag handle. @@ -108,13 +112,13 @@ public: private: void paint_caps(QPainter &p, QLineF *const lines, - std::vector< std::pair > &edges, + vector< pair > &edges, bool level, double samples_per_pixel, double pixels_offset, float x_offset, float y_offset); void init_trigger_actions(QWidget *parent); - const std::vector get_trigger_types() const; + const vector get_trigger_types() const; QAction* action_from_trigger_type( const sigrok::TriggerMatchType *type); const sigrok::TriggerMatchType* trigger_type_from_action( @@ -131,7 +135,7 @@ private Q_SLOTS: private: int signal_height_; - std::shared_ptr device_; + shared_ptr device_; const sigrok::TriggerMatchType *trigger_match_; QToolBar *trigger_bar_; diff --git a/pv/view/marginwidget.hpp b/pv/view/marginwidget.hpp index 1f877761..ebe8cfc0 100644 --- a/pv/view/marginwidget.hpp +++ b/pv/view/marginwidget.hpp @@ -26,6 +26,8 @@ #include "viewwidget.hpp" +using std::shared_ptr; + namespace pv { namespace views { namespace TraceView { @@ -51,14 +53,13 @@ protected: * Indicates the event an a view item has been clicked. * @param item the view item that has been clicked. */ - virtual void item_clicked( - const std::shared_ptr &item); + virtual void item_clicked(const shared_ptr &item); /** * Shows the popup of a the specified @c ViewItem . * @param item The item to show the popup for. */ - void show_popup(const std::shared_ptr &item); + void show_popup(const shared_ptr &item); protected: virtual void contextMenuEvent(QContextMenuEvent *event); diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index be715ec1..712244a9 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -28,6 +28,7 @@ using namespace Qt; +using std::function; using std::shared_ptr; using std::vector; @@ -70,7 +71,7 @@ QSize Ruler::sizeHint() const QSize Ruler::extended_size_hint() const { QRectF max_rect; - std::vector< std::shared_ptr > items(view_.time_items()); + vector< shared_ptr > items(view_.time_items()); for (auto &i : items) max_rect = max_rect.united(i->label_rect(QRect())); return QSize(0, sizeHint().height() - max_rect.top() / 2 + @@ -193,7 +194,7 @@ Ruler::TickPositions Ruler::calculate_tick_positions( const pv::util::Timestamp& offset, const double scale, const int width, - std::function format_function) + function format_function) { TickPositions tp; diff --git a/pv/view/ruler.hpp b/pv/view/ruler.hpp index c8cb0e5f..192de791 100644 --- a/pv/view/ruler.hpp +++ b/pv/view/ruler.hpp @@ -28,6 +28,11 @@ #include "marginwidget.hpp" #include +using std::function; +using std::pair; +using std::shared_ptr; +using std::vector; + namespace RulerTest { struct tick_position_test_0; struct tick_position_test_1; @@ -109,7 +114,7 @@ private: /** * Gets the time items. */ - std::vector< std::shared_ptr > items() override; + vector< shared_ptr > items() override; /** * Gets the first view item which has a label that contains @c pt . @@ -117,8 +122,7 @@ private: * @return the view item that has been found, or and empty * @c shared_ptr if no item was found. */ - std::shared_ptr get_mouse_over_item( - const QPoint &pt) override; + shared_ptr get_mouse_over_item(const QPoint &pt) override; void paintEvent(QPaintEvent *event) override; @@ -135,8 +139,8 @@ private: struct TickPositions { - std::vector> major; - std::vector minor; + vector> major; + vector minor; }; /** @@ -162,7 +166,7 @@ private: const pv::util::Timestamp& offset, const double scale, const int width, - std::function format_function); + function format_function); protected: void resizeEvent(QResizeEvent*) override; diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index a74831a6..065715aa 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -60,7 +60,7 @@ const char *const ChannelNames[] = { }; Signal::Signal(pv::Session &session, - std::shared_ptr channel) : + shared_ptr channel) : Trace(channel), session_(session), scale_handle_(make_shared(*this)), diff --git a/pv/view/signal.hpp b/pv/view/signal.hpp index 8796660e..82d3b51f 100644 --- a/pv/view/signal.hpp +++ b/pv/view/signal.hpp @@ -31,6 +31,8 @@ #include "trace.hpp" #include "viewitemowner.hpp" +using std::shared_ptr; + namespace pv { class Session; @@ -48,8 +50,7 @@ class Signal : public Trace, public ViewItemOwner Q_OBJECT protected: - Signal(pv::Session &session, - std::shared_ptr channel); + Signal(pv::Session &session, shared_ptr channel); public: /** @@ -57,14 +58,14 @@ public: */ virtual void set_name(QString name); - virtual std::shared_ptr data() const = 0; + virtual shared_ptr data() const = 0; /** * Returns true if the trace is visible and enabled. */ bool enabled() const; - std::shared_ptr base() const; + shared_ptr base() const; virtual void save_settings(QSettings &settings) const; @@ -109,7 +110,7 @@ protected Q_SLOTS: protected: pv::Session &session_; - const std::shared_ptr scale_handle_; + const shared_ptr scale_handle_; const item_list items_; QComboBox *name_widget_; diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index 0ca13591..0d4a4536 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -35,6 +35,9 @@ #include "pv/widgets/colourbutton.hpp" #include "pv/widgets/popup.hpp" +using std::pair; +using std::shared_ptr; + namespace pv { namespace views { namespace TraceView { @@ -45,7 +48,7 @@ const int Trace::LabelHitPadding = 2; const QColor Trace::BrightGrayBGColour = QColor(0, 0, 0, 10*255/100); const QColor Trace::DarkGrayBGColour = QColor(0, 0, 0, 15*255/100); -Trace::Trace(std::shared_ptr channel) : +Trace::Trace(shared_ptr channel) : base_(channel), popup_(nullptr), popup_form_(nullptr) @@ -166,7 +169,7 @@ void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp) p.setPen(QPen(Qt::NoPen)); - const std::pair extents = v_extents(); + const pair extents = v_extents(); const int x = 0; const int y = get_visual_y() + extents.first; diff --git a/pv/view/trace.hpp b/pv/view/trace.hpp index 11f80ccb..ac4540c9 100644 --- a/pv/view/trace.hpp +++ b/pv/view/trace.hpp @@ -32,6 +32,8 @@ #include "pv/data/signalbase.hpp" +using std::shared_ptr; + class QFormLayout; namespace pv { @@ -55,7 +57,7 @@ private: static const QColor DarkGrayBGColour; protected: - Trace(std::shared_ptr channel); + Trace(shared_ptr channel); public: /** @@ -127,7 +129,7 @@ private Q_SLOTS: void on_colouredit_changed(const QColor &colour); protected: - std::shared_ptr base_; + shared_ptr base_; bool coloured_bg_, coloured_bg_state_; private: diff --git a/pv/view/tracegroup.cpp b/pv/view/tracegroup.cpp index 490f39c5..5b59eab9 100644 --- a/pv/view/tracegroup.cpp +++ b/pv/view/tracegroup.cpp @@ -27,6 +27,7 @@ #include "tracegroup.hpp" +using std::any_of; using std::pair; using std::shared_ptr; using std::vector; @@ -48,7 +49,7 @@ TraceGroup::~TraceGroup() bool TraceGroup::enabled() const { - return std::any_of(child_items().begin(), child_items().end(), + return any_of(child_items().begin(), child_items().end(), [](const shared_ptr &r) { return r->enabled(); }); } diff --git a/pv/view/tracegroup.hpp b/pv/view/tracegroup.hpp index 80fc5fc0..b00d5bf5 100644 --- a/pv/view/tracegroup.hpp +++ b/pv/view/tracegroup.hpp @@ -23,6 +23,8 @@ #include "tracetreeitem.hpp" #include "tracetreeitemowner.hpp" +using std::pair; + namespace pv { namespace views { namespace TraceView { @@ -72,7 +74,7 @@ public: * Computes the vertical extents of the contents of this row item. * @return A pair containing the minimum and maximum y-values. */ - std::pair v_extents() const; + pair v_extents() const; /** * Paints the signal label. diff --git a/pv/view/tracetreeitem.hpp b/pv/view/tracetreeitem.hpp index cc329121..d1dd67cc 100644 --- a/pv/view/tracetreeitem.hpp +++ b/pv/view/tracetreeitem.hpp @@ -26,6 +26,9 @@ #include "rowitem.hpp" +using std::enable_shared_from_this; +using std::pair; + namespace pv { namespace views { namespace TraceView { @@ -33,7 +36,7 @@ namespace TraceView { class TraceTreeItemOwner; class TraceTreeItem : public RowItem, - public std::enable_shared_from_this + public enable_shared_from_this { Q_OBJECT Q_PROPERTY(int visual_v_offset @@ -122,7 +125,7 @@ public: * Computes the vertical extents of the contents of this row item. * @return A pair containing the minimum and maximum y-values. */ - virtual std::pair v_extents() const = 0; + virtual pair v_extents() const = 0; protected: TraceTreeItemOwner *owner_; diff --git a/pv/view/tracetreeitemowner.cpp b/pv/view/tracetreeitemowner.cpp index b570c038..c8761952 100644 --- a/pv/view/tracetreeitemowner.cpp +++ b/pv/view/tracetreeitemowner.cpp @@ -24,8 +24,9 @@ #include "trace.hpp" using std::dynamic_pointer_cast; -using std::max; +using std::find; using std::make_pair; +using std::max; using std::min; using std::pair; using std::set; @@ -42,7 +43,7 @@ const ViewItemOwner::item_list& TraceTreeItemOwner::child_items() const return items_; } -vector< std::shared_ptr > +vector< shared_ptr > TraceTreeItemOwner::trace_tree_child_items() const { vector< shared_ptr > items; @@ -65,7 +66,7 @@ void TraceTreeItemOwner::clear_child_items() items_.clear(); } -void TraceTreeItemOwner::add_child_item(std::shared_ptr item) +void TraceTreeItemOwner::add_child_item(shared_ptr item) { assert(!item->owner()); item->set_owner(this); @@ -74,11 +75,11 @@ void TraceTreeItemOwner::add_child_item(std::shared_ptr item) extents_changed(true, true); } -void TraceTreeItemOwner::remove_child_item(std::shared_ptr item) +void TraceTreeItemOwner::remove_child_item(shared_ptr item) { assert(item->owner() == this); item->set_owner(nullptr); - auto iter = std::find(items_.begin(), items_.end(), item); + auto iter = find(items_.begin(), items_.end(), item); assert(iter != items_.end()); items_.erase(iter); diff --git a/pv/view/tracetreeitemowner.hpp b/pv/view/tracetreeitemowner.hpp index 6beae5e9..92aae37f 100644 --- a/pv/view/tracetreeitemowner.hpp +++ b/pv/view/tracetreeitemowner.hpp @@ -23,6 +23,10 @@ #include "viewitemowner.hpp" #include "tracetreeitem.hpp" +using std::pair; +using std::shared_ptr; +using std::vector; + namespace pv { class Session; @@ -71,7 +75,7 @@ public: /** * Returns a list of row items owned by this object. */ - std::vector< std::shared_ptr > + vector< shared_ptr > trace_tree_child_items() const; /** @@ -82,12 +86,12 @@ public: /** * Adds a child item to this object. */ - void add_child_item(std::shared_ptr item); + void add_child_item(shared_ptr item); /** * Removes a child item from this object. */ - void remove_child_item(std::shared_ptr item); + void remove_child_item(shared_ptr item); virtual void restack_items(); @@ -95,7 +99,7 @@ public: * Computes the vertical extents of the contents of this row item owner. * @return A pair containing the minimum and maximum y-values. */ - std::pair v_extents() const; + pair v_extents() const; /* * Reassigns background color states to all its children, thereby diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 07e97666..ae37b912 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -77,6 +77,7 @@ using pv::util::Timestamp; using std::back_inserter; using std::copy_if; +using std::count_if; using std::deque; using std::dynamic_pointer_cast; using std::inserter; @@ -90,6 +91,7 @@ using std::pair; using std::set; using std::set_difference; using std::shared_ptr; +using std::stringstream; using std::unordered_map; using std::unordered_set; using std::vector; @@ -224,7 +226,7 @@ const Session& View::session() const return session_; } -std::unordered_set< std::shared_ptr > View::signals() const +unordered_set< shared_ptr > View::signals() const { return signals_; } @@ -289,7 +291,7 @@ void View::save_settings(QSettings &settings) const settings.setValue("v_offset", scrollarea_.verticalScrollBar()->sliderPosition()); - std::stringstream ss; + stringstream ss; boost::archive::text_oarchive oa(ss); oa << boost::serialization::make_nvp("offset", offset_); settings.setValue("offset", QString::fromStdString(ss.str())); @@ -311,7 +313,7 @@ void View::restore_settings(QSettings &settings) if (settings.contains("offset")) { util::Timestamp offset; - std::stringstream ss; + stringstream ss; ss << settings.value("offset").toString().toStdString(); boost::archive::text_iarchive ia(ss); @@ -617,7 +619,7 @@ void View::centre_cursors() viewport_->update(); } -std::shared_ptr View::cursors() const +shared_ptr View::cursors() const { return cursors_; } @@ -633,15 +635,15 @@ void View::add_flag(const Timestamp& time) time_item_appearance_changed(true, true); } -void View::remove_flag(std::shared_ptr flag) +void View::remove_flag(shared_ptr flag) { flags_.remove(flag); time_item_appearance_changed(true, true); } -vector< std::shared_ptr > View::flags() const +vector< shared_ptr > View::flags() const { - vector< std::shared_ptr > flags(flags_.begin(), flags_.end()); + vector< shared_ptr > flags(flags_.begin(), flags_.end()); stable_sort(flags.begin(), flags.end(), [](const shared_ptr &a, const shared_ptr &b) { return a->time() < b->time(); @@ -755,7 +757,7 @@ void View::calculate_tick_spacing() // Precision is the number of fractional digits required, not // taking the prefix into account (and it must never be negative) - tick_precision = std::max(ceil(log10(1 / tick_period)).convert_to(), 0); + tick_precision = max(ceil(log10(1 / tick_period)).convert_to(), 0); tick_period_width = (tick_period / scale_).convert_to(); @@ -887,7 +889,7 @@ TraceTreeItemOwner* View::find_prevalent_trace_group( size_t max_prevalence = 0; TraceTreeItemOwner *prevalent_owner = nullptr; for (TraceTreeItemOwner *owner : owners) { - const size_t prevalence = std::count_if( + const size_t prevalence = count_if( owner_list.begin(), owner_list.end(), [&](TraceTreeItemOwner *o) { return o == owner; }); if (prevalence > max_prevalence) { diff --git a/pv/view/view.hpp b/pv/view/view.hpp index 2ba157d8..e083fa13 100644 --- a/pv/view/view.hpp +++ b/pv/view/view.hpp @@ -40,6 +40,13 @@ #include "flag.hpp" #include "tracetreeitemowner.hpp" +using std::list; +using std::unordered_map; +using std::unordered_set; +using std::set; +using std::shared_ptr; +using std::vector; + namespace sigrok { class ChannelGroup; } @@ -97,18 +104,18 @@ public: /** * Returns the signals contained in this view. */ - std::unordered_set< std::shared_ptr > signals() const; + unordered_set< shared_ptr > signals() const; virtual void clear_signals(); - virtual void add_signal(const std::shared_ptr signal); + virtual void add_signal(const shared_ptr signal); #ifdef ENABLE_DECODE virtual void clear_decode_signals(); - virtual void add_decode_signal(std::shared_ptr signalbase); + virtual void add_decode_signal(shared_ptr signalbase); - virtual void remove_decode_signal(std::shared_ptr signalbase); + virtual void remove_decode_signal(shared_ptr signalbase); #endif /** @@ -132,7 +139,7 @@ public: /** * Gets a list of time markers. */ - std::vector< std::shared_ptr > time_items() const; + vector< shared_ptr > time_items() const; /** * Returns the view time scale in seconds per pixel. @@ -194,10 +201,9 @@ public: */ void set_scale_offset(double scale, const pv::util::Timestamp& offset); - std::set< std::shared_ptr > - get_visible_data() const; + set< shared_ptr > get_visible_data() const; - std::pair get_time_extents() const; + pair get_time_extents() const; /** * Enables or disables coloured trace backgrounds. If they're not @@ -228,7 +234,7 @@ public: /** * Returns a reference to the pair of cursors. */ - std::shared_ptr cursors() const; + shared_ptr cursors() const; /** * Adds a new flag at a specified time. @@ -238,12 +244,12 @@ public: /** * Removes a flag from the list. */ - void remove_flag(std::shared_ptr flag); + void remove_flag(shared_ptr flag); /** * Gets the list of flags. */ - std::vector< std::shared_ptr > flags() const; + vector< shared_ptr > flags() const; const QPoint& hover_point() const; @@ -305,16 +311,16 @@ private: void update_layout(); TraceTreeItemOwner* find_prevalent_trace_group( - const std::shared_ptr &group, - const std::unordered_map, - std::shared_ptr > &signal_map); + const shared_ptr &group, + const unordered_map, + shared_ptr > &signal_map); - static std::vector< std::shared_ptr > + static vector< shared_ptr > extract_new_traces_for_channels( - const std::vector< std::shared_ptr > &channels, - const std::unordered_map, - std::shared_ptr > &signal_map, - std::set< std::shared_ptr > &add_list); + const vector< shared_ptr > &channels, + const unordered_map, + shared_ptr > &signal_map, + set< shared_ptr > &add_list); void determine_time_unit(); @@ -384,10 +390,10 @@ private: Ruler *ruler_; Header *header_; - std::unordered_set< std::shared_ptr > signals_; + unordered_set< shared_ptr > signals_; #ifdef ENABLE_DECODE - std::vector< std::shared_ptr > decode_traces_; + vector< shared_ptr > decode_traces_; #endif CustomAbstractScrollArea scrollarea_; @@ -410,12 +416,12 @@ private: util::TimeUnit time_unit_; bool show_cursors_; - std::shared_ptr cursors_; + shared_ptr cursors_; - std::list< std::shared_ptr > flags_; + list< shared_ptr > flags_; char next_flag_text_; - std::vector< std::shared_ptr > trigger_markers_; + vector< shared_ptr > trigger_markers_; QPoint hover_point_; diff --git a/pv/view/viewitemiterator.hpp b/pv/view/viewitemiterator.hpp index c4c6f2af..91ace4e9 100644 --- a/pv/view/viewitemiterator.hpp +++ b/pv/view/viewitemiterator.hpp @@ -30,6 +30,11 @@ #include +using std::dynamic_pointer_cast; +using std::forward_iterator_tag; +using std::shared_ptr; +using std::stack; + namespace pv { namespace views { namespace TraceView { @@ -38,11 +43,11 @@ template class ViewItemIterator { public: typedef typename Owner::item_list::const_iterator child_iterator; - typedef std::shared_ptr value_type; + typedef shared_ptr value_type; typedef ptrdiff_t difference_type; typedef value_type pointer; typedef const value_type& reference; - typedef std::forward_iterator_tag iterator_category; + typedef forward_iterator_tag iterator_category; public: ViewItemIterator(Owner *owner) : @@ -68,9 +73,6 @@ public: } ViewItemIterator& operator++() { - using std::dynamic_pointer_cast; - using std::shared_ptr; - assert(!owner_stack_.empty()); assert(!iter_stack_.empty()); @@ -113,8 +115,8 @@ public: } private: - std::stack owner_stack_; - std::stack iter_stack_; + stack owner_stack_; + stack iter_stack_; }; template diff --git a/pv/view/viewitemowner.hpp b/pv/view/viewitemowner.hpp index 877c9681..dcec370f 100644 --- a/pv/view/viewitemowner.hpp +++ b/pv/view/viewitemowner.hpp @@ -25,6 +25,10 @@ #include "viewitemiterator.hpp" +using std::dynamic_pointer_cast; +using std::shared_ptr; +using std::vector; + namespace pv { class Session; @@ -38,7 +42,7 @@ class View; class ViewItemOwner { public: - typedef std::vector< std::shared_ptr > item_list; + typedef vector< shared_ptr > item_list; typedef ViewItemIterator iterator; typedef ViewItemIterator const_iterator; @@ -75,10 +79,10 @@ public: * Creates a list of descendant signals filtered by type. */ template - std::vector< std::shared_ptr > list_by_type() { - std::vector< std::shared_ptr > items; + vector< shared_ptr > list_by_type() { + vector< shared_ptr > items; for (const auto &r : *this) { - std::shared_ptr p = std::dynamic_pointer_cast(r); + shared_ptr p = dynamic_pointer_cast(r); if (p) items.push_back(p); } diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index 1504f482..2d10f2a0 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -102,7 +102,7 @@ void Viewport::drag_release() vector< shared_ptr > Viewport::items() { vector< shared_ptr > items; - const std::vector< shared_ptr > view_items( + const vector< shared_ptr > view_items( view_.list_by_type()); copy(view_items.begin(), view_items.end(), back_inserter(items)); const vector< shared_ptr > time_items(view_.time_items()); diff --git a/pv/view/viewport.hpp b/pv/view/viewport.hpp index 555d8f55..de3e681d 100644 --- a/pv/view/viewport.hpp +++ b/pv/view/viewport.hpp @@ -28,6 +28,9 @@ #include "pv/util.hpp" #include "viewwidget.hpp" +using std::shared_ptr; +using std::vector; + class QPainter; class QPaintEvent; class Session; @@ -51,7 +54,7 @@ private: * @param item The item that is being hovered over, or @c nullptr * if no view item is being hovered over. */ - void item_hover(const std::shared_ptr &item); + void item_hover(const shared_ptr &item); /** * Gets the first view item which has a hit-box that contains @c pt . @@ -59,7 +62,7 @@ private: * @return the view item that has been found, or and empty * @c shared_ptr if no item was found. */ - std::shared_ptr get_mouse_over_item(const QPoint &pt); + shared_ptr get_mouse_over_item(const QPoint &pt); /** * Sets this item into the dragged state. @@ -80,7 +83,7 @@ private: /** * Gets the items in the view widget. */ - std::vector< std::shared_ptr > items(); + vector< shared_ptr > items(); /** * Handles touch begin update and end events. diff --git a/pv/view/viewwidget.hpp b/pv/view/viewwidget.hpp index 364ed02a..02c842a8 100644 --- a/pv/view/viewwidget.hpp +++ b/pv/view/viewwidget.hpp @@ -24,6 +24,9 @@ #include +using std::shared_ptr; +using std::vector; + class QTouchEvent; namespace pv { @@ -46,16 +49,14 @@ protected: * if no view item is being hovered over. * @remarks the default implementation does nothing. */ - virtual void item_hover( - const std::shared_ptr &item); + virtual void item_hover(const shared_ptr &item); /** * Indicates the event an a view item has been clicked. * @param item the view item that has been clicked. * @remarks the default implementation does nothing. */ - virtual void item_clicked( - const std::shared_ptr &item); + virtual void item_clicked(const shared_ptr &item); /** * Returns true if the selection of row items allows dragging. @@ -94,7 +95,7 @@ protected: /** * Gets the items in the view widget. */ - virtual std::vector< std::shared_ptr > items() = 0; + virtual vector< shared_ptr > items() = 0; /** * Gets the first view item which has a hit-box that contains @c pt . @@ -102,8 +103,7 @@ protected: * @return the view item that has been found, or and empty * @c shared_ptr if no item was found. */ - virtual std::shared_ptr get_mouse_over_item( - const QPoint &pt) = 0; + virtual shared_ptr get_mouse_over_item(const QPoint &pt) = 0; /** * Handles left mouse button press events. @@ -142,7 +142,7 @@ protected: pv::views::TraceView::View &view_; QPoint mouse_point_; QPoint mouse_down_point_; - std::shared_ptr mouse_down_item_; + shared_ptr mouse_down_item_; bool item_dragging_; }; diff --git a/pv/views/viewbase.hpp b/pv/views/viewbase.hpp index 3e180830..f83187e5 100644 --- a/pv/views/viewbase.hpp +++ b/pv/views/viewbase.hpp @@ -32,6 +32,8 @@ #include #include +using std::shared_ptr; + namespace pv { class Session; @@ -62,9 +64,9 @@ public: #ifdef ENABLE_DECODE virtual void clear_decode_signals(); - virtual void add_decode_signal(std::shared_ptr signalbase); + virtual void add_decode_signal(shared_ptr signalbase); - virtual void remove_decode_signal(std::shared_ptr signalbase); + virtual void remove_decode_signal(shared_ptr signalbase); #endif virtual void save_settings(QSettings &settings) const; diff --git a/pv/widgets/devicetoolbutton.hpp b/pv/widgets/devicetoolbutton.hpp index cedf49e7..46b2240a 100644 --- a/pv/widgets/devicetoolbutton.hpp +++ b/pv/widgets/devicetoolbutton.hpp @@ -29,6 +29,11 @@ #include #include +using std::list; +using std::shared_ptr; +using std::vector; +using std::weak_ptr; + struct srd_decoder; namespace pv { @@ -58,7 +63,7 @@ public: /** * Returns a reference to the selected device. */ - std::shared_ptr selected_device(); + shared_ptr selected_device(); /** * Sets the current list of devices. @@ -66,8 +71,8 @@ public: * @param selected_device the currently active device. */ void set_device_list( - const std::list< std::shared_ptr > &devices, - std::shared_ptr selected); + const list< shared_ptr > &devices, + shared_ptr selected); /** * Sets the current device to "no device". Useful for when a selected @@ -98,8 +103,8 @@ private: QMenu menu_; QSignalMapper mapper_; - std::shared_ptr selected_device_; - std::vector< std::weak_ptr > devices_; + shared_ptr selected_device_; + vector< weak_ptr > devices_; QString device_tooltip_; }; diff --git a/pv/widgets/exportmenu.cpp b/pv/widgets/exportmenu.cpp index 47fb3ec2..13c977d5 100644 --- a/pv/widgets/exportmenu.cpp +++ b/pv/widgets/exportmenu.cpp @@ -31,6 +31,7 @@ using std::map; using std::pair; using std::string; using std::shared_ptr; +using std::vector; using sigrok::Context; using sigrok::OutputFormat; @@ -39,7 +40,7 @@ namespace pv { namespace widgets { ExportMenu::ExportMenu(QWidget *parent, shared_ptr context, - std::vectoropen_actions) : + vectoropen_actions) : QMenu(parent), context_(context), mapper_(this) diff --git a/pv/widgets/exportmenu.hpp b/pv/widgets/exportmenu.hpp index 3416c7b3..0980ffd5 100644 --- a/pv/widgets/exportmenu.hpp +++ b/pv/widgets/exportmenu.hpp @@ -25,6 +25,9 @@ #include #include +using std::shared_ptr; +using std::vector; + namespace sigrok { class Context; class OutputFormat; @@ -38,17 +41,17 @@ class ExportMenu : public QMenu Q_OBJECT; public: - ExportMenu(QWidget *parent, std::shared_ptr context, - std::vectoropen_actions = std::vector()); + ExportMenu(QWidget *parent, shared_ptr context, + vectoropen_actions = vector()); private Q_SLOTS: void on_action(QObject *action); Q_SIGNALS: - void format_selected(std::shared_ptr format); + void format_selected(shared_ptr format); private: - std::shared_ptr context_; + shared_ptr context_; QSignalMapper mapper_; }; diff --git a/pv/widgets/importmenu.hpp b/pv/widgets/importmenu.hpp index ad2a6e79..cb33af98 100644 --- a/pv/widgets/importmenu.hpp +++ b/pv/widgets/importmenu.hpp @@ -25,6 +25,8 @@ #include #include +using std::shared_ptr; + namespace sigrok { class Context; class InputFormat; @@ -38,17 +40,17 @@ class ImportMenu : public QMenu Q_OBJECT; public: - ImportMenu(QWidget *parent, std::shared_ptr context, + ImportMenu(QWidget *parent, shared_ptr context, QAction *open_action = nullptr); private Q_SLOTS: void on_action(QObject *action); Q_SIGNALS: - void format_selected(std::shared_ptr format); + void format_selected(shared_ptr format); private: - std::shared_ptr context_; + shared_ptr context_; QSignalMapper mapper_; }; diff --git a/test/test.cpp b/test/test.cpp index 8fd2e65f..c2a50313 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -21,7 +21,9 @@ #include #include "test/test.hpp" -std::ostream& operator<<(std::ostream& stream, const QString& str) +using std::ostream; + +ostream& operator<<(ostream& stream, const QString& str) { return stream << str.toUtf8().data(); } diff --git a/test/test.hpp b/test/test.hpp index 119f5ab8..62e6cf0d 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -22,6 +22,8 @@ #include -std::ostream& operator<<(std::ostream& stream, const QString& str); +using std::ostream; + +ostream& operator<<(ostream& stream, const QString& str); #endif diff --git a/test/util.cpp b/test/util.cpp index 7ff2a316..0ac6f5fc 100644 --- a/test/util.cpp +++ b/test/util.cpp @@ -25,6 +25,8 @@ using namespace pv::util; using ts = pv::util::Timestamp; +using std::bind; + namespace { QChar mu = QChar(0x03BC); @@ -202,7 +204,7 @@ BOOST_AUTO_TEST_CASE(format_time_minutes_test) { using namespace std::placeholders; - auto fmt = std::bind(format_time_minutes, _1, _2, true); + auto fmt = bind(format_time_minutes, _1, _2, true); BOOST_CHECK_EQUAL(fmt(ts( 0), 0), "+0:00"); BOOST_CHECK_EQUAL(fmt(ts( 1), 0), "+0:01");