>
> I've tweaked it to try to detect overflow errors, and re-ran
> the tests with the 4 databases.
>
> Also I tweaked it to use std::iostream::peek() in order to
> try to avoid reading eof().
>
> I wasn't sure if we should throw std::overflow_error
> when reading Decimals from an std::istream, instead
> I just set the fail bit.
>
Setting fail bit in istream is the right thing to do. But 
tntdb::Decimal::getInteger<IntegerType>() should throw an 
overflow_error.

But I would like to strip down the class a little. Do a database library 
really need input and output operators for iostream for the Decimal-type? 
tntdb::Date, tntdb::Time and tntdb::DateTime are just very simple data 
holder. I would prefer that for tntdb::Decimal too.

It is not that easy to do that iostream-stuff right. What about decimal point? 
In germany we use a decimal comma. You don't use the locale correctly. Why do 
I need print flags in the decimal class? Tntdb does not need that. It is 
useless.

tntdb::Decimal::getBool does not make any sense. A decimal has nothing to do 
with bool. Why should a decimal has some special value, which is interpreted 
as false? You may do something like:

        tntdb::Decimal d = ...;
        if (d == tntdb::Decimal(0, 0))
        {
                // d is zero
        }

This is more readable than:

        tntdb::Decimal d = ...;
        if (d.getBool())
        {
        }

I still like your idea with getInteger and getFloatingPoint as templates, but 
let us remove these iostream-stuff from tntdb.

There may be something like tntdbx::Decimal, which adds all that nifty things. 
You may then write:

        tntdb::Value v = ...;
        std::cout << tntdbx::Decimal(v.getDecimal()) << std::endl;

The tntdb::Decimal will be very lightweight then.

Tommi

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to