stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r570219 - in /incubator/stdcxx/trunk/doc/stdlibref: money-put.html num-get.html time-get.html
Date Mon, 27 Aug 2007 18:57:34 GMT
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 <Farid_Zaripov@epam.com>

	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&lt;char,
-        std::char_traits&lt;char&gt; &gt; Iter;
+    typedef std::ostreambuf_iterator&lt;char, std::char_traits&lt;char&gt; &gt;
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&lt;char, Iter&gt; &amp;mp =
-        std::use_facet&lt;std::money_put&lt;char, Iter&gt; &gt;(std::locale
-        ());
+    const std::money_put&lt;char, Iter&gt; &amp;mp = 
+        std::use_facet&lt;std::money_put&lt;char, Iter&gt; &gt;(loc);
 
     // Put out the string representation of the monetary value
     std::cout &lt;&lt; buffer &lt;&lt; " --&gt; ";

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&lt;char, Iter&gt; &amp;ng =
-        std::use_facet&lt;std::num_get&lt;char, Iter&gt; &gt;(std::locale
());
+        std::use_facet&lt;std::num_get&lt;char, Iter&gt; &gt;(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 &lt;sstream&gt;    // for stringstream
 #include &lt;iostream&gt;   // for cout, endl
 
-// Print out a tm struct
-std::ostream&amp; operator&lt;&lt; (std::ostream &amp;os, const struct tm
&amp;t)
+
+// Print out a tm struct value in one atomic operation
+std::ostream&amp; operator&lt;&lt; (std::ostream &amp;os, const std::tm &amp;t)
 {
-    return os &lt;&lt; "Daylight Savings = " &lt;&lt; t.tm_isdst
-              &lt;&lt; "\nDay of year      = " &lt;&lt; t.tm_yday
-              &lt;&lt; "\nDay of week      = " &lt;&lt; t.tm_wday
-              &lt;&lt; "\nYear             = " &lt;&lt; t.tm_year
-              &lt;&lt; "\nMonth            = " &lt;&lt; t.tm_mon
-              &lt;&lt; "\nDay of month     = " &lt;&lt; t.tm_mday
-              &lt;&lt; "\nHour             = " &lt;&lt; t.tm_hour
-              &lt;&lt; "\nMinute           = " &lt;&lt; t.tm_min
-              &lt;&lt; "\nSecond           = " &lt;&lt; t.tm_sec
-              &lt;&lt; std::endl;
+    std::stringstream strm;
+
+    strm &lt;&lt; "Daylight Savings = "   &lt;&lt; t.tm_isdst
+         &lt;&lt; "\nDay of year      = " &lt;&lt; t.tm_yday
+         &lt;&lt; "\nDay of week      = " &lt;&lt; t.tm_wday
+         &lt;&lt; "\nYear             = " &lt;&lt; t.tm_year
+         &lt;&lt; "\nMonth            = " &lt;&lt; t.tm_mon
+         &lt;&lt; "\nDay of month     = " &lt;&lt; t.tm_mday
+         &lt;&lt; "\nHour             = " &lt;&lt; t.tm_hour
+         &lt;&lt; "\nMinute           = " &lt;&lt; t.tm_min
+         &lt;&lt; "\nSecond           = " &lt;&lt; t.tm_sec
+         &lt;&lt; '\n';
+
+    // guard for thread safety and output synchronization
+    const std::ostream::sentry guard (os);
+
+    if (guard)
+        os.rdbuf ()-&gt;sputn (strm.str ().c_str (), strm.str ().size ());
+    else
+        os.setstate (os.failbit);
+
+    return os;
 }
 
 
 int main ()
 {
-    typedef std::istreambuf_iterator&lt;char,
-            std::char_traits&lt;char&gt; &gt; Iter;
+    typedef std::istreambuf_iterator&lt;char, std::char_traits&lt;char&gt; &gt;
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&lt;char, Iter&gt; &amp;tg =
-        std::use_facet&lt;std::time_get&lt;char, Iter&gt; &gt;(std::locale
-                 ("C"));
+        std::use_facet&lt;std::time_get&lt;char, Iter&gt; &gt;(loc);
 
     // Display time_base::dateorder value.
-    std::cout &lt;&lt; "time_base::dateorder == " &lt;&lt; tg.date_order
()
-                 &lt;&lt; ".\n";
+    std::cout &lt;&lt; "time_base::dateorder == " &lt;&lt; tg.date_order
() &lt;&lt; ".\n";
   
     // Insert date string into stream.
     ins.str ("04/07/69");



Mime
View raw message