|
|
Choosing A Webhost: |
CVS update of carob/src (ParameterStatement.cpp): msg#00193db.carob.cvs
Date: Friday, January 27, 2006 @ 13:22:12 Author: marc Path: /cvsroot/carob/carob/src Modified: ParameterStatement.cpp (1.10 -> 1.11) Added floating-point FPoneShotFilter for float and double : now handling +-infinity() CAROB-31 ------------------------+ ParameterStatement.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 41 insertions(+), 1 deletion(-) Index: carob/src/ParameterStatement.cpp diff -u carob/src/ParameterStatement.cpp:1.10 carob/src/ParameterStatement.cpp:1.11 --- carob/src/ParameterStatement.cpp:1.10 Fri Jan 27 12:48:24 2006 +++ carob/src/ParameterStatement.cpp Fri Jan 27 13:22:12 2006 @@ -223,6 +223,44 @@ }; }; +template<class FP> +class FPoneShotFilter +{ + basic_ostream<wchar_t>& wrapped_stream; +public: + FPoneShotFilter(basic_ostream<wchar_t>& s) : wrapped_stream(s) { } ; + basic_ostream<wchar_t>& + // this is the actual filtering operator + operator<< (FP value) + { + // too bad Standard C and Java could not agree on the same string :-( + if (value == std::numeric_limits<FP>::infinity()) + wrapped_stream << L"Infinity"; // see java.lang.(Float|Double)#toString() + else if (value == -std::numeric_limits<FP>::infinity()) + wrapped_stream << L"-Infinity"; + // TODO: catch NaNs + else + wrapped_stream << value; + // then return the underlying stream (we filter only once!) + return wrapped_stream; + } +}; + +template<> +class oneShotFilter<double, wchar_t> : public FPoneShotFilter<double> +{ +public: + oneShotFilter(basic_ostream<wchar_t>& s) : FPoneShotFilter<double>(s) { } ; +}; + +template<> +class oneShotFilter<float, wchar_t> : public FPoneShotFilter<float> +{ +public: + oneShotFilter(basic_ostream<wchar_t>& s) : FPoneShotFilter<float>(s) { } ; +}; + + } // namespace CarobNS //// end of template filters //// @@ -236,7 +274,9 @@ throw DriverException(L"Parameter index out of range."); // As an optimization, we could make this stream a member. - // That would just require a member lock for thread-safety + // That would require + // - a member lock for thread-safety + // - carefully checking that streamSettings<T1>() does not step on streamSettings<T2>() toes std::wostringstream buffer;
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of carob/src (ParameterStatement.cpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of libmysequoia/src (CarobMySQL.cpp CarobStmt.cpp Utils.cpp), zsolt-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/src (ParameterStatement.cpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of carob/src (ParameterStatement.cpp), 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.
|