Author: faridz
Date: Mon Aug 27 11:57:34 2007
New Revision: 570219
URL: http://svn.apache.org/viewvc?rev=570219&view=rev
Log:
2007-08-27 Farid Zaripov <[EMAIL PROTECTED]>
STDCXX-462
* money-put.html: Updated example code according to real example.
* num-get.html: Ditto.
* time-get.html: Ditto.
Modified:
incubator/stdcxx/trunk/doc/stdlibref/money-put.html
incubator/stdcxx/trunk/doc/stdlibref/num-get.html
incubator/stdcxx/trunk/doc/stdlibref/time-get.html
Modified: incubator/stdcxx/trunk/doc/stdlibref/money-put.html
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/doc/stdlibref/money-put.html?rev=570219&r1=570218&r2=570219&view=diff
==============================================================================
--- incubator/stdcxx/trunk/doc/stdlibref/money-put.html (original)
+++ incubator/stdcxx/trunk/doc/stdlibref/money-put.html Mon Aug 27 11:57:34 2007
@@ -166,8 +166,7 @@
int main ()
{
- typedef std::ostreambuf_iterator<char,
- std::char_traits<char> > Iter;
+ typedef std::ostreambuf_iterator<char, std::char_traits<char>
> Iter;
const std::string buffer ("10002");
const long double ldval = 10002;
@@ -175,10 +174,11 @@
// Construct a ostreambuf_iterator on cout
Iter begin (std::cout);
+ const std::locale loc;
+
// Get a money put facet
- const std::money_put<char, Iter> &mp =
- std::use_facet<std::money_put<char, Iter> >(std::locale
- ());
+ const std::money_put<char, Iter> &mp =
+ std::use_facet<std::money_put<char, Iter> >(loc);
// Put out the string representation of the monetary value
std::cout << buffer << " --> ";
Modified: incubator/stdcxx/trunk/doc/stdlibref/num-get.html
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/doc/stdlibref/num-get.html?rev=570219&r1=570218&r2=570219&view=diff
==============================================================================
--- incubator/stdcxx/trunk/doc/stdlibref/num-get.html (original)
+++ incubator/stdcxx/trunk/doc/stdlibref/num-get.html Mon Aug 27 11:57:34 2007
@@ -243,9 +243,11 @@
long lval = 0L;
long double ldval = 0.0;
+ const std::locale loc;
+
// Get a num_get facet
const std::num_get<char, Iter> &ng =
- std::use_facet<std::num_get<char, Iter> >(std::locale ());
+ std::use_facet<std::num_get<char, Iter> >(loc);
#ifndef _RWSTD_NO_BOOL
{
Modified: incubator/stdcxx/trunk/doc/stdlibref/time-get.html
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/doc/stdlibref/time-get.html?rev=570219&r1=570218&r2=570219&view=diff
==============================================================================
--- incubator/stdcxx/trunk/doc/stdlibref/time-get.html (original)
+++ incubator/stdcxx/trunk/doc/stdlibref/time-get.html Mon Aug 27 11:57:34 2007
@@ -572,29 +572,41 @@
#include <sstream> // for stringstream
#include <iostream> // for cout, endl
-// Print out a tm struct
-std::ostream& operator<< (std::ostream &os, const struct tm
&t)
+
+// Print out a tm struct value in one atomic operation
+std::ostream& operator<< (std::ostream &os, const std::tm &t)
{
- return os << "Daylight Savings = " << t.tm_isdst
- << "\nDay of year = " << t.tm_yday
- << "\nDay of week = " << t.tm_wday
- << "\nYear = " << t.tm_year
- << "\nMonth = " << t.tm_mon
- << "\nDay of month = " << t.tm_mday
- << "\nHour = " << t.tm_hour
- << "\nMinute = " << t.tm_min
- << "\nSecond = " << t.tm_sec
- << std::endl;
+ std::stringstream strm;
+
+ strm << "Daylight Savings = " << t.tm_isdst
+ << "\nDay of year = " << t.tm_yday
+ << "\nDay of week = " << t.tm_wday
+ << "\nYear = " << t.tm_year
+ << "\nMonth = " << t.tm_mon
+ << "\nDay of month = " << t.tm_mday
+ << "\nHour = " << t.tm_hour
+ << "\nMinute = " << t.tm_min
+ << "\nSecond = " << t.tm_sec
+ << '\n';
+
+ // guard for thread safety and output synchronization
+ const std::ostream::sentry guard (os);
+
+ if (guard)
+ os.rdbuf ()->sputn (strm.str ().c_str (), strm.str ().size ());
+ else
+ os.setstate (os.failbit);
+
+ return os;
}
int main ()
{
- typedef std::istreambuf_iterator<char,
- std::char_traits<char> > Iter;
+ typedef std::istreambuf_iterator<char, std::char_traits<char>
> Iter;
// time struct to parse date into
- static struct tm timeb; // zero initialized
+ static std::tm timeb; // zero initialized
// Unused, required by time_get
std::ios_base::iostate state;
@@ -606,14 +618,14 @@
Iter begin (ins);
Iter end;
+ const std::locale loc ("C");
+
// Get a reference to the time_get facet in locale loc.
const std::time_get<char, Iter> &tg =
- std::use_facet<std::time_get<char, Iter> >(std::locale
- ("C"));
+ std::use_facet<std::time_get<char, Iter> >(loc);
// Display time_base::dateorder value.
- std::cout << "time_base::dateorder == " << tg.date_order ()
- << ".\n";
+ std::cout << "time_base::dateorder == " << tg.date_order ()
<< ".\n";
// Insert date string into stream.
ins.str ("04/07/69");