|
|
Choosing A Webhost: |
CVS update of carob/src (ParameterStatement.cpp): msg#00203db.carob.cvs
Date: Monday, January 30, 2006 @ 11:48:26 Author: marc Path: /cvsroot/carob/carob/src Modified: ParameterStatement.cpp (1.15 -> 1.16) templatized floating-point s.precision() instead of duplicating code ------------------------+ ParameterStatement.cpp | 51 +++++++++++++++++++++++------------------------ 1 files changed, 25 insertions(+), 26 deletions(-) Index: carob/src/ParameterStatement.cpp diff -u carob/src/ParameterStatement.cpp:1.15 carob/src/ParameterStatement.cpp:1.16 --- carob/src/ParameterStatement.cpp:1.15 Fri Jan 27 19:03:19 2006 +++ carob/src/ParameterStatement.cpp Mon Jan 30 11:48:26 2006 @@ -213,39 +213,30 @@ // See paragraph "Conversions" at: // http://www2.hursley.ibm.com/decimal/ for more details and proofs. -template<class Ch> void -streamSettingsForFloatingPoint(basic_ostream<Ch>& s) -{ - s.imbue(locC); - s.setf(std::ios_base::scientific, std::ios_base::floatfield); -} - -// template specialization for float -template<class Ch> -class streamSettings<float, Ch> +template<int precision, class Ch> +class FPSettings { public: void doManip(basic_ostream<Ch>& s) const { - streamSettingsForFloatingPoint(s); - s.precision(9); - }; + s.imbue(locC); + s.setf(std::ios_base::scientific, std::ios_base::floatfield); + s.precision(precision); + } }; -// template specialization for double +// settings specialization for double template<class Ch> -class streamSettings<double, Ch> -{ -public: - void doManip(basic_ostream<Ch>& s) const - { - streamSettingsForFloatingPoint(s); - s.precision(17); - }; -}; +class streamSettings<double, Ch> : public FPSettings<17, Ch> { }; + +// settings specialization for float +template<class Ch> +class streamSettings<float, Ch> : public FPSettings<9, Ch> { }; -template<class FP> + + +template<typename FP> class FPoneShotFilter { basic_ostream<wchar_t>& wrapped_stream; @@ -280,6 +271,7 @@ } }; +// filter specialization for double template<> class oneShotFilter<double, wchar_t> : public FPoneShotFilter<double> { @@ -287,6 +279,7 @@ oneShotFilter(basic_ostream<wchar_t>& s) : FPoneShotFilter<double>(s) { } ; }; +// filter specialization for float template<> class oneShotFilter<float, wchar_t> : public FPoneShotFilter<float> { @@ -345,8 +338,6 @@ // - carefully checking that streamSettings<T1>() does not step on streamSettings<T2>() toes std::wostringstream buffer; - - // TODO: catch inf & NaN buffer << START_PARAM_TAG << typeTag << streamSettings<T>() << value << END_PARAM_TAG; inStrings[paramIndex-1] = buffer.str(); @@ -439,3 +430,11 @@ { set<wstring>(parameterIndex, STRING_TAG, x); } + +/* + * Local Variables: + * c-file-style: "bsd" + * c-basic-offset: 2 + * indent-tabs-mode: nil + * End: + */
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of libmysequoia (autogen.sh configure.ac test/Makefile.am), csaba-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of libmysequoia (Makefile.am configure.ac), csaba-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/src (ParameterStatement.cpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of carob/test/40-Parameter-PreparedStatement (1 file), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|