Boost logo

Boost Users :

From: Richard Lyon (rlyon_at_[hidden])
Date: 2003-10-21 03:38:59


Hi,

Many applications are required to parse a string/file and extract numeric
values. You can use sscanf or alternatively use regexp with numeric casting
templates. I suprised that boost doesn't seem to contain conversion templates
like:

template < typename t_target > t_target decimal_cast( const std::string&
arg ){ ... };

template < typename t_target > t_target octal_cast( const std::string&
arg ){ ... };

template < typename t_target > t_target hex_cast( const std::string&
arg ){ ... };

When you use these type of casts with regexp, you can construct simple
robust parsers for reading numeric data from files, etc ..., in just a few
lines of code.

The lexical_cast and numeric_cast don't seem to cover these conversions.

This is much better approach than using parsing framework like spirit/antlr.
Shouldn't boost have this capability.

Regards


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net