util/NumberParser: utilities for parsing numbers from ASCII strings
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "EncoderAPI.hxx"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "ConfigError.hxx"
|
||||
#include "util/NumberParser.hxx"
|
||||
#include "util/ReusableArray.hxx"
|
||||
#include "util/Manual.hxx"
|
||||
#include "util/Error.hxx"
|
||||
@@ -29,8 +30,6 @@
|
||||
|
||||
#include <lame/lame.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -63,7 +62,7 @@ LameEncoder::Configure(const config_param ¶m, Error &error)
|
||||
if (value != nullptr) {
|
||||
/* a quality was configured (VBR) */
|
||||
|
||||
quality = g_ascii_strtod(value, &endptr);
|
||||
quality = ParseDouble(value, &endptr);
|
||||
|
||||
if (*endptr != '\0' || quality < -1.0 || quality > 10.0) {
|
||||
error.Format(config_domain,
|
||||
@@ -89,7 +88,7 @@ LameEncoder::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
quality = -2.0;
|
||||
bitrate = g_ascii_strtoll(value, &endptr, 10);
|
||||
bitrate = ParseInt(value, &endptr);
|
||||
|
||||
if (*endptr != '\0' || bitrate <= 0) {
|
||||
error.Set(config_domain,
|
||||
|
@@ -22,14 +22,13 @@
|
||||
#include "EncoderAPI.hxx"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "ConfigError.hxx"
|
||||
#include "util/NumberParser.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <twolame.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -69,7 +68,7 @@ TwolameEncoder::Configure(const config_param ¶m, Error &error)
|
||||
if (value != nullptr) {
|
||||
/* a quality was configured (VBR) */
|
||||
|
||||
quality = g_ascii_strtod(value, &endptr);
|
||||
quality = ParseDouble(value, &endptr);
|
||||
|
||||
if (*endptr != '\0' || quality < -1.0 || quality > 10.0) {
|
||||
error.Format(config_domain,
|
||||
@@ -95,7 +94,7 @@ TwolameEncoder::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
quality = -2.0;
|
||||
bitrate = g_ascii_strtoll(value, &endptr, 10);
|
||||
bitrate = ParseInt(value, &endptr);
|
||||
|
||||
if (*endptr != '\0' || bitrate <= 0) {
|
||||
error.Set(config_domain,
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "tag/Tag.hxx"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "ConfigError.hxx"
|
||||
#include "util/NumberParser.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
|
||||
@@ -67,7 +68,7 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder,
|
||||
/* a quality was configured (VBR) */
|
||||
|
||||
char *endptr;
|
||||
encoder->quality = g_ascii_strtod(value, &endptr);
|
||||
encoder->quality = ParseDouble(value, &endptr);
|
||||
|
||||
if (*endptr != '\0' || encoder->quality < -1.0 ||
|
||||
encoder->quality > 10.0) {
|
||||
@@ -96,7 +97,7 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder,
|
||||
encoder->quality = -2.0;
|
||||
|
||||
char *endptr;
|
||||
encoder->bitrate = g_ascii_strtoll(value, &endptr, 10);
|
||||
encoder->bitrate = ParseInt(value, &endptr);
|
||||
if (*endptr != '\0' || encoder->bitrate <= 0) {
|
||||
error.Set(config_domain,
|
||||
"bitrate should be a positive integer");
|
||||
|
Reference in New Issue
Block a user