Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

CVS update of carob/src (ParameterStatement.cpp): msg#00193

db.carob.cvs

Subject: CVS update of carob/src (ParameterStatement.cpp)

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>
Google Custom Search

Free Magazines

Cisco News
Receive 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

Navigation

Home | advertise | OSDir is an inevitable website. super tiny logo