diff options
author | Dave Reisner <dreisner@archlinux.org> | 2013-01-02 11:33:59 -0500 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2013-01-02 14:23:57 -0500 |
commit | e35ce0069094c135ed9065f2bda945fdf4b6d83e (patch) | |
tree | 843d860598cbefbe1d3c35ddb4a6d4e320fefed2 /pulse.cc | |
parent | aa6847b94511728250333125c3dd9bec7b65759a (diff) | |
download | mirror-ponymix-e35ce0069094c135ed9065f2bda945fdf4b6d83e.tar.gz mirror-ponymix-e35ce0069094c135ed9065f2bda945fdf4b6d83e.tar.bz2 mirror-ponymix-e35ce0069094c135ed9065f2bda945fdf4b6d83e.zip |
ponymix: validate arg count before invoking function
A few changes make this fun and easy:
- Merge the function array into the string to action lookup and return a
Command instead of simply an enum. A Command is the function and the
min/max arg count.
- Implement an InRange method for the Range class.
- Add a Dispatch function to convert the string to Command and validate
the arguments.
This leaves us in a position where the argc parameter to each method is
never used, but maybe some day a command will be added that takes a
range of args rather than a fixed number.
Diffstat (limited to 'pulse.cc')
-rw-r--r-- | pulse.cc | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -305,12 +305,12 @@ bool PulseClient::SetVolume(Device& device, long volume) { bool PulseClient::IncreaseVolume(Device& device, long increment) { return SetVolume(device, - volume_range_.clamp(device.volume_percent_ + increment)); + volume_range_.Clamp(device.volume_percent_ + increment)); } bool PulseClient::DecreaseVolume(Device& device, long increment) { return SetVolume(device, - volume_range_.clamp(device.volume_percent_ - increment)); + volume_range_.Clamp(device.volume_percent_ - increment)); } bool PulseClient::SetBalance(Device& device, long balance) { @@ -339,12 +339,12 @@ bool PulseClient::SetBalance(Device& device, long balance) { bool PulseClient::IncreaseBalance(Device& device, long increment) { return SetBalance(device, - balance_range_.clamp(device.balance_ + increment)); + balance_range_.Clamp(device.balance_ + increment)); } bool PulseClient::DecreaseBalance(Device& device, long increment) { return SetBalance(device, - balance_range_.clamp(device.balance_ - increment)); + balance_range_.Clamp(device.balance_ - increment)); } int PulseClient::GetVolume(const Device& device) const { |