Added code to use boost::lexical_cast<>.

This commit is contained in:
John Wiegley 2007-05-03 06:10:32 +00:00
parent f0508a9f86
commit f9f24fab93
8 changed files with 22 additions and 21 deletions

20
configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for ledger 3.0-git. # Generated by GNU Autoconf 2.61 for ledger 3.0-git-lexical_cast.
# #
# Report bugs to <johnw@newartisans.com>. # Report bugs to <johnw@newartisans.com>.
# #
@ -728,8 +728,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package. # Identity of this package.
PACKAGE_NAME='ledger' PACKAGE_NAME='ledger'
PACKAGE_TARNAME='ledger' PACKAGE_TARNAME='ledger'
PACKAGE_VERSION='3.0-git' PACKAGE_VERSION='3.0-git-lexical_cast'
PACKAGE_STRING='ledger 3.0-git' PACKAGE_STRING='ledger 3.0-git-lexical_cast'
PACKAGE_BUGREPORT='johnw@newartisans.com' PACKAGE_BUGREPORT='johnw@newartisans.com'
ac_unique_file="ledger" ac_unique_file="ledger"
@ -1424,7 +1424,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures ledger 3.0-git to adapt to many kinds of systems. \`configure' configures ledger 3.0-git-lexical_cast to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1494,7 +1494,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of ledger 3.0-git:";; short | recursive ) echo "Configuration of ledger 3.0-git-lexical_cast:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1605,7 +1605,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
ledger configure 3.0-git ledger configure 3.0-git-lexical_cast
generated by GNU Autoconf 2.61 generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@ -1619,7 +1619,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by ledger $as_me 3.0-git, which was It was created by ledger $as_me 3.0-git-lexical_cast, which was
generated by GNU Autoconf 2.61. Invocation command line was generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@ $ $0 $@
@ -2310,7 +2310,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='ledger' PACKAGE='ledger'
VERSION='3.0-git' VERSION='3.0-git-lexical_cast'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -21967,7 +21967,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by ledger $as_me 3.0-git, which was This file was extended by ledger $as_me 3.0-git-lexical_cast, which was
generated by GNU Autoconf 2.61. Invocation command line was generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -22020,7 +22020,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\ ac_cs_version="\\
ledger config.status 3.0-git ledger config.status 3.0-git-lexical_cast
configured by $0, generated by GNU Autoconf 2.61, configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"

View file

@ -3,7 +3,7 @@
AC_PREREQ(2.59) AC_PREREQ(2.59)
AC_INIT(ledger, 3.0-git, johnw@newartisans.com) AC_INIT(ledger, 3.0-git-lexical_cast, johnw@newartisans.com)
AC_CONFIG_SRCDIR(ledger) AC_CONFIG_SRCDIR(ledger)
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE

View file

@ -408,7 +408,7 @@ int main(int argc, char * argv[], char * envp[])
#if defined(TRACING_ON) #if defined(TRACING_ON)
if (i + 1 < argc && std::strcmp(argv[i], "--trace") == 0) { if (i + 1 < argc && std::strcmp(argv[i], "--trace") == 0) {
ledger::_log_level = LOG_TRACE; ledger::_log_level = LOG_TRACE;
ledger::_trace_level = std::atoi(argv[i + 1]); ledger::_trace_level = lexical_cast<int>(argv[i + 1]);
i++; i++;
} }
#endif #endif

View file

@ -106,6 +106,7 @@ extern "C" {
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/operators.hpp> #include <boost/operators.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/ptr_container/ptr_list.hpp> #include <boost/ptr_container/ptr_list.hpp>

View file

@ -774,7 +774,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
case 'Y': // set current year case 'Y': // set current year
#if 0 #if 0
// jww (2007-04-18): Need to set this up again // jww (2007-04-18): Need to set this up again
date_t::current_year = std::atoi(skip_ws(line + 1)); date_t::current_year = lexical_cast<int>(skip_ws(line + 1));
#endif #endif
break; break;

View file

@ -1647,7 +1647,7 @@ void value_t::in_place_cast(type_t cast_type)
break; break;
} }
if (alldigits) { if (alldigits) {
long temp = std::atol((*(string **) data)->c_str()); long temp = lexical_cast<long>((*(string **) data)->c_str());
destroy(); destroy();
*(long *) data = temp; *(long *) data = temp;
} else { } else {

View file

@ -654,7 +654,7 @@ xpath_t::parse_value_term(std::istream& in, unsigned short tflags) const
int id = -1; int id = -1;
if (std::isdigit(ident[0])) { if (std::isdigit(ident[0])) {
node.reset(new op_t(op_t::ARG_INDEX)); node.reset(new op_t(op_t::ARG_INDEX));
node->arg_index = std::atol(ident.c_str()); node->arg_index = lexical_cast<unsigned int>(ident.c_str());
} }
else if ((id = document_t::lookup_builtin_id(ident)) != -1) { else if ((id = document_t::lookup_builtin_id(ident)) != -1) {
node.reset(new op_t(op_t::NODE_ID)); node.reset(new op_t(op_t::NODE_ID));

View file

@ -17,8 +17,8 @@ void BasicAmountTestCase::testConstructors()
amount_t x3(123.456); amount_t x3(123.456);
amount_t x5("123456"); amount_t x5("123456");
amount_t x6("123.456"); amount_t x6("123.456");
amount_t x7(std::string("123456")); amount_t x7(string("123456"));
amount_t x8(std::string("123.456")); amount_t x8(string("123.456"));
amount_t x9(x3); amount_t x9(x3);
amount_t x10(x6); amount_t x10(x6);
amount_t x11(x8); amount_t x11(x8);
@ -76,8 +76,8 @@ void BasicAmountTestCase::testAssignment()
x3 = 123.456; x3 = 123.456;
x5 = "123456"; x5 = "123456";
x6 = "123.456"; x6 = "123.456";
x7 = std::string("123456"); x7 = string("123456");
x8 = std::string("123.456"); x8 = string("123.456");
x9 = x3; x9 = x3;
x10 = amount_t(x6); x10 = amount_t(x6);
@ -415,8 +415,8 @@ void BasicAmountTestCase::testNegation()
amount_t x3(-123.456); amount_t x3(-123.456);
amount_t x5("-123456"); amount_t x5("-123456");
amount_t x6("-123.456"); amount_t x6("-123.456");
amount_t x7(std::string("-123456")); amount_t x7(string("-123456"));
amount_t x8(std::string("-123.456")); amount_t x8(string("-123.456"));
amount_t x9(- x3); amount_t x9(- x3);
assertEqual(amount_t(0L), x0); assertEqual(amount_t(0L), x0);