Replace boost::format with PBD::string_compose
This commit is contained in:
parent
609b723650
commit
8eb9263af2
@ -4,7 +4,7 @@
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include "pbd/compose.h"
|
||||
|
||||
#include "audiographer/visibility.h"
|
||||
#include "audiographer/debug_utils.h"
|
||||
@ -20,20 +20,18 @@ class LIBAUDIOGRAPHER_API Exception : public std::exception
|
||||
public:
|
||||
template<typename T>
|
||||
Exception (T const & thrower, std::string const & reason)
|
||||
: reason (boost::str (boost::format
|
||||
("Exception thrown by %1%: %2%")
|
||||
% DebugUtils::demangled_name (thrower) % reason))
|
||||
: explanation(string_compose ("Exception thrown by %1: %2", DebugUtils::demangled_name (thrower), reason))
|
||||
{}
|
||||
|
||||
virtual ~Exception () throw() { }
|
||||
|
||||
const char* what() const throw()
|
||||
{
|
||||
return reason.c_str();
|
||||
return explanation.c_str();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string const reason;
|
||||
std::string const explanation;
|
||||
|
||||
};
|
||||
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include "process_context.h"
|
||||
#include "types.h"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
namespace AudioGrapher
|
||||
{
|
||||
|
||||
@ -35,10 +33,11 @@ class LIBAUDIOGRAPHER_API FlagDebuggable : public Debuggable<L>
|
||||
FlagField unsupported = flags.unsupported_flags_of (context.flags());
|
||||
|
||||
for (FlagField::iterator it = unsupported.begin(); it != unsupported.end(); ++it) {
|
||||
Debuggable<L>::debug_stream() << boost::str (boost::format
|
||||
("%1% does not support flag %2%")
|
||||
% DebugUtils::demangled_name (self) % DebugUtils::process_context_flag_name (*it)
|
||||
) << std::endl;
|
||||
Debuggable<L>::debug_stream()
|
||||
<< DebugUtils::demangled_name (self)
|
||||
<< " does not support flag "
|
||||
<< DebugUtils::process_context_flag_name (*it)
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <string>
|
||||
|
||||
#include <glib.h>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "audiographer/flag_debuggable.h"
|
||||
#include "audiographer/sink.h"
|
||||
@ -70,8 +69,7 @@ public:
|
||||
check_flags (*this, c);
|
||||
|
||||
if (_tmp_fd < 0 && (!_proc || !_proc->is_running())) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("Target encoder process is not running")));
|
||||
throw Exception (*this, "Target encoder process is not running");
|
||||
}
|
||||
|
||||
const size_t bytes_per_sample = sizeof (T);
|
||||
@ -85,8 +83,7 @@ public:
|
||||
samples_written += written;
|
||||
|
||||
if (throw_level (ThrowProcess) && written != c.samples()) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("Could not write data to output file")));
|
||||
throw Exception (*this, "Could not write data to output file");
|
||||
}
|
||||
|
||||
if (c.has_flag(ProcessContext<T>::EndOfInput)) {
|
||||
|
@ -8,11 +8,11 @@
|
||||
#include <glibmm/threadpool.h>
|
||||
#include <glibmm/timeval.h>
|
||||
#include <sigc++/slot.h>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "pbd/atomic.h"
|
||||
#include "pbd/compose.h"
|
||||
|
||||
#include "audiographer/visibility.h"
|
||||
#include "audiographer/source.h"
|
||||
@ -28,10 +28,7 @@ class /*LIBAUDIOGRAPHER_API*/ ThreaderException : public Exception
|
||||
public:
|
||||
template<typename T>
|
||||
ThreaderException (T const & thrower, std::exception const & e)
|
||||
: Exception (thrower,
|
||||
boost::str ( boost::format
|
||||
("\n\t- Dynamic type: %1%\n\t- what(): %2%")
|
||||
% DebugUtils::demangled_name (e) % e.what() ))
|
||||
: Exception (thrower, string_compose ("\n\t- Dynamic type: %1\n\t- what(): %2", DebugUtils::demangled_name (e), e.what()))
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef AUDIOGRAPHER_SNDFILE_READER_H
|
||||
#define AUDIOGRAPHER_SNDFILE_READER_H
|
||||
|
||||
#include "pbd/compose.h"
|
||||
|
||||
#include "audiographer/utils/listed_source.h"
|
||||
#include "audiographer/process_context.h"
|
||||
#include "audiographer/sndfile/sndfile_base.h"
|
||||
@ -32,9 +34,9 @@ class SndfileReader
|
||||
samplecnt_t read (ProcessContext<T> & context)
|
||||
{
|
||||
if (throw_level (ThrowStrict) && context.channels() != channels() ) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("Wrong number of channels given to process(), %1% instead of %2%")
|
||||
% context.channels() % channels()));
|
||||
throw Exception (*this, string_compose
|
||||
("Wrong number of channels given to process(), %1 instead of %2",
|
||||
context.channels(), channels()));
|
||||
}
|
||||
|
||||
samplecnt_t const samples_read = SndfileHandle::read (context.data(), context.samples());
|
||||
|
@ -3,14 +3,13 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "audiographer/flag_debuggable.h"
|
||||
#include "audiographer/sink.h"
|
||||
#include "audiographer/types.h"
|
||||
#include "audiographer/sndfile/sndfile_base.h"
|
||||
#include "audiographer/broadcast_info.h"
|
||||
|
||||
#include "pbd/compose.h"
|
||||
#include "pbd/signals.h"
|
||||
|
||||
namespace AudioGrapher
|
||||
@ -51,18 +50,21 @@ class SndfileWriter
|
||||
check_flags (*this, c);
|
||||
|
||||
if (throw_level (ThrowStrict) && c.channels() != channels()) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("Wrong number of channels given to process(), %1% instead of %2%")
|
||||
% c.channels() % channels()));
|
||||
throw Exception (*this, string_compose
|
||||
("Wrong number of channels given to process(), %1 instead of %2",
|
||||
c.channels(), channels()));
|
||||
}
|
||||
|
||||
samplecnt_t const written = write (c.data(), c.samples());
|
||||
samples_written += written;
|
||||
|
||||
if (throw_level (ThrowProcess) && written != c.samples()) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("Could not write data to output file (%1%)")
|
||||
% strError()));
|
||||
std::stringstream reason;
|
||||
reason << "Could not write data to output file ("
|
||||
<< strError()
|
||||
<< ")";
|
||||
|
||||
throw Exception (*this, reason.str());
|
||||
}
|
||||
|
||||
if (c.has_flag(ProcessContext<T>::EndOfInput)) {
|
||||
@ -85,8 +87,12 @@ class SndfileWriter
|
||||
virtual void init()
|
||||
{
|
||||
if (SF_ERR_NO_ERROR != SndfileHandle::error ()) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("Could not create output file (%1%)") % path));
|
||||
std::stringstream reason;
|
||||
reason << "Could not write data to output file ("
|
||||
<< path
|
||||
<< ")";
|
||||
|
||||
throw Exception (*this, reason.str());
|
||||
}
|
||||
samples_written = 0;
|
||||
add_supported_flag (ProcessContext<T>::EndOfInput);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "pbd/compose.h"
|
||||
#include "pbd/gstdio_compat.h"
|
||||
#include "pbd/pthread_utils.h"
|
||||
#include "pbd/ringbuffer.h"
|
||||
@ -63,15 +64,16 @@ class TmpFileRt
|
||||
SndfileWriter<T>::check_flags (*this, c);
|
||||
|
||||
if (SndfileWriter<T>::throw_level (ThrowStrict) && c.channels() != SndfileHandle::channels()) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("Wrong number of channels given to process(), %1% instead of %2%")
|
||||
% c.channels() % SndfileHandle::channels()));
|
||||
throw Exception (*this, string_compose
|
||||
("Wrong number of channels given to process(), %1 instead of %2",
|
||||
c.channels(), SndfileHandle::channels()));
|
||||
}
|
||||
|
||||
if (SndfileWriter<T>::throw_level (ThrowProcess) && _rb.write_space() < (size_t) c.samples()) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("Could not write data to ringbuffer/output file (%1%)")
|
||||
% SndfileHandle::strError()));
|
||||
throw Exception (*this, string_compose
|
||||
("Could not write data to ringbuffer/output file (%1)",
|
||||
SndfileHandle::strError()));
|
||||
|
||||
}
|
||||
|
||||
_rb.write (c.data(), c.samples());
|
||||
|
@ -16,6 +16,8 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "audiographer/general/demo_noise.h"
|
||||
#include "ardour/dB.h"
|
||||
|
||||
@ -67,10 +69,14 @@ DemoNoiseAdder::process (ProcessContext<float> const& ctx)
|
||||
const samplecnt_t n_samples = ctx.samples_per_channel ();
|
||||
|
||||
if (throw_level (ThrowStrict) && ctx.channels () != _channels) {
|
||||
throw Exception (*this, boost::str (boost::format ("Wrong channel count given to process(), %1% instead of %2%") % ctx.channels () % _channels));
|
||||
throw Exception (*this, string_compose
|
||||
("Wrong channel count given to process(), %1 instead of %2",
|
||||
ctx.channels () % _channels));
|
||||
}
|
||||
if (throw_level (ThrowProcess) && ctx.samples () > _data_out_size) {
|
||||
throw Exception (*this, boost::str (boost::format ("Too many samples given to process(), %1% instead of %2%") % ctx.samples () % _data_out_size));
|
||||
throw Exception (*this, string_compose
|
||||
("Too many samples given to process(), %1 instead of %2",
|
||||
ctx.samples (), _data_out_size));
|
||||
}
|
||||
|
||||
if (_pos + n_samples > _duration) {
|
||||
|
@ -17,6 +17,8 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "audiographer/general/loudness_reader.h"
|
||||
#include "pbd/fastlog.h"
|
||||
|
||||
|
@ -19,14 +19,14 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "pbd/compose.h"
|
||||
|
||||
#include "audiographer/general/sample_format_converter.h"
|
||||
|
||||
#include "audiographer/exception.h"
|
||||
#include "audiographer/type_utils.h"
|
||||
#include "private/gdither/gdither.h"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
namespace AudioGrapher
|
||||
{
|
||||
|
||||
@ -72,9 +72,9 @@ void
|
||||
SampleFormatConverter<int16_t>::init (samplecnt_t max_samples, int type, int data_width)
|
||||
{
|
||||
if (throw_level (ThrowObject) && data_width > 16) {
|
||||
throw Exception (*this, boost::str(boost::format
|
||||
("Data width (%1%) too large for int16_t")
|
||||
% data_width));
|
||||
throw Exception (*this, string_compose
|
||||
("Data width (%1) too large for int16_t",
|
||||
data_width));
|
||||
}
|
||||
init_common (max_samples);
|
||||
dither = gdither_new ((GDitherType) type, channels, GDither16bit, data_width);
|
||||
@ -85,9 +85,9 @@ void
|
||||
SampleFormatConverter<uint8_t>::init (samplecnt_t max_samples, int type, int data_width)
|
||||
{
|
||||
if (throw_level (ThrowObject) && data_width > 8) {
|
||||
throw Exception (*this, boost::str(boost::format
|
||||
("Data width (%1%) too large for uint8_t")
|
||||
% data_width));
|
||||
throw Exception (*this, string_compose
|
||||
("Data width (%1) too large for uint8_t",
|
||||
data_width));
|
||||
}
|
||||
init_common (max_samples);
|
||||
dither = gdither_new ((GDitherType) type, channels, GDither8bit, data_width);
|
||||
@ -197,15 +197,15 @@ void
|
||||
SampleFormatConverter<TOut>::check_sample_and_channel_count (samplecnt_t samples, ChannelCount channels_)
|
||||
{
|
||||
if (throw_level (ThrowStrict) && channels_ != channels) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("Wrong channel count given to process(), %1% instead of %2%")
|
||||
% channels_ % channels));
|
||||
throw Exception (*this, string_compose
|
||||
("Wrong channel count given to process(), %1 instead of %2",
|
||||
channels_, channels));
|
||||
}
|
||||
|
||||
if (throw_level (ThrowProcess) && samples > data_out_size) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("Too many samples given to process(), %1% instead of %2%")
|
||||
% samples % data_out_size));
|
||||
throw Exception (*this, string_compose
|
||||
("Too many samples given to process(), %1 instead of %2",
|
||||
samples, data_out_size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,18 +18,17 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "pbd/compose.h"
|
||||
|
||||
#include "audiographer/general/sr_converter.h"
|
||||
|
||||
#include "audiographer/exception.h"
|
||||
#include "audiographer/type_utils.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
namespace AudioGrapher
|
||||
{
|
||||
using boost::format;
|
||||
using boost::str;
|
||||
|
||||
SampleRateConverter::SampleRateConverter (uint32_t channels)
|
||||
: active (false)
|
||||
@ -59,9 +58,9 @@ SampleRateConverter::init (samplecnt_t in_rate, samplecnt_t out_rate, int qualit
|
||||
int err;
|
||||
src_state = src_new (quality, channels, &err);
|
||||
if (throw_level (ThrowObject) && !src_state) {
|
||||
throw Exception (*this, str (format
|
||||
("Cannot initialize sample rate converter: %1%")
|
||||
% src_strerror (err)));
|
||||
throw Exception (*this, string_compose
|
||||
("Cannot initialize sample rate converter: %1",
|
||||
src_strerror (err)));
|
||||
}
|
||||
|
||||
src_data.src_ratio = (double) out_rate / (double) in_rate;
|
||||
@ -113,9 +112,9 @@ SampleRateConverter::process (ProcessContext<float> const & c)
|
||||
float * in = const_cast<float *> (c.data()); // TODO check if this is safe!
|
||||
|
||||
if (throw_level (ThrowProcess) && samples > max_samples_in) {
|
||||
throw Exception (*this, str (format (
|
||||
"process() called with too many samples, %1% instead of %2%")
|
||||
% samples % max_samples_in));
|
||||
throw Exception (*this, string_compose
|
||||
("process() called with too many samples, %1 instead of %2",
|
||||
samples, max_samples_in));
|
||||
}
|
||||
|
||||
int err;
|
||||
@ -163,9 +162,7 @@ SampleRateConverter::process (ProcessContext<float> const & c)
|
||||
|
||||
err = src_process (src_state, &src_data);
|
||||
if (throw_level (ThrowProcess) && err) {
|
||||
throw Exception (*this, str (format
|
||||
("An error occurred during sample rate conversion: %1%")
|
||||
% src_strerror (err)));
|
||||
throw Exception (*this, string_compose ("An error occurred during sample rate conversion: %1",src_strerror (err)));
|
||||
}
|
||||
|
||||
leftover_samples = src_data.input_frames - src_data.input_frames_used;
|
||||
@ -191,9 +188,9 @@ SampleRateConverter::process (ProcessContext<float> const & c)
|
||||
}
|
||||
|
||||
if (throw_level (ThrowProcess) && src_data.output_frames_gen == 0 && leftover_samples) {
|
||||
throw Exception (*this, boost::str (boost::format
|
||||
("No output samples generated with %1% leftover samples")
|
||||
% leftover_samples));
|
||||
throw Exception (*this, string_compose
|
||||
("No output samples generated with %1 leftover samples",
|
||||
leftover_samples));
|
||||
}
|
||||
|
||||
} while (leftover_samples > samples);
|
||||
|
@ -27,9 +27,6 @@ def configure(conf):
|
||||
autowaf.check_pkg(conf, 'sndfile', uselib_store='SNDFILE', atleast_version='1.0.18', mandatory=False)
|
||||
autowaf.check_pkg(conf, 'fftw3f', uselib_store='FFTW3F', mandatory=True)
|
||||
|
||||
# Boost headers
|
||||
autowaf.check_header(conf, 'cxx', 'boost/format.hpp')
|
||||
|
||||
def build(bld):
|
||||
|
||||
# Headers
|
||||
|
Loading…
Reference in New Issue
Block a user