[uClibc-cvs] CVS uClibc++/include

CVS User gkajmowi gkajmowi at codepoet.org
Tue Jan 25 04:32:41 UTC 2005


Update of /var/cvs/uClibc++/include
In directory nail:/tmp/cvs-serv14607

Modified Files:
	ostream ostream_helpers 
Log Message:
More work on wchar support

--- /var/cvs/uClibc++/include/ostream	2005/01/23 18:58:14	1.8
+++ /var/cvs/uClibc++/include/ostream	2005/01/25 04:32:40	1.9
@@ -30,7 +30,10 @@
 namespace std {
 	template <class charT, class traits > class basic_ostream;
 	typedef basic_ostream<char> ostream;
+
+#ifdef __UCLIBCXX_HAS_WCHAR__
 	typedef basic_ostream<wchar_t> wostream;
+#endif
 
 	template <class charT, class traits> basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
 	template <class charT, class traits> basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
@@ -327,6 +330,8 @@
 		return out;
 	}
 
+
+#ifdef __UCLIBCXX_HAS_WCHAR__
 	template<class traits> basic_ostream<wchar_t,traits>& operator<<(basic_ostream<wchar_t,traits>& out, const char* c){
 		typename basic_ostream<wchar_t, traits>::sentry s(out);
 		size_t numChars = char_traits<char>::length(c);
@@ -339,6 +344,7 @@
 		out.write(temp, numChars);
 		return out;
 	}
+#endif
     
     //  signed and unsigned
 	template<class traits> basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const signed char* c){
--- /var/cvs/uClibc++/include/ostream_helpers	2005/01/03 16:28:46	1.5
+++ /var/cvs/uClibc++/include/ostream_helpers	2005/01/25 04:32:40	1.6
@@ -17,6 +17,7 @@
 	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#include <basic_definitions>
 #include <ios>
 #include <cctype>
 #include <string>
@@ -234,6 +235,198 @@
 		}
 	};
 
+#ifdef __UCLIBCXX_HAS_WCHAR__
+	template <class traits> class __ostream_printout<traits, wchar_t, signed long int>{
+	public:
+		static void printout(basic_ostream<wchar_t, traits >& stream, const signed long int n)
+		{
+			wchar_t buffer[20];
+			if( stream.flags() & ios_base::dec){
+				stream.write(buffer, swprintf(buffer, 20, L"%ld", n));
+			}else if( stream.flags() & ios_base::oct){
+				if( stream.flags() & ios_base::showbase){
+					stream.write(buffer, swprintf(buffer, 20, L"%#lo", n));
+				}else{
+					stream.write(buffer, swprintf(buffer, 20, L"%lo", n) );
+				}
+			}else if (stream.flags() & ios_base::hex){
+				if(stream.flags() & ios_base::showbase){
+					if(stream.flags() & ios_base::uppercase){
+						stream.write(buffer, swprintf(buffer, 20, L"%#lX", n) );
+					}else{
+						stream.write(buffer, swprintf(buffer, 20, L"%#lx", n) );
+					}
+				}else{
+					if(stream.flags() & ios_base::uppercase){
+						stream.write(buffer, swprintf(buffer, 20, L"%lX", n) );
+					}else{
+						stream.write(buffer, swprintf(buffer, 20, L"%lx", n) );
+					}
+				}
+			}
+			if(stream.flags() & ios_base::unitbuf){
+				stream.flush();
+			}
+		}
+	};
+
+	template <class traits> class __ostream_printout<traits, wchar_t, unsigned long int>{
+	public:
+		static void printout(basic_ostream<wchar_t, traits >& stream, const unsigned long int n)
+		{
+			wchar_t buffer[20];
+			if( stream.flags() & ios_base::dec){
+				stream.write(buffer, swprintf(buffer, 20, L"%lu", n));
+			}else if( stream.flags() & ios_base::oct){
+				if( stream.flags() & ios_base::showbase){
+					stream.write(buffer, swprintf(buffer, 20, L"%#lo", n));
+				}else{
+					stream.write(buffer, swprintf(buffer, 20, L"%lo", n) );
+				}
+			}else if (stream.flags() & ios_base::hex){
+				if(stream.flags() & ios_base::showbase){
+					if(stream.flags() & ios_base::uppercase){
+						stream.write(buffer, swprintf(buffer, 20, L"%#lX", n) );
+					}else{
+						stream.write(buffer, swprintf(buffer, 20, L"%#lx", n) );
+					}
+				}else{
+					if(stream.flags() & ios_base::uppercase){
+						stream.write(buffer, swprintf(buffer, 20, L"%lX", n) );
+					}else{
+						stream.write(buffer, swprintf(buffer, 20, L"%lx", n) );
+					}
+				}
+			}
+			if(stream.flags() & ios_base::unitbuf){
+				stream.flush();
+			}
+		}
+	};
+
+#ifndef __STRICT_ANSI__
+
+	template <class traits> class __ostream_printout<traits, wchar_t, signed long long int>{
+	public:
+		static void printout(basic_ostream<wchar_t, traits >& stream, const signed long long int n)
+		{
+			wchar_t buffer[28];
+			if( stream.flags() & ios_base::dec){
+				stream.write(buffer, swprintf(buffer, 27, L"%lld", n));
+			}else if( stream.flags() & ios_base::oct){
+				if( stream.flags() & ios_base::showbase){
+					stream.write(buffer, swprintf(buffer, 27, L"%#llo", n));
+				}else{
+					stream.write(buffer, swprintf(buffer, 27, L"%llo", n) );
+				}
+			}else if (stream.flags() & ios_base::hex){
+				if(stream.flags() & ios_base::showbase){
+					if(stream.flags() & ios_base::uppercase){
+						stream.write(buffer, swprintf(buffer, 27, L"%#llX", n) );
+					}else{
+						stream.write(buffer, swprintf(buffer, 27, L"%#llx", n) );
+					}
+				}else{
+					if(stream.flags() & ios_base::uppercase){
+						stream.write(buffer, swprintf(buffer, 27, L"%llX", n) );
+					}else{
+						stream.write(buffer, swprintf(buffer, 27, L"%llx", n) );
+					}
+				}
+			}
+			if(stream.flags() & ios_base::unitbuf){
+				stream.flush();
+			}
+		}
+	};
+
+	template <class traits> class __ostream_printout<traits, wchar_t, unsigned long long int>{
+	public:
+		static void printout(basic_ostream<wchar_t, traits >& stream, const unsigned long long int n)
+		{
+			wchar_t buffer[28];
+			if( stream.flags() & ios_base::dec){
+				stream.write(buffer, swprintf(buffer, 27, L"%llu", n));
+			}else if( stream.flags() & ios_base::oct){
+				if( stream.flags() & ios_base::showbase){
+					stream.write(buffer, swprintf(buffer, 27, L"%#llo", n));
+				}else{
+					stream.write(buffer, swprintf(buffer, 27, L"%llo", n) );
+				}
+			}else if (stream.flags() & ios_base::hex){
+				if(stream.flags() & ios_base::showbase){
+					if(stream.flags() & ios_base::uppercase){
+						stream.write(buffer, swprintf(buffer, 27, L"%#llX", n) );
+					}else{
+						stream.write(buffer, swprintf(buffer, 27, L"%#llx", n) );
+					}
+				}else{
+					if(stream.flags() & ios_base::uppercase){
+						stream.write(buffer, swprintf(buffer, 27, L"%llX", n) );
+					}else{
+						stream.write(buffer, swprintf(buffer, 27, L"%llx", n) );
+					}
+				}
+			}
+			if(stream.flags() & ios_base::unitbuf){
+				stream.flush();
+			}
+		}
+	};
+
+
+#endif	//__STRICT_ANSI__
+
+	template <class traits> class __ostream_printout<traits, wchar_t, double>{
+	public:
+		static void printout(basic_ostream<wchar_t, traits >& stream, const double f)
+		{
+			wchar_t buffer[32];
+			wchar_t format_string[20];
+			if(stream.flags() & ios_base::scientific){
+				if(stream.flags() & ios_base::uppercase){
+					swprintf(format_string, 20, L"%%%ue", static_cast<unsigned int>(stream.width()));
+				}else{
+					swprintf(format_string, 20, L"%%%ue", static_cast<unsigned int>(stream.width()));
+				}
+			} else if(stream.flags() & ios_base::fixed){
+				swprintf(format_string, 20, L"%%%uf", static_cast<unsigned int>(stream.width()));
+			} else {
+				swprintf(format_string, 20, L"%%%ug", static_cast<unsigned int>(stream.width()));
+			}
+			stream.write(buffer, swprintf(buffer, 32, format_string, f) );
+			if(stream.flags() & ios_base::unitbuf){
+				stream.flush();
+			}
+		}
+	};
+
+	template <class traits> class __ostream_printout<traits, wchar_t, long double>{
+	public:
+		static void printout(basic_ostream<wchar_t, traits >& stream, const long double f)
+		{
+			wchar_t buffer[32];
+			wchar_t format_string[20];
+			if(stream.flags() & ios_base::scientific){
+				if(stream.flags() & ios_base::uppercase){
+					swprintf(format_string, 20, L"%%%uLe", static_cast<unsigned int>(stream.width()));
+				}else{
+					swprintf(format_string, 20, L"%%%uLe", static_cast<unsigned int>(stream.width()));
+				}
+			} else if(stream.flags() & ios_base::fixed){
+				swprintf(format_string, 20, L"%%%uLf", static_cast<unsigned int>(stream.width()));
+			} else {
+				swprintf(format_string, 20, L"%%%uLg", static_cast<unsigned int>(stream.width()));
+			}
+			stream.write(buffer, swprintf(buffer, 32, format_string, f) );
+			if(stream.flags() & ios_base::unitbuf){
+				stream.flush();
+			}
+		}
+	};
+
+#endif //__UCLIBCXX_HAS_WCHAR__
+
 }
 
 



More information about the uClibc-cvs mailing list