From c4632da2e78d93aaea376c74d3b1c0d49fa87421 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 18 Jun 2021 20:31:35 -0400 Subject: [PATCH] Push2: Drop "using namespace std" No functional changes, just makes some more context explicit like the previous commit. --- libs/surfaces/push2/gui.cc | 21 +++++++++-------- libs/surfaces/push2/interface.cc | 7 +++--- libs/surfaces/push2/level_meter.cc | 15 ++++++------- libs/surfaces/push2/menu.cc | 15 ++++++------- libs/surfaces/push2/midi_byte_array.cc | 10 ++++----- libs/surfaces/push2/mix.cc | 21 +++++++++-------- libs/surfaces/push2/push2.cc | 31 +++++++++++++------------- libs/surfaces/push2/scale.cc | 11 +++++---- libs/surfaces/push2/splash.cc | 5 ++--- libs/surfaces/push2/track_mix.cc | 1 - 10 files changed, 65 insertions(+), 72 deletions(-) diff --git a/libs/surfaces/push2/gui.cc b/libs/surfaces/push2/gui.cc index 3f15ab3069..5f55d3be1e 100644 --- a/libs/surfaces/push2/gui.cc +++ b/libs/surfaces/push2/gui.cc @@ -40,7 +40,6 @@ using namespace PBD; using namespace ARDOUR; using namespace ArdourSurface; -using namespace std; using namespace Gtk; using namespace Gtkmm2ext; @@ -92,7 +91,7 @@ P2GUI::P2GUI (Push2& p) _table.set_homogeneous (false); std::string data_file_path; - string name = "push2-small.png"; + std::string name = "push2-small.png"; Searchpath spath(ARDOUR::ardour_data_search_path()); spath.add_subdirectory_to_paths ("icons"); find_file (spath, name, data_file_path); @@ -170,8 +169,8 @@ P2GUI::connection_handler () void P2GUI::update_port_combos () { - vector midi_inputs; - vector midi_outputs; + std::vector midi_inputs; + std::vector midi_outputs; ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsTerminal), midi_inputs); ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsTerminal), midi_outputs); @@ -192,7 +191,7 @@ P2GUI::update_port_combos () for (n = 1; i != children.end(); ++i, ++n) { - string port_name = (*i)[_midi_port_columns.full_name]; + std::string port_name = (*i)[_midi_port_columns.full_name]; if (_p2.input_port()->connected_to (port_name)) { _input_combo.set_active (n); input_found = true; @@ -209,7 +208,7 @@ P2GUI::update_port_combos () ++i; /* skip "Disconnected" */ for (n = 1; i != children.end(); ++i, ++n) { - string port_name = (*i)[_midi_port_columns.full_name]; + std::string port_name = (*i)[_midi_port_columns.full_name]; if (_p2.output_port()->connected_to (port_name)) { _output_combo.set_active (n); output_found = true; @@ -223,16 +222,16 @@ P2GUI::update_port_combos () } Glib::RefPtr -P2GUI::build_midi_port_list (vector const & ports, bool for_input) +P2GUI::build_midi_port_list (std::vector const & ports, bool for_input) { Glib::RefPtr store = ListStore::create (_midi_port_columns); TreeModel::Row row; row = *store->append (); - row[_midi_port_columns.full_name] = string(); + row[_midi_port_columns.full_name] = std::string(); row[_midi_port_columns.short_name] = _("Disconnected"); - for (vector::const_iterator p = ports.begin(); p != ports.end(); ++p) { + for (std::vector::const_iterator p = ports.begin(); p != ports.end(); ++p) { row = *store->append (); row[_midi_port_columns.full_name] = *p; std::string pn = ARDOUR::AudioEngine::instance()->get_pretty_name_by_name (*p); @@ -253,7 +252,7 @@ P2GUI::active_port_changed (Gtk::ComboBox* combo, bool for_input) } TreeModel::iterator active = combo->get_active (); - string new_port = (*active)[_midi_port_columns.full_name]; + std::string new_port = (*active)[_midi_port_columns.full_name]; if (new_port.empty()) { if (for_input) { @@ -312,6 +311,6 @@ P2GUI::reprogram_pressure_mode () pm = Push2::AfterTouch; } - cerr << "Reprogram pm to " << pm << endl; + std::cerr << "Reprogram pm to " << pm << std::endl; _p2.set_pressure_mode (pm); } diff --git a/libs/surfaces/push2/interface.cc b/libs/surfaces/push2/interface.cc index 0f2d3d7000..43aafe9eca 100644 --- a/libs/surfaces/push2/interface.cc +++ b/libs/surfaces/push2/interface.cc @@ -27,7 +27,6 @@ using namespace ARDOUR; using namespace PBD; -using namespace std; using namespace ArdourSurface; static ControlProtocol* @@ -39,7 +38,7 @@ new_push2 (ControlProtocolDescriptor*, Session* s) p2 = new Push2 (*s); /* do not set active here - wait for set_state() */ } - catch (exception & e) { + catch (std::exception & e) { error << "Error instantiating Push2 support: " << e.what() << endmsg; delete p2; p2 = 0; @@ -55,9 +54,9 @@ delete_push2 (ControlProtocolDescriptor*, ControlProtocol* cp) { delete cp; } - catch ( exception & e ) + catch ( std::exception & e ) { - cout << "Exception caught trying to finalize Push2 support: " << e.what() << endl; + std::cout << "Exception caught trying to finalize Push2 support: " << e.what() << std::endl; } } diff --git a/libs/surfaces/push2/level_meter.cc b/libs/surfaces/push2/level_meter.cc index c3b9e0840c..4af396d76c 100644 --- a/libs/surfaces/push2/level_meter.cc +++ b/libs/surfaces/push2/level_meter.cc @@ -38,7 +38,6 @@ using namespace ARDOUR; using namespace PBD; using namespace Gtkmm2ext; -using namespace std; using namespace ArdourSurface; using namespace ArdourCanvas; @@ -72,7 +71,7 @@ LevelMeter::~LevelMeter () _configuration_connection.disconnect(); _meter_type_connection.disconnect(); _parameter_connection.disconnect(); - for (vector::iterator i = _meters.begin(); i != _meters.end(); i++) { + for (std::vector::iterator i = _meters.begin(); i != _meters.end(); ++i) { delete (*i).meter; } _meters.clear(); @@ -136,7 +135,7 @@ static float vu_standard() { float LevelMeter::update_meters () { - vector::iterator i; + std::vector::iterator i; uint32_t n; if (!_meter) { @@ -191,10 +190,10 @@ LevelMeter::update_meters () } void -LevelMeter::parameter_changed (string p) +LevelMeter::parameter_changed (std::string p) { if (p == "meter-hold") { - vector::iterator i; + std::vector::iterator i; uint32_t n; for (n = 0, i = _meters.begin(); i != _meters.end(); ++i, ++n) { @@ -209,7 +208,7 @@ LevelMeter::parameter_changed (string p) setup_meters (_meter_length, _regular_meter_width, _thin_meter_width); } else if (p == "meter-peak") { - vector::iterator i; + std::vector::iterator i; uint32_t n; for (n = 0, i = _meters.begin(); i != _meters.end(); ++i, ++n) { @@ -233,7 +232,7 @@ LevelMeter::meter_type_changed (MeterType t) void LevelMeter::hide_all_meters () { - for (vector::iterator i = _meters.begin(); i != _meters.end(); ++i) { + for (std::vector::iterator i = _meters.begin(); i != _meters.end(); ++i) { if ((*i).packed) { _meter_packer->remove ((*i).meter); (*i).packed = false; @@ -486,7 +485,7 @@ LevelMeter::setup_meters (int len, int initial_width, int thin_width) void LevelMeter::clear_meters (bool reset_highlight) { - for (vector::iterator i = _meters.begin(); i < _meters.end(); i++) { + for (std::vector::iterator i = _meters.begin(); i < _meters.end(); ++i) { (*i).meter->clear(); (*i).max_peak = minus_infinity(); if (reset_highlight) diff --git a/libs/surfaces/push2/menu.cc b/libs/surfaces/push2/menu.cc index 515594c1a6..a5fe1ca3b5 100644 --- a/libs/surfaces/push2/menu.cc +++ b/libs/surfaces/push2/menu.cc @@ -40,13 +40,12 @@ #endif using namespace ARDOUR; -using namespace std; using namespace PBD; using namespace Glib; using namespace ArdourSurface; using namespace ArdourCanvas; -Push2Menu::Push2Menu (Item* parent, vector s) +Push2Menu::Push2Menu (Item* parent, std::vector s) : Container (parent) , _baseline (-1) , _ncols (0) @@ -70,7 +69,7 @@ Push2Menu::Push2Menu (Item* parent, vector s) _active_bg = new ArdourCanvas::Rectangle (this); - for (vector::iterator si = s.begin(); si != s.end(); ++si) { + for (std::vector::iterator si = s.begin(); si != s.end(); ++si) { Text* t = new Text (this); t->set_font_description (fd); t->set (*si); @@ -96,7 +95,7 @@ Push2Menu::rearrange (uint32_t initial_display) return; } - vector::iterator i = _displays.begin(); + std::vector::iterator i = _displays.begin(); /* move to first */ @@ -182,7 +181,7 @@ Push2Menu::scroll (Direction dir, bool page) case DirectionLeft: if (page) { - set_active (max (0, (int) (_first - (_nrows * _ncols)))); + set_active (std::max (0, (int) (_first - (_nrows * _ncols)))); } else { if (_active / _nrows == 0) { /* in the first column, go to last column, same row */ @@ -198,7 +197,7 @@ Push2Menu::scroll (Direction dir, bool page) case DirectionRight: if (page) { - set_active (min ((uint32_t) _displays.size(), _first + (_nrows * _ncols))); + set_active (std::min ((uint32_t) _displays.size(), _first + (_nrows * _ncols))); } else { if (_active / _nrows == _ncols) { /* in the last column, go to same row in first column */ @@ -270,7 +269,7 @@ Push2Menu::set_text_color (Gtkmm2ext::Color c) { _text_color = c; - for (vector::iterator t = _displays.begin(); t != _displays.end(); ++t) { + for (std::vector::iterator t = _displays.begin(); t != _displays.end(); ++t) { (*t)->set_color (c); } @@ -295,7 +294,7 @@ Push2Menu::set_font_description (Pango::FontDescription fd) { _font_description = fd; - for (vector::iterator t = _displays.begin(); t != _displays.end(); ++t) { + for (std::vector::iterator t = _displays.begin(); t != _displays.end(); ++t) { (*t)->set_font_description (fd); } } diff --git a/libs/surfaces/push2/midi_byte_array.cc b/libs/surfaces/push2/midi_byte_array.cc index 28c2b46db4..2ba2265ffe 100644 --- a/libs/surfaces/push2/midi_byte_array.cc +++ b/libs/surfaces/push2/midi_byte_array.cc @@ -26,8 +26,6 @@ #include #include -using namespace std; - MidiByteArray::MidiByteArray (size_t size, MIDI::byte array[]) : std::vector() { @@ -67,21 +65,21 @@ MidiByteArray & operator << (MidiByteArray & mba, const MIDI::byte & b) MidiByteArray & operator << (MidiByteArray & mba, const MidiByteArray & barr) { - back_insert_iterator bit (mba); + std::back_insert_iterator bit (mba); copy (barr.begin(), barr.end(), bit); return mba; } -ostream & operator << (ostream & os, const MidiByteArray & mba) +std::ostream & operator << (std::ostream & os, const MidiByteArray & mba) { os << "["; char fill = os.fill('0'); for (MidiByteArray::const_iterator it = mba.begin(); it != mba.end(); ++it) { if (it != mba.begin()) os << " "; - os << hex << setw(2) << (int)*it; + os << std::hex << std::setw(2) << (int)*it; } os.fill (fill); - os << dec; + os << std::dec; os << "]"; return os; } diff --git a/libs/surfaces/push2/mix.cc b/libs/surfaces/push2/mix.cc index 861048ef37..4e3899c6d3 100644 --- a/libs/surfaces/push2/mix.cc +++ b/libs/surfaces/push2/mix.cc @@ -67,7 +67,6 @@ #endif using namespace ARDOUR; -using namespace std; using namespace PBD; using namespace Glib; using namespace ArdourSurface; @@ -113,7 +112,7 @@ MixLayout::MixLayout (Push2& p, Session & s, std::string const & name) t->set_color (_p2.get_color (Push2::ParameterName)); t->set_position (Duple (10 + (n*Push2Canvas::inter_button_spacing()), 5)); - string txt; + std::string txt; switch (n) { case 0: txt = _("Volumes"); @@ -424,9 +423,13 @@ MixLayout::strip_vpot (int n, int delta) boost::shared_ptr ac = gain_meter[n]->knob->controllable(); if (ac) { - ac->set_value (ac->interface_to_internal ( - min (ac->upper(), max (ac->lower(), ac->internal_to_interface (ac->get_value()) + (delta/256.0)))), - PBD::Controllable::UseGroup); + ac->set_value ( + ac->interface_to_internal ( + std::min (ac->upper (), + std::max (ac->lower (), + ac->internal_to_interface (ac->get_value ()) + + (delta / 256.0)))), + PBD::Controllable::UseGroup); } } @@ -512,8 +515,8 @@ MixLayout::mute_changed (uint32_t n) void MixLayout::solo_mute_changed (uint32_t n) { - string shortname = short_version (_stripable[n]->name(), 10); - string text; + std::string shortname = short_version (_stripable[n]->name(), 10); + std::string text; boost::shared_ptr ac; ac = _stripable[n]->solo_control(); if (ac && ac->get_value()) { @@ -648,13 +651,13 @@ MixLayout::switch_bank (uint32_t base) void MixLayout::button_right () { - switch_bank (max (0, _bank_start + 8)); + switch_bank (std::max (0, _bank_start + 8)); } void MixLayout::button_left () { - switch_bank (max (0, _bank_start - 8)); + switch_bank (std::max (0, _bank_start - 8)); } diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 9075764a0c..06a663dc6a 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -66,7 +66,6 @@ #endif using namespace ARDOUR; -using namespace std; using namespace PBD; using namespace Glib; using namespace ArdourSurface; @@ -78,7 +77,7 @@ using namespace Gtkmm2ext; #define PUSH2 0x1967 Push2::Push2 (ARDOUR::Session& s) - : ControlProtocol (s, string (X_("Ableton Push 2"))) + : ControlProtocol (s, std::string (X_("Ableton Push 2"))) , AbstractUI (name()) , _handle (0) , _in_use (false) @@ -628,7 +627,7 @@ Push2::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* ev) if (ev->value) { /* any press cancels any pending long press timeouts */ - for (set::iterator x = _buttons_down.begin(); x != _buttons_down.end(); ++x) { + for (std::set::iterator x = _buttons_down.begin(); x != _buttons_down.end(); ++x) { boost::shared_ptr