aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2016-06-06 08:19:27 -0400
committerDave Reisner <dreisner@archlinux.org>2016-06-06 08:19:27 -0400
commit8ba83e91bf8457fd9cf3110538fc278c426c0dc0 (patch)
treefc7396ed408eef2418bb99f6ef7bcfc027dca03a
parenta502864f63e0c43a44c500e7076753b6e1fa21ff (diff)
downloadmirror-ponymix-8ba83e91bf8457fd9cf3110538fc278c426c0dc0.tar.gz
mirror-ponymix-8ba83e91bf8457fd9cf3110538fc278c426c0dc0.tar.bz2
mirror-ponymix-8ba83e91bf8457fd9cf3110538fc278c426c0dc0.zip
get rid of using std::* statements in headers
-rw-r--r--ponymix.cc14
-rw-r--r--pulse.cc45
-rw-r--r--pulse.h84
3 files changed, 69 insertions, 74 deletions
diff --git a/ponymix.cc b/ponymix.cc
index 5f1e98c..1464d9f 100644
--- a/ponymix.cc
+++ b/ponymix.cc
@@ -88,7 +88,7 @@ static const char* type_to_string(enum DeviceType t) {
}
static enum DeviceType string_to_devtype_or_die(const char* str) {
- static std::map<string, enum DeviceType> typemap{
+ static std::map<std::string, enum DeviceType> typemap{
{ "sink", DEVTYPE_SINK },
{ "source", DEVTYPE_SOURCE },
{ "sink-input", DEVTYPE_SINK_INPUT },
@@ -102,7 +102,7 @@ static enum DeviceType string_to_devtype_or_die(const char* str) {
}
static Device* string_to_device_or_die(PulseClient& ponymix,
- string arg,
+ std::string arg,
enum DeviceType type) {
Device* device = ponymix.GetDevice(arg, type);
if (device == nullptr) errx(1, "no match found for device: %s", arg.c_str());
@@ -400,7 +400,7 @@ static int IsAvailable(PulseClient& ponymix, int, char*[]) {
return ponymix.Availability(*device) == Device::AVAILABLE_YES;
}
-static bool endswith(const string& subject, const string& predicate) {
+static bool endswith(const std::string& subject, const std::string& predicate) {
if (subject.size() < predicate.size()) {
return false;
}
@@ -409,9 +409,9 @@ static bool endswith(const string& subject, const string& predicate) {
predicate.size(), predicate) == 0;
}
-static const std::pair<const string, const Command>& string_to_command(
+static const std::pair<const std::string, const Command>& string_to_command(
const char* str) {
- static std::map<string, const Command> actionmap{
+ static std::map<std::string, const Command> actionmap{
// command name function arg min arg max
{ "defaults", { ShowDefaults, { 0, 0 } } },
{ "list", { List, { 0, 0 } } },
@@ -460,7 +460,7 @@ static const std::pair<const string, const Command>& string_to_command(
}
if (iter != match) {
auto i = match;
- string cand = i->first;
+ std::string cand = i->first;
i++;
while (i->first.find(str) == 0) {
cand += ", " + i->first;
@@ -558,7 +558,7 @@ static int CommandDispatch(PulseClient& ponymix, int argc, char *argv[]) {
error_wrong_args(cmd.second, cmd.first.c_str());
}
- if (endswith(cmd.first, string("-short"))) {
+ if (endswith(cmd.first, std::string("-short"))) {
opt_short = true;
}
diff --git a/pulse.cc b/pulse.cc
index fc450ae..ab3f3cf 100644
--- a/pulse.cc
+++ b/pulse.cc
@@ -8,7 +8,6 @@
#include <stdlib.h>
// C++
-#include <string>
#include <algorithm>
#include <stdexcept>
@@ -39,7 +38,7 @@ static void card_info_cb(pa_context* context,
}
if (!eol) {
- vector<Card>* cards = static_cast<vector<Card>*>(raw);
+ std::vector<Card>* cards = static_cast<std::vector<Card>*>(raw);
cards->push_back(info);
}
}
@@ -56,7 +55,7 @@ static void device_info_cb(pa_context* context,
}
if (!eol) {
- vector<Device>* devices_ = static_cast<vector<Device>*>(raw);
+ std::vector<Device>* devices_ = static_cast<std::vector<Device>*>(raw);
devices_->push_back(info);
}
}
@@ -91,7 +90,7 @@ static int xstrtol(const char *str, long *out) {
} // anonymous namespace
-PulseClient::PulseClient(string client_name) :
+PulseClient::PulseClient(std::string client_name) :
client_name_(client_name),
volume_range_(0, 150),
balance_range_(-100, 100),
@@ -145,7 +144,7 @@ Card* PulseClient::GetCard(const uint32_t index) {
return nullptr;
}
-Card* PulseClient::GetCard(const string& name) {
+Card* PulseClient::GetCard(const std::string& name) {
long val;
if (xstrtol(name.c_str(), &val) == 0) {
return GetCard(val);
@@ -161,7 +160,7 @@ Card* PulseClient::GetCard(const Device& device) {
return nullptr;
}
-Device* PulseClient::get_device(vector<Device>& devices,
+Device* PulseClient::get_device(std::vector<Device>& devices,
const uint32_t index) {
for (Device& device : devices) {
if (device.index_ == index) return &device;
@@ -169,7 +168,7 @@ Device* PulseClient::get_device(vector<Device>& devices,
return nullptr;
}
-Device* PulseClient::get_device(vector<Device>& devices, const string& name) {
+Device* PulseClient::get_device(std::vector<Device>& devices, const std::string& name) {
long val;
if (xstrtol(name.c_str(), &val) == 0) {
return get_device(devices, val);
@@ -193,7 +192,7 @@ Device* PulseClient::GetDevice(const uint32_t index, enum DeviceType type) {
throw unreachable();
}
-Device* PulseClient::GetDevice(const string& name, enum DeviceType type) {
+Device* PulseClient::GetDevice(const std::string& name, enum DeviceType type) {
switch (type) {
case DEVTYPE_SINK:
return GetSink(name);
@@ -208,7 +207,7 @@ Device* PulseClient::GetDevice(const string& name, enum DeviceType type) {
throw unreachable();
}
-const vector<Device>& PulseClient::GetDevices(enum DeviceType type) const {
+const std::vector<Device>& PulseClient::GetDevices(enum DeviceType type) const {
switch (type) {
case DEVTYPE_SINK:
return GetSinks();
@@ -227,7 +226,7 @@ Device* PulseClient::GetSink(const uint32_t index) {
return get_device(sinks_, index);
}
-Device* PulseClient::GetSink(const string& name) {
+Device* PulseClient::GetSink(const std::string& name) {
return get_device(sinks_, name);
}
@@ -235,7 +234,7 @@ Device* PulseClient::GetSource(const uint32_t index) {
return get_device(sources_, index);
}
-Device* PulseClient::GetSource(const string& name) {
+Device* PulseClient::GetSource(const std::string& name) {
return get_device(sources_, name);
}
@@ -243,7 +242,7 @@ Device* PulseClient::GetSinkInput(const uint32_t index) {
return get_device(sink_inputs_, index);
}
-Device* PulseClient::GetSinkInput(const string& name) {
+Device* PulseClient::GetSinkInput(const std::string& name) {
return get_device(sink_inputs_, name);
}
@@ -251,7 +250,7 @@ Device* PulseClient::GetSourceOutput(const uint32_t index) {
return get_device(source_outputs_, index);
}
-Device* PulseClient::GetSourceOutput(const string& name) {
+Device* PulseClient::GetSourceOutput(const std::string& name) {
return get_device(source_outputs_, name);
}
@@ -263,11 +262,11 @@ void PulseClient::mainloop_iterate(pa_operation* op) {
}
template<class T>
-T* PulseClient::find_fuzzy(vector<T>& haystack, const string& needle) {
- vector<T*> res;
+T* PulseClient::find_fuzzy(std::vector<T>& haystack, const std::string& needle) {
+ std::vector<T*> res;
for (T& item : haystack) {
- if (item.name_.find(needle) != string::npos) res.push_back(&item);
+ if (item.name_.find(needle) != std::string::npos) res.push_back(&item);
}
switch (res.size()) {
@@ -283,7 +282,7 @@ T* PulseClient::find_fuzzy(vector<T>& haystack, const string& needle) {
}
void PulseClient::populate_cards() {
- vector<Card> cards;
+ std::vector<Card> cards;
pa_operation* op = pa_context_get_card_info_list(context_,
card_info_cb,
static_cast<void*>(&cards));
@@ -303,13 +302,13 @@ void PulseClient::populate_server_info() {
}
void PulseClient::populate_sinks() {
- vector<Device> sinks;
+ std::vector<Device> sinks;
pa_operation* op = pa_context_get_sink_info_list(
context_, device_info_cb, static_cast<void*>(&sinks));
mainloop_iterate(op);
pa_operation_unref(op);
- vector<Device> sink_inputs;
+ std::vector<Device> sink_inputs;
op = pa_context_get_sink_input_info_list(
context_, device_info_cb, static_cast<void*>(&sink_inputs));
mainloop_iterate(op);
@@ -321,13 +320,13 @@ void PulseClient::populate_sinks() {
}
void PulseClient::populate_sources() {
- vector<Device> sources;
+ std::vector<Device> sources;
pa_operation* op = pa_context_get_source_info_list(
context_, device_info_cb, static_cast<void*>(&sources));
mainloop_iterate(op);
pa_operation_unref(op);
- vector<Device> source_outputs;
+ std::vector<Device> source_outputs;
op = pa_context_get_source_output_info_list(
context_, device_info_cb, static_cast<void*>(&source_outputs));
mainloop_iterate(op);
@@ -441,7 +440,7 @@ int PulseClient::GetBalance(const Device& device) const {
return device.Balance();
}
-bool PulseClient::SetProfile(Card& card, const string& profile) {
+bool PulseClient::SetProfile(Card& card, const std::string& profile) {
int success;
pa_operation* op =
pa_context_set_card_profile_by_index(context_,
@@ -537,7 +536,7 @@ bool PulseClient::SetDefault(Device& device) {
}
void PulseClient::remove_device(Device& device) {
- vector<Device>* devlist;
+ std::vector<Device>* devlist;
switch (device.type_) {
case DEVTYPE_SINK:
diff --git a/pulse.h b/pulse.h
index a825d62..9f2d447 100644
--- a/pulse.h
+++ b/pulse.h
@@ -14,10 +14,6 @@
// external
#include <pulse/pulseaudio.h>
-using std::string;
-using std::vector;
-using std::unique_ptr;
-
enum DeviceType {
DEVTYPE_SINK,
DEVTYPE_SOURCE,
@@ -31,8 +27,8 @@ struct Profile {
desc(info.description) {
}
- string name;
- string desc;
+ std::string name;
+ std::string desc;
};
struct Operations {
@@ -61,8 +57,8 @@ class Device {
Device(const pa_source_output_info* info);
uint32_t Index() const { return index_; }
- const string& Name() const { return name_; }
- const string& Desc() const { return desc_; }
+ const std::string& Name() const { return name_; }
+ const std::string& Desc() const { return desc_; }
int Volume() const { return volume_percent_; }
int Balance() const { return balance_; }
bool Muted() const { return mute_; }
@@ -75,8 +71,8 @@ class Device {
enum DeviceType type_;
uint32_t index_;
- string name_;
- string desc_;
+ std::string name_;
+ std::string desc_;
pa_cvolume volume_;
int volume_percent_;
pa_channel_map channels_;
@@ -91,30 +87,30 @@ class Card {
public:
Card(const pa_card_info* info);
- const string& Name() const { return name_; }
+ const std::string& Name() const { return name_; }
uint32_t Index() const { return index_; }
- const string& Driver() const { return driver_; }
+ const std::string& Driver() const { return driver_; }
- const vector<Profile>& Profiles() const { return profiles_; }
+ const std::vector<Profile>& Profiles() const { return profiles_; }
const Profile& ActiveProfile() const { return active_profile_; }
private:
friend class PulseClient;
uint32_t index_;
- string name_;
+ std::string name_;
uint32_t owner_module_;
- string driver_;
- vector<Profile> profiles_;
+ std::string driver_;
+ std::vector<Profile> profiles_;
Profile active_profile_;
};
struct ServerInfo {
- string sink;
- string source;
- string empty = "";
+ std::string sink;
+ std::string source;
+ std::string empty = "";
- const string& GetDefault(enum DeviceType type) {
+ const std::string& GetDefault(enum DeviceType type) {
switch (type) {
case DEVTYPE_SINK:
return sink;
@@ -146,7 +142,7 @@ struct Range {
class PulseClient {
public:
- PulseClient(string client_name);
+ PulseClient(std::string client_name);
~PulseClient();
// Populates all known devices and cards. Any currently known
@@ -155,35 +151,35 @@ class PulseClient {
// Get a device by index or name and type, or all devices by type.
Device* GetDevice(const uint32_t index, enum DeviceType type);
- Device* GetDevice(const string& name, enum DeviceType type);
- const vector<Device>& GetDevices(enum DeviceType type) const;
+ Device* GetDevice(const std::string& name, enum DeviceType type);
+ const std::vector<Device>& GetDevices(enum DeviceType type) const;
// Get a sink by index or name, or all sinks.
Device* GetSink(const uint32_t index);
- Device* GetSink(const string& name);
- const vector<Device>& GetSinks() const { return sinks_; }
+ Device* GetSink(const std::string& name);
+ const std::vector<Device>& GetSinks() const { return sinks_; }
// Get a source by index or name, or all sources.
Device* GetSource(const uint32_t index);
- Device* GetSource(const string& name);
- const vector<Device>& GetSources() const { return sources_; }
+ Device* GetSource(const std::string& name);
+ const std::vector<Device>& GetSources() const { return sources_; }
// Get a sink input by index or name, or all sink inputs.
Device* GetSinkInput(const uint32_t name);
- Device* GetSinkInput(const string& name);
- const vector<Device>& GetSinkInputs() const { return sink_inputs_; }
+ Device* GetSinkInput(const std::string& name);
+ const std::vector<Device>& GetSinkInputs() const { return sink_inputs_; }
// Get a source output by index or name, or all source outputs.
Device* GetSourceOutput(const uint32_t name);
- Device* GetSourceOutput(const string& name);
- const vector<Device>& GetSourceOutputs() const { return source_outputs_; }
+ Device* GetSourceOutput(const std::string& name);
+ const std::vector<Device>& GetSourceOutputs() const { return source_outputs_; }
// Get a card by index or name, all cards, or get the card which
// a sink is attached to.
Card* GetCard(const uint32_t index);
- Card* GetCard(const string& name);
+ Card* GetCard(const std::string& name);
Card* GetCard(const Device& device);
- const vector<Card>& GetCards() const { return cards_; }
+ const std::vector<Card>& GetCards() const { return cards_; }
// Get or set the volume of a device.
int GetVolume(const Device& device) const;
@@ -210,7 +206,7 @@ class PulseClient {
}
// Set the profile for a card by name.
- bool SetProfile(Card& card, const string& profile);
+ bool SetProfile(Card& card, const std::string& profile);
// Move a given source output or sink input to the destination.
bool Move(Device& source, Device& dest);
@@ -236,30 +232,30 @@ class PulseClient {
private:
void mainloop_iterate(pa_operation* op);
- template<class T> T* find_fuzzy(vector<T>& haystack, const string& needle);
+ template<class T> T* find_fuzzy(std::vector<T>& haystack, const std::string& needle);
void populate_server_info();
void populate_cards();
void populate_sinks();
void populate_sources();
- Device* get_device(vector<Device>& devices, const uint32_t index);
- Device* get_device(vector<Device>& devices, const string& name);
+ Device* get_device(std::vector<Device>& devices, const uint32_t index);
+ Device* get_device(std::vector<Device>& devices, const std::string& name);
void remove_device(Device& device);
- string client_name_;
+ std::string client_name_;
pa_context* context_;
pa_mainloop* mainloop_;
- vector<Device> sinks_;
- vector<Device> sources_;
- vector<Device> sink_inputs_;
- vector<Device> source_outputs_;
- vector<Card> cards_;
+ std::vector<Device> sinks_;
+ std::vector<Device> sources_;
+ std::vector<Device> sink_inputs_;
+ std::vector<Device> source_outputs_;
+ std::vector<Card> cards_;
ServerInfo defaults_;
Range<int> volume_range_;
Range<int> balance_range_;
- unique_ptr<Notifier> notifier_;
+ std::unique_ptr<Notifier> notifier_;
};
class unreachable : public std::runtime_error {