- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/Programmation/Sources/Tensor2/Utils/include/frost_utils_str_conversion.h

Go to the documentation of this file.

    00001 // Warning : If you need to use this file, include frost_utils_types.h
    00002 /** \cond NOT_REMOVE_FROM_DOC
    00003 */
    00004 namespace Frost
    00005 {
    00006     s_str_t<uint>           UTF8ToUnicode(const s_str_t<string_element>& s);
    00007     std::basic_string<uint> UTF8ToUnicode(const std::string& s);
    00008     s_uint_t<uint>          UTF8ToUnicode(const s_int_t<string_element>& c);
    00009     uint                    UTF8ToUnicode(const string_element& c);
    00010
    00011     s_str_t<string_element> UnicodeToUTF8(const s_str_t<uint>& s);
    00012     std::string             UnicodeToUTF8(const std::basic_string<uint>& s);
    00013     s_int_t<string_element> UnicodeToUTF8(const s_uint_t<uint>& c);
    00014     string_element          UnicodeToUTF8(const uint& c);
    00015
    00016     s_uint_t<default_uint>  HexToUInt(const s_str_t<string_element>& s);
    00017
    00018     s_str_t<string_element>::string IntToString(const long& i);
    00019     s_str_t<string_element>::string UIntToString(const ulong& ui);
    00020
    00021     template <class T>
    00022     s_str_t<string_element>::string FloatToString(const T& f);
    00023
    00024     template<class T>
    00025     class StringConverter< T, s_str_t<T> >
    00026     {
    00027     public :
    00028
    00029         typedef std::basic_string<T> string;
    00030
    00031         /// Copy constructor.
    00032         /** \param s The string to copy
    00033         */
    00034         static string Convert(const s_str_t<T>& s)
    00035         {
    00036             return s.Get();
    00037         }
    00038
    00039         /// Creates "uiNbr" copies of the provided string.
    00040         /** \param s     The string to copy
    00041         *   \param uiNbr The number of times to copy the string
    00042         *   \note If uiNbr equals 0, creates an empty string.
    00043         */
    00044         static string Convert(const s_str_t<T>& s, const s_uint_t<default_uint>& uiNbr)
    00045         {
    00046             string sReturn;
    00047
    00048             if (uiNbr.IsValid())
    00049             {
    00050                 for (default_uint uiCounter = 0; uiCounter < uiNbr.Get(); ++uiCounter)
    00051                     sReturn += s.Get();
    00052             }
    00053
    00054             return sReturn;
    00055         }
    00056     };
    00057
    00058     template<class T>
    00059     class StringConverter< T, std::basic_string<T> >
    00060     {
    00061     public :
    00062
    00063         typedef std::basic_string<T> string;
    00064
    00065         /// Constructor.
    00066         /** \param s The string to copy
    00067         */
    00068         static string Convert(const string& s)
    00069         {
    00070             return s;
    00071         }
    00072
    00073         /// Creates "uiNbr" copies of the provided string.
    00074         /** \param s     The string to copy
    00075         *   \param uiNbr The number of times to copy the string
    00076         *   \note If uiNbr equals 0, creates an empty string.
    00077         */
    00078         static string Convert(const string& s, const s_uint_t<default_uint>& uiNbr)
    00079         {
    00080             string sReturn;
    00081
    00082             if (uiNbr.IsValid())
    00083             {
    00084                 for (default_uint uiCounter = 0; uiCounter < uiNbr.Get(); ++uiCounter)
    00085                     sReturn += s;
    00086             }
    00087
    00088             return sReturn;
    00089         }
    00090     };
    00091
    00092     template<class T>
    00093     class StringConverter< T, const T* >
    00094     {
    00095     public :
    00096
    00097         typedef std::basic_string<T> string;
    00098
    00099         /// Constructor.
    00100         /** \param s The character array to copy
    00101         */
    00102         static string Convert(const T* s)
    00103         {
    00104             return s;
    00105         }
    00106
    00107         /// Creates "uiNbr" copies of the provided string.
    00108         /** \param s     The string to copy
    00109         *   \param uiNbr The number of times to copy the string
    00110         *   \note If uiNbr equals 0, creates an empty string.
    00111         */
    00112         static string Convert(const T* s, const s_uint_t<default_uint>& uiNbr)
    00113         {
    00114             string sReturn;
    00115
    00116             if (uiNbr.IsValid())
    00117             {
    00118                 for (default_uint uiCounter = 0; uiCounter < uiNbr.Get(); ++uiCounter)
    00119                     sReturn += s;
    00120             }
    00121
    00122             return sReturn;
    00123         }
    00124     };
    00125
    00126     template<class T>
    00127     class StringConverter< T, T* >
    00128     {
    00129     public :
    00130
    00131         typedef std::basic_string<T> string;
    00132
    00133         /// Constructor.
    00134         /** \param s The character array to copy
    00135         */
    00136         static string Convert(T* s)
    00137         {
    00138             return s;
    00139         }
    00140
    00141         /// Creates "uiNbr" copies of the provided string.
    00142         /** \param s     The string to copy
    00143         *   \param uiNbr The number of times to copy the string
    00144         *   \note If uiNbr equals 0, creates an empty string.
    00145         */
    00146         static string Convert(T* s, const s_uint_t<default_uint>& uiNbr)
    00147         {
    00148             string sReturn;
    00149
    00150             if (uiNbr.IsValid())
    00151             {
    00152                 for (default_uint uiCounter = 0; uiCounter < uiNbr.Get(); ++uiCounter)
    00153                     sReturn += s;
    00154             }
    00155
    00156             return sReturn;
    00157         }
    00158     };
    00159
    00160     template<class T, default_uint N>
    00161     class StringConverter< T, T[N] >
    00162     {
    00163     public :
    00164
    00165         typedef std::basic_string<T> string;
    00166
    00167         /// Constructor.
    00168         /** \param s The character array to copy
    00169         */
    00170         static string Convert(const T* s)
    00171         {
    00172             return s;
    00173         }
    00174
    00175         /// Creates "uiNbr" copies of the provided string.
    00176         /** \param s     The string to copy
    00177         *   \param uiNbr The number of times to copy the string
    00178         *   \note If uiNbr equals 0, creates an empty string.
    00179         */
    00180         static string Convert(const T* s, const s_uint_t<default_uint>& uiNbr)
    00181         {
    00182             string sReturn;
    00183
    00184             if (uiNbr.IsValid())
    00185             {
    00186                 for (default_uint uiCounter = 0; uiCounter < uiNbr.Get(); ++uiCounter)
    00187                     sReturn += s;
    00188             }
    00189
    00190             return sReturn;
    00191         }
    00192     };
    00193
    00194     template<class T, default_uint N>
    00195     class StringConverter< T, const T[N] >
    00196     {
    00197     public :
    00198
    00199         typedef std::basic_string<T> string;
    00200
    00201         /// Constructor.
    00202         /** \param s The character array to copy
    00203         */
    00204         static string Convert(const T* s)
    00205         {
    00206             return s;
    00207         }
    00208
    00209         /// Creates "uiNbr" copies of the provided string.
    00210         /** \param s     The string to copy
    00211         *   \param uiNbr The number of times to copy the string
    00212         *   \note If uiNbr equals 0, creates an empty string.
    00213         */
    00214         static string Convert(const T* s, const s_uint_t<default_uint>& uiNbr)
    00215         {
    00216             string sReturn;
    00217
    00218             if (uiNbr.IsValid())
    00219             {
    00220                 for (default_uint uiCounter = 0; uiCounter < uiNbr.Get(); ++uiCounter)
    00221                     sReturn += s;
    00222             }
    00223
    00224             return sReturn;
    00225         }
    00226     };
    00227
    00228     template<class T>
    00229     class StringConverter<T, T>
    00230     {
    00231     public :
    00232
    00233         typedef std::basic_string<T> string;
    00234
    00235         /// Constructor.
    00236         /** \param c The character to copy
    00237         */
    00238         static string Convert(const T& c)
    00239         {
    00240             string s;
    00241             s.push_back(c);
    00242             return s;
    00243         }
    00244
    00245         /// Creates "uiNbr" copies of the provided character.
    00246         /** \param c     The character to copy
    00247         *   \param uiNbr The number of times to copy the character
    00248         *   \note If uiNbr equals 0, creates an empty string.
    00249         */
    00250         static string Convert(const T& c, const s_uint_t<default_uint>& uiNbr)
    00251         {
    00252             if (uiNbr.IsValid())
    00253                 return string(uiNbr.Get(), c);
    00254             else
    00255                 return string();
    00256         }
    00257
    00258         /// Constructor.
    00259         /** \param c The character to copy
    00260         */
    00261         static T ConvertChar(const T& c)
    00262         {
    00263             return c;
    00264         }
    00265     };
    00266
    00267     template<> class StringConverter<string_element, TypeTraits<string_element>::FrostType>
    00268     {
    00269     public :
    00270
    00271         typedef s_str_t<string_element>::string string;
    00272
    00273         /// Constructor.
    00274         /** \param c The character to copy
    00275         */
    00276         static string Convert(const TypeTraits<string_element>::FrostType& c)
    00277         {
    00278             string s;
    00279             s.push_back(c.Get());
    00280             return s;
    00281         }
    00282
    00283         /// Creates "uiNbr" copies of the provided character.
    00284         /** \param c     The character to copy
    00285         *   \param uiNbr The number of times to copy the character
    00286         *   \note If uiNbr equals 0, creates an empty string.
    00287         */
    00288         static string Convert(const TypeTraits<string_element>::FrostType& c, const s_uint_t<default_uint>& uiNbr)
    00289         {
    00290             if (uiNbr.IsValid())
    00291                 return string(uiNbr.Get(), c.Get());
    00292             else
    00293                 return string();
    00294         }
    00295
    00296         /// Constructor.
    00297         /** \param c The character to copy
    00298         */
    00299         static TypeTraits<string_element>::FrostType ConvertChar(const TypeTraits<string_element>::FrostType& c)
    00300         {
    00301             return c;
    00302         }
    00303     };
    00304
    00305     template<class N> class StringConverter< string_element, s_int_t<N> >
    00306     {
    00307     public :
    00308
    00309         typedef s_str_t<string_element>::string string;
    00310
    00311         /// Converts the provided integer.
    00312         /** \param i The integer to convert
    00313         */
    00314         static string Convert(const s_int_t<N>& i)
    00315         {
    00316             switch (i.GetType())
    00317             {
    00318                 case s_int_t<N>::INTEGER :
    00319                     return IntToString(i.Get());
    00320                 case s_int_t<N>::INTEGER_NAN :
    00321                     return "nan";
    00322                 case  s_int_t<N>::INTEGER_INF_PLUS :
    00323                     return "inf+";
    00324                 case s_int_t<N>::INTEGER_INF_MINUS :
    00325                     return "inf-";
    00326                 default : return "";
    00327             }
    00328         }
    00329
    00330         /// Converts and formats the provided integer.
    00331         /** \param i         The integer to convert
    00332         *   \param uiCharNbr The minimum number of character allowed (fills with zeros)
    00333         *   \note If the string representation of i is larger than uiCharNbr, it won't
    00334         *         be truncated.
    00335         */
    00336         static string Convert(const s_int_t<N>& i, const s_uint_t<default_uint>& uiCharNbr)
    00337         {
    00338             string sReturn;
    00339
    00340             if (i >= 0)
    00341             {
    00342                 sReturn = StringConverter< string_element, s_int_t<N> >::Convert(i);
    00343
    00344                 if (uiCharNbr.IsValid())
    00345                 {
    00346                     while (sReturn.length() < uiCharNbr.Get())
    00347                         sReturn = '0' + sReturn;
    00348                 }
    00349             }
    00350             else
    00351             {
    00352                 sReturn = StringConverter< string_element, s_int_t<N> >::Convert(-i);
    00353
    00354                 if (uiCharNbr.IsValid())
    00355                 {
    00356                     while (sReturn.length() < uiCharNbr.Get())
    00357                         sReturn = '0' + sReturn;
    00358                 }
    00359
    00360                 sReturn = '-' + sReturn;
    00361             }
    00362
    00363             return sReturn;
    00364         }
    00365     };
    00366
    00367     template<> class StringConverter< string_element, TypeTraits<uint>::FrostType >
    00368     {
    00369     public :
    00370
    00371         typedef s_str_t<string_element>::string string;
    00372
    00373         /// Converts the provided unsigned integer (as a number).
    00374         /** \param ui The unsigned integer to convert
    00375         */
    00376         static string Convert(const TypeTraits<uint>::FrostType& ui)
    00377         {
    00378             switch (ui.GetType())
    00379             {
    00380                 case TypeTraits<uint>::FrostType::INTEGER :
    00381                     return UIntToString(ui.Get());
    00382                 case TypeTraits<uint>::FrostType::INTEGER_NAN :
    00383                     return "nan";
    00384                 case TypeTraits<uint>::FrostType::INTEGER_INF :
    00385                     return "inf";
    00386                 default : return "";
    00387             }
    00388         }
    00389
    00390         /// Converts and formats the provided unsigned integer (as a number).
    00391         /** \param uiValue   The unsigned integer to convert
    00392         *   \param uiCharNbr The minimum number of character allowed (fills with zeros)
    00393         *   \note If the string representation of ui is larger than uiCharNbr, it won't
    00394         *         be truncated.
    00395         */
    00396         static string Convert(const TypeTraits<uint>::FrostType& ui, const s_uint_t<default_uint>& uiCharNbr)
    00397         {
    00398             string sReturn = StringConverter< string_element, TypeTraits<uint>::FrostType >::Convert(ui);
    00399
    00400             if (uiCharNbr.IsValid())
    00401             {
    00402                 while (sReturn.length() < uiCharNbr.Get())
    00403                     sReturn = '0' + sReturn;
    00404             }
    00405
    00406             return sReturn;
    00407         }
    00408
    00409         /// Constructor.
    00410         /** \param c The character to copy
    00411         */
    00412         static TypeTraits<string_element>::FrostType ConvertChar(const TypeTraits<uint>::FrostType& c)
    00413         {
    00414             return UnicodeToUTF8(c);
    00415         }
    00416     };
    00417
    00418     template<class N> class StringConverter< string_element, s_uint_t<N> >
    00419     {
    00420     public :
    00421
    00422         typedef s_str_t<string_element>::string string;
    00423
    00424         /// Converts the provided unsigned integer.
    00425         /** \param ui The unsigned integer to convert
    00426         */
    00427         static string Convert(const s_uint_t<N>& ui)
    00428         {
    00429             switch (ui.GetType())
    00430             {
    00431                 case s_uint_t<N>::INTEGER :
    00432                     return UIntToString(ui.Get());
    00433                 case s_uint_t<N>::INTEGER_NAN :
    00434                     return "nan";
    00435                 case s_uint_t<N>::INTEGER_INF :
    00436                     return "inf";
    00437                 default : return "";
    00438             }
    00439         }
    00440
    00441         /// Converts and formats the provided unsigned integer.
    00442         /** \param uiValue   The unsigned integer to convert
    00443         *   \param uiCharNbr The minimum number of character allowed (fills with zeros)
    00444         *   \note If the string representation of ui is larger than uiCharNbr, it won't
    00445         *         be truncated.
    00446         */
    00447         static string Convert(const s_uint_t<N>& ui, const s_uint_t<default_uint>& uiCharNbr)
    00448         {
    00449             string sReturn = StringConverter< string_element, s_uint_t<N> >::Convert(ui);
    00450
    00451             if (uiCharNbr.IsValid())
    00452             {
    00453                 while (sReturn.length() < uiCharNbr.Get())
    00454                     sReturn = '0' + sReturn;
    00455             }
    00456
    00457             return sReturn;
    00458         }
    00459     };
    00460
    00461     template<class N> class StringConverter< string_element, s_float_t<N> >
    00462     {
    00463     public :
    00464
    00465         typedef s_str_t<string_element>::string string;
    00466
    00467         /// Converts the provided floating point number.
    00468         /** \param f The floating point number to convert
    00469         */
    00470         static string Convert(const s_float_t<N>& f)
    00471         {
    00472             switch (f.GetType())
    00473             {
    00474                 case s_float_t<N>::FLOAT :
    00475                     return FloatToString<N>(f.Get());
    00476                 case s_float_t<N>::FLOAT_NAN :
    00477                     return "nan";
    00478                 case s_float_t<N>::FLOAT_INF_PLUS :
    00479                     return "inf+";
    00480                 case s_float_t<N>::FLOAT_INF_MINUS :
    00481                     return "inf-";
    00482                 default : return "";
    00483             }
    00484         }
    00485
    00486         /// Converts the provided floating point number with fixed number of significant digits.
    00487         /** \param f          The floating point number to convert
    00488         *   \param uiDigitNbr The number of significant digit to display
    00489         */
    00490         static string Convert(const s_float_t<N>& f, const s_uint_t<default_uint>& uiDigitNbr)
    00491         {
    00492             string sReturn;
    00493
    00494             s_float_t<N> fTemp = f;
    00495             if (fTemp < 0.0f)
    00496             {
    00497                 sReturn.push_back('-');
    00498                 fTemp *= -1.0f;
    00499             }
    00500
    00501             if (fTemp < 1.0f)
    00502             {
    00503                 sReturn += "0.";
    00504
    00505                 default_uint uiZeroes = 0;
    00506
    00507                 do
    00508                 {
    00509                     fTemp *= 10.0f;
    00510                     ++uiZeroes;
    00511                 }
    00512                 while (fTemp < 1.0f);
    00513
    00514                 sReturn.append(uiZeroes, '0');
    00515
    00516                 for (default_uint i = 0; i < uiDigitNbr.Get(); ++i)
    00517                 {
    00518                     fTemp *= 10.0f;
    00519                 }
    00520
    00521                 sReturn += StringConverter< string_element, s_uint_t<default_uint> >::Convert(
    00522                     s_uint_t<default_uint>(fTemp)
    00523                 );
    00524             }
    00525             else
    00526             {
    00527                 s_float_t<N> fTemp2 = s_float_t<N>::RoundDown(fTemp);
    00528                 s_uint_t<default_uint> uiInt(fTemp2);
    00529                 sReturn += StringConverter< string_element, s_uint_t<default_uint> >::Convert(uiInt);
    00530
    00531                 default_uint uiSize = sReturn.size();
    00532                 if (sReturn[0] == '-')
    00533                     --uiSize;
    00534
    00535                 if (uiSize > uiDigitNbr.Get())
    00536                 {
    00537                     default_uint uiExcess = uiSize - uiDigitNbr.Get();
    00538
    00539                     sReturn.erase(sReturn.length() - uiExcess, uiExcess);
    00540                     sReturn.append(uiExcess, '0');
    00541                     return sReturn;
    00542                 }
    00543
    00544                 sReturn.push_back('.');
    00545
    00546                 default_uint uiRemaining = uiDigitNbr.Get() - uiSize;
    00547
    00548                 fTemp2 = fTemp - fTemp2;
    00549                 for (default_uint i = 0; i < uiRemaining; ++i)
    00550                 {
    00551                     fTemp2 *= 10.0f;
    00552                 }
    00553
    00554                 sReturn += StringConverter< string_element, s_uint_t<default_uint> >::Convert(
    00555                     s_uint_t<default_uint>(fTemp2), uiRemaining
    00556                 );
    00557             }
    00558
    00559             return sReturn;
    00560         }
    00561
    00562         /// Converts the provided floating point number with fixed size integer and fractional parts.
    00563         /** \param fValue         The s_float to convert
    00564         *   \param uiIntCharNbr   The minimum number of character allowed for the
    00565         *                         integer part (fills with zeros)
    00566         *   \param uinFracCharNbr The number of decimal to show (fills with zeros)
    00567         */
    00568         static string Convert(const s_float_t<N>& f, const s_uint_t<default_uint>& uiIntCharNbr, const s_uint_t<default_uint>& uiFracCharNbr)
    00569         {
    00570             string sReturn;
    00571
    00572             s_float_t<N> fTemp = f;
    00573             if (fTemp < 0.0f)
    00574             {
    00575                 sReturn.push_back('-');
    00576                 fTemp *= -1.0f;
    00577             }
    00578
    00579             s_float_t<N> fTemp2 = s_float_t<N>::RoundDown(fTemp);
    00580
    00581             sReturn = StringConverter< string_element, s_uint_t<default_uint> >::Convert(
    00582                 s_uint_t<default_uint>(fTemp2), uiIntCharNbr
    00583             );
    00584
    00585             if (uiFracCharNbr > 0)
    00586             {
    00587                 fTemp2 = fTemp - fTemp2;
    00588                 for (default_uint i = 0; i < uiFracCharNbr.Get(); ++i)
    00589                     fTemp2 *= 10.0f;
    00590
    00591                 sReturn.push_back('.');
    00592                 sReturn += StringConverter< string_element, s_uint_t<default_uint> >::Convert(
    00593                     s_uint_t<default_uint>(fTemp2), uiFracCharNbr
    00594                 );
    00595             }
    00596
    00597             return sReturn;
    00598         }
    00599     };
    00600
    00601     template<class N> class StringConverter< string_element, s_bool_t<N> >
    00602     {
    00603     public :
    00604
    00605         typedef s_str_t<string_element>::string string;
    00606
    00607         /// Converts the provided boolean.
    00608         /** \param b The boolean to convert
    00609         */
    00610         static string Convert(const s_bool_t<N>& b)
    00611         {
    00612             return b ? "true" : "false";
    00613         }
    00614     };
    00615
    00616     template<class N> class StringConverter< string_element, s_ptr<N> >
    00617     {
    00618     public :
    00619
    00620         typedef s_str_t<string_element>::string string;
    00621
    00622         /// Converts the provided pointer's address.
    00623         /** \param b The pointer to convert
    00624         *   \note The pointer is converted to a ptrdiff_t.
    00625         */
    00626         static string Convert(const s_ptr<N>& p)
    00627         {
    00628             if (p.IsValid())
    00629                 return StringConverter< string_element, s_int_t<ptrdiff_t> >::Convert(
    00630                     s_int_t<ptrdiff_t>((ptrdiff_t)p.Get())
    00631                 );
    00632             else
    00633                 return ("NULL");
    00634         }
    00635     };
    00636
    00637     template<class N> class StringConverter< string_element, s_refptr<N> >
    00638     {
    00639     public :
    00640
    00641         typedef s_str_t<string_element>::string string;
    00642
    00643         /// Converts the provided pointer's address.
    00644         /** \param b The pointer to convert
    00645         *   \note The pointer is converted to a ptrdiff_t.
    00646         */
    00647         static string Convert(const s_refptr<N>& p)
    00648         {
    00649             if (p.IsValid())
    00650                 return StringConverter< string_element, s_int_t<ptrdiff_t> >::Convert(
    00651                     s_int_t<ptrdiff_t>((ptrdiff_t)p.Get())
    00652                 );
    00653             else
    00654                 return ("NULL");
    00655         }
    00656     };
    00657
    00658     template<class N> class StringConverter< string_element, s_wptr<N> >
    00659     {
    00660     public :
    00661
    00662         typedef s_str_t<string_element>::string string;
    00663
    00664         /// Converts the provided pointer's address.
    00665         /** \param b The pointer to convert
    00666         *   \note The pointer is converted to a ptrdiff_t.
    00667         */
    00668         static string Convert(const s_wptr<N>& p)
    00669         {
    00670             if (p.IsValid())
    00671                 return StringConverter< string_element, s_int_t<ptrdiff_t> >::Convert(
    00672                     s_int_t<ptrdiff_t>((ptrdiff_t)p.Lock().Get())
    00673                 );
    00674             else
    00675                 return ("NULL");
    00676         }
    00677     };
    00678
    00679     template<> class StringConverter< uint, s_str_t<string_element> >
    00680     {
    00681     public :
    00682
    00683         typedef std::basic_string<uint> string;
    00684
    00685         typedef bool IsDefined;
    00686
    00687         /// Converts the provided UTF8 encoded string.
    00688         /** \param s The string to copy
    00689         *   \note Calls UTF8ToUnicode().
    00690         */
    00691         static string Construct(const s_str_t<string_element>& s)
    00692         {
    00693             return Convert(s);
    00694         }
    00695
    00696         /// Converts the provided UTF8 encoded string.
    00697         /** \param s The string to convert
    00698         *   \note Calls UTF8ToUnicode().
    00699         */
    00700         static string Convert(const s_str_t<string_element>& s)
    00701         {
    00702             return UTF8ToUnicode(s.Get());
    00703         }
    00704     };
    00705
    00706     template<> class StringConverter< uint, s_str_t<string_element>::string >
    00707     {
    00708     public :
    00709
    00710         typedef std::basic_string<uint> string;
    00711
    00712         typedef bool IsDefined;
    00713
    00714         /// Converts the provided UTF8 encoded string.
    00715         /** \param s The string to copy
    00716         *   \note Calls UTF8ToUnicode().
    00717         */
    00718         static string Construct(const s_str_t<string_element>::string& s)
    00719         {
    00720             return Convert(s);
    00721         }
    00722
    00723         /// Converts the provided UTF8 encoded string.
    00724         /** \param s The string to convert
    00725         *   \note Calls UTF8ToUnicode().
    00726         */
    00727         static string Convert(const s_str_t<string_element>::string& s)
    00728         {
    00729             return UTF8ToUnicode(s);
    00730         }
    00731     };
    00732
    00733     template<> class StringConverter< uint, const string_element* >
    00734     {
    00735     public :
    00736
    00737         typedef std::basic_string<uint> string;
    00738
    00739         typedef bool IsDefined;
    00740
    00741         /// Converts the provided UTF8 encoded string.
    00742         /** \param s The string to copy
    00743         *   \note Calls UTF8ToUnicode().
    00744         */
    00745         static string Construct(const string_element* s)
    00746         {
    00747             return Convert(s);
    00748         }
    00749
    00750         /// Converts the provided UTF8 encoded string.
    00751         /** \param s The string to convert
    00752         *   \note Calls UTF8ToUnicode().
    00753         */
    00754         static string Convert(const string_element* s)
    00755         {
    00756             return UTF8ToUnicode(s_str_t<string_element>::string(s));
    00757         }
    00758     };
    00759
    00760     template<> class StringConverter< uint, string_element* >
    00761     {
    00762     public :
    00763
    00764         typedef std::basic_string<uint> string;
    00765
    00766         typedef bool IsDefined;
    00767
    00768         /// Converts the provided UTF8 encoded string.
    00769         /** \param s The string to copy
    00770         *   \note Calls UTF8ToUnicode().
    00771         */
    00772         static string Construct(string_element* s)
    00773         {
    00774             return Convert(s);
    00775         }
    00776
    00777         /// Converts the provided UTF8 encoded string.
    00778         /** \param s The string to convert
    00779         *   \note Calls UTF8ToUnicode().
    00780         */
    00781         static string Convert(string_element* s)
    00782         {
    00783             return UTF8ToUnicode(s_str_t<string_element>::string(s));
    00784         }
    00785     };
    00786
    00787     template<default_uint N> class StringConverter< uint, const string_element[N] >
    00788     {
    00789     public :
    00790
    00791         typedef std::basic_string<uint> string;
    00792
    00793         typedef bool IsDefined;
    00794
    00795         /// Converts the provided UTF8 encoded string.
    00796         /** \param s The string to copy
    00797         *   \note Calls UTF8ToUnicode().
    00798         */
    00799         static string Construct(const string_element* s)
    00800         {
    00801             return Convert(s);
    00802         }
    00803
    00804         /// Converts the provided UTF8 encoded string.
    00805         /** \param s The string to convert
    00806         *   \note Calls UTF8ToUnicode().
    00807         */
    00808         static string Convert(const string_element* s)
    00809         {
    00810             return UTF8ToUnicode(s_str_t<string_element>::string(s));
    00811         }
    00812     };
    00813
    00814     template<default_uint N> class StringConverter< uint, string_element[N] >
    00815     {
    00816     public :
    00817
    00818         typedef std::basic_string<uint> string;
    00819
    00820         typedef bool IsDefined;
    00821
    00822         /// Converts the provided UTF8 encoded string.
    00823         /** \param s The string to copy
    00824         *   \note Calls UTF8ToUnicode().
    00825         */
    00826         static string Construct(const string_element* s)
    00827         {
    00828             return Convert(s);
    00829         }
    00830
    00831         /// Converts the provided UTF8 encoded string.
    00832         /** \param s The string to convert
    00833         *   \note Calls UTF8ToUnicode().
    00834         */
    00835         static string Convert(const string_element* s)
    00836         {
    00837             return UTF8ToUnicode(s_str_t<string_element>::string(s));
    00838         }
    00839     };
    00840
    00841     template<> class StringConverter<uint, TypeTraits<uint>::FrostType>
    00842     {
    00843     public :
    00844
    00845         typedef std::basic_string<uint> string;
    00846
    00847         /// Constructor.
    00848         /** \param c The character to copy
    00849         */
    00850         static string Convert(const TypeTraits<uint>::FrostType& c)
    00851         {
    00852             string s;
    00853             s.push_back(c.Get());
    00854             return s;
    00855         }
    00856
    00857         /// Creates "uiNbr" copies of the provided character.
    00858         /** \param c     The character to copy
    00859         *   \param uiNbr The number of times to copy the character
    00860         *   \note If uiNbr equals 0, creates an empty string.
    00861         */
    00862         static string Convert(const TypeTraits<uint>::FrostType& c, const s_uint_t<default_uint>& uiNbr)
    00863         {
    00864             if (uiNbr.IsValid())
    00865                 return string(uiNbr.Get(), c.Get());
    00866             else
    00867                 return string();
    00868         }
    00869     };
    00870
    00871     template<> class StringConverter< string_element, std::basic_string<uint> >
    00872     {
    00873     public :
    00874
    00875         typedef std::basic_string<string_element> string;
    00876
    00877         /// Converts the provided Unicode string to a UTF8 encoded string.
    00878         /** \param s The string to convert
    00879         */
    00880         static string Convert(const std::basic_string<uint>& s)
    00881         {
    00882             return UnicodeToUTF8(s);
    00883         }
    00884     };
    00885
    00886     template<> class StringConverter< string_element, uint >
    00887     {
    00888     public :
    00889
    00890         typedef s_str_t<string_element>::string string;
    00891
    00892         /// Constructor.
    00893         /** \param c The character to copy
    00894         */
    00895         static string Convert(const uint& c)
    00896         {
    00897             std::basic_string<uint> s;
    00898             s.push_back(c);
    00899             return UnicodeToUTF8(s);
    00900         }
    00901
    00902         /// Constructor.
    00903         /** \param c The character to copy
    00904         */
    00905         static string_element ConvertChar(const uint& c)
    00906         {
    00907             return UnicodeToUTF8(c);
    00908         }
    00909     };
    00910 }
    00911 /** \endcond
    00912 */