00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 #include <ximol/io.hpp>
00072 #include <ximol/stream.hpp>
00073 #include <ximol/str_cast.hpp>
00074 #include <algorithm>
00075 #include <functional>
00076 #include <locale>
00077
00078 XIMOL_BEGIN_PRIVATE_NAMESPACE
00079
00080 wchar_t to_wide_char(char c)
00081 {
00082 XIMOL_USING_NAMESPACE;
00083 return converter<wchar_t,char>::get(c);
00084 };
00085
00086 char to_narrow_char(wchar_t xc)
00087 {
00088 XIMOL_USING_NAMESPACE;
00089 return converter<char,wchar_t>::get(xc);
00090 };
00091
00092 wchar_t to_wide_char(char c, ::std::basic_ios<wchar_t>& ios)
00093 {
00094 using namespace std;
00095 typedef ctype<wchar_t> ctype_facet;
00096 const ctype_facet & the_facet = XIMOL_USE_FACET(ios.getloc(), ctype_facet);
00097 return the_facet.widen(c);
00098 };
00099
00100 char to_narrow_char(wchar_t xc, ::std::basic_ios<wchar_t>& ios)
00101 {
00102 using namespace std;
00103 typedef ctype<wchar_t> ctype_facet;
00104 const ctype_facet & the_facet = XIMOL_USE_FACET(ios.getloc(), ctype_facet);
00105 return the_facet.narrow(xc,' ');
00106 };
00107
00108 XIMOL_END_PRIVATE_NAMESPACE
00109
00110 namespace std {
00111 ostream& operator<<(ostream& ostream_, const wchar_t* pXChar_)
00112 {
00113 if(pXChar_) while(*pXChar_ != '\0') operator<<(ostream_, to_narrow_char(*pXChar_++));
00114 return ostream_;
00115 }
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 wostream& operator<<(wostream& wostream_, const char* pChar_)
00128 {
00129 if(pChar_) while (*pChar_ != '\0') operator<<(wostream_, to_wide_char(*pChar_++));
00130 return wostream_;
00131 }
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 };
00178
00179 XIMOL_BEGIN_NAMESPACE
00180
00181
00182
00183
00184 XIMOL_TEMPLATE_NULL
00185 xostream& operator<<(xostream& xos, const char c)
00186 {
00187
00188
00189 xos.rdbuf()->sputc((xchar_t)((unsigned char)c));
00190 return xos;
00191 }
00192
00193
00194
00195
00196 XIMOL_TEMPLATE_NULL
00197 xostream& operator<<(xostream& xos, const char * c)
00198 {
00199
00200
00201 while (*c != '\0') xos.rdbuf()->sputc((xchar_t)((unsigned char)*c++));
00202 return xos;
00203 }
00204
00205
00206
00207
00208 XIMOL_TEMPLATE_NULL
00209 xostream& operator<<(xostream& xostream_, const std::string& str_)
00210 {
00211 return xostream_ << str_.c_str();
00212 }
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236 XIMOL_TEMPLATE_NULL
00237 xostream& operator<<(xostream& xos, const xchar_t * c)
00238 {
00239 while (*c != '\0') xos.rdbuf()->sputc((xchar_t)(*c++));
00240 return xos;
00241 }
00242
00243
00244
00245
00246 XIMOL_TEMPLATE_NULL
00247 xostream& operator<<(xostream& xos, const xstring& c)
00248 {
00249 return xos<<c.c_str();
00250 }
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276 using namespace std;
00277
00278 xistream& operator>>(xistream& xis, bool & c){ (basic_istream<xchar_t>&)xis>>c; return xis;}
00279 xistream& operator>>(xistream& xis, short & c){ (basic_istream<xchar_t>&)xis>>c; return xis;}
00280 xistream& operator>>(xistream& xis, long & c){ (basic_istream<xchar_t>&)xis>>c; return xis;}
00281 xistream& operator>>(xistream& xis, unsigned long & c){ (basic_istream<xchar_t>&)xis>>c; return xis;}
00282 xistream& operator>>(xistream& xis, int & c){ (basic_istream<xchar_t>&)xis>>c; return xis;}
00283 xistream& operator>>(xistream& xis, unsigned int & c){ (basic_istream<xchar_t>&)xis>>c; return xis;}
00284 xistream& operator>>(xistream& xis, float & c){ (basic_istream<xchar_t>&)xis>>c; return xis;}
00285 xistream& operator>>(xistream& xis, double & c){ (basic_istream<xchar_t>&)xis>>c; return xis;}
00286 xistream& operator>>(xistream& xis, long double & c){ (basic_istream<xchar_t>&)xis>>c; return xis;}
00287 xistream& operator>>(xistream& xis, ::std::basic_istream<xchar_t>& (*fun)( ::std::basic_istream<xchar_t>&)){ fun(xis); return xis;}
00288
00289 xostream& operator<<(xostream& xos, bool c){ (basic_ostream<xchar_t>&)xos<<c; return xos;}
00290 xostream& operator<<(xostream& xos, short c){ (basic_ostream<xchar_t>&)xos<<c; return xos;}
00291 xostream& operator<<(xostream& xos, long c){ (basic_ostream<xchar_t>&)xos<<c; return xos;}
00292 xostream& operator<<(xostream& xos, unsigned long c){ (basic_ostream<xchar_t>&)xos<<c; return xos;}
00293 xostream& operator<<(xostream& xos, int c){ (basic_ostream<xchar_t>&)xos<<c; return xos;}
00294 xostream& operator<<(xostream& xos, unsigned int c){ (basic_ostream<xchar_t>&)xos<<c; return xos;}
00295 xostream& operator<<(xostream& xos, float c){ (basic_ostream<xchar_t>&)xos<<c; return xos;}
00296 xostream& operator<<(xostream& xos, double c){ (basic_ostream<xchar_t>&)xos<<c; return xos;}
00297 xostream& operator<<(xostream& xos, long double c){ (basic_ostream<xchar_t>&)xos<<c; return xos;}
00298 xostream& operator<<(xostream& xos, ::std::basic_ostream<xchar_t>& (*fun)( ::std::basic_ostream<xchar_t>&)){ fun(xos); return xos;}
00299
00300 XIMOL_END_NAMESPACE