mptStringFormat.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * mptStringFormat.cpp
  3. * -------------------
  4. * Purpose: Convert other types to strings.
  5. * Notes : Currently none.
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #include "stdafx.h"
  10. #include "mptStringFormat.h"
  11. #include "mpt/format/default_floatingpoint.hpp"
  12. #include "mpt/format/default_integer.hpp"
  13. #include "mpt/format/helpers.hpp"
  14. #include "mpt/format/simple_floatingpoint.hpp"
  15. #include "mpt/format/simple_integer.hpp"
  16. OPENMPT_NAMESPACE_BEGIN
  17. namespace mpt
  18. {
  19. std::string ToAString(const bool & x) { return mpt::format_value_default<std::string>(x); }
  20. std::string ToAString(const signed char & x) { return mpt::format_value_default<std::string>(x); }
  21. std::string ToAString(const unsigned char & x) { return mpt::format_value_default<std::string>(x); }
  22. std::string ToAString(const signed short & x) { return mpt::format_value_default<std::string>(x); }
  23. std::string ToAString(const unsigned short & x) { return mpt::format_value_default<std::string>(x); }
  24. std::string ToAString(const signed int & x) { return mpt::format_value_default<std::string>(x); }
  25. std::string ToAString(const unsigned int & x) { return mpt::format_value_default<std::string>(x); }
  26. std::string ToAString(const signed long & x) { return mpt::format_value_default<std::string>(x); }
  27. std::string ToAString(const unsigned long & x) { return mpt::format_value_default<std::string>(x); }
  28. std::string ToAString(const signed long long & x) { return mpt::format_value_default<std::string>(x); }
  29. std::string ToAString(const unsigned long long & x) { return mpt::format_value_default<std::string>(x); }
  30. std::string ToAString(const float & x) { return mpt::format_value_default<std::string>(x); }
  31. std::string ToAString(const double & x) { return mpt::format_value_default<std::string>(x); }
  32. std::string ToAString(const long double & x) { return mpt::format_value_default<std::string>(x); }
  33. #if MPT_WSTRING_FORMAT
  34. #if MPT_USTRING_MODE_UTF8
  35. mpt::ustring ToUString(const std::wstring & x) { return mpt::ToUnicode(x); }
  36. #endif
  37. mpt::ustring ToUString(const wchar_t * const & x) { return mpt::ToUnicode(x); }
  38. #endif
  39. #if defined(MPT_WITH_MFC)
  40. mpt::ustring ToUString(const CString & x) { return mpt::ToUnicode(x); }
  41. #endif // MPT_WITH_MFC
  42. mpt::ustring ToUString(const bool & x) { return mpt::format_value_default<mpt::ustring>(x); }
  43. mpt::ustring ToUString(const signed char & x) { return mpt::format_value_default<mpt::ustring>(x); }
  44. mpt::ustring ToUString(const unsigned char & x) { return mpt::format_value_default<mpt::ustring>(x); }
  45. mpt::ustring ToUString(const signed short & x) { return mpt::format_value_default<mpt::ustring>(x); }
  46. mpt::ustring ToUString(const unsigned short & x) { return mpt::format_value_default<mpt::ustring>(x); }
  47. mpt::ustring ToUString(const signed int & x) { return mpt::format_value_default<mpt::ustring>(x); }
  48. mpt::ustring ToUString(const unsigned int & x) { return mpt::format_value_default<mpt::ustring>(x); }
  49. mpt::ustring ToUString(const signed long & x) { return mpt::format_value_default<mpt::ustring>(x); }
  50. mpt::ustring ToUString(const unsigned long & x) { return mpt::format_value_default<mpt::ustring>(x); }
  51. mpt::ustring ToUString(const signed long long & x) { return mpt::format_value_default<mpt::ustring>(x); }
  52. mpt::ustring ToUString(const unsigned long long & x) { return mpt::format_value_default<mpt::ustring>(x); }
  53. mpt::ustring ToUString(const float & x) { return mpt::format_value_default<mpt::ustring>(x); }
  54. mpt::ustring ToUString(const double & x) { return mpt::format_value_default<mpt::ustring>(x); }
  55. mpt::ustring ToUString(const long double & x) { return mpt::format_value_default<mpt::ustring>(x); }
  56. #if MPT_WSTRING_FORMAT
  57. #if MPT_USTRING_MODE_UTF8
  58. std::wstring ToWString(const mpt::ustring & x) { return mpt::ToWide(x); }
  59. #endif
  60. #if defined(MPT_WITH_MFC)
  61. std::wstring ToWString(const CString & x) { return mpt::ToWide(x); }
  62. #endif // MPT_WITH_MFC
  63. std::wstring ToWString(const bool & x) { return mpt::format_value_default<std::wstring>(x); }
  64. std::wstring ToWString(const signed char & x) { return mpt::format_value_default<std::wstring>(x); }
  65. std::wstring ToWString(const unsigned char & x) { return mpt::format_value_default<std::wstring>(x); }
  66. std::wstring ToWString(const signed short & x) { return mpt::format_value_default<std::wstring>(x); }
  67. std::wstring ToWString(const unsigned short & x) { return mpt::format_value_default<std::wstring>(x); }
  68. std::wstring ToWString(const signed int & x) { return mpt::format_value_default<std::wstring>(x); }
  69. std::wstring ToWString(const unsigned int & x) { return mpt::format_value_default<std::wstring>(x); }
  70. std::wstring ToWString(const signed long & x) { return mpt::format_value_default<std::wstring>(x); }
  71. std::wstring ToWString(const unsigned long & x) { return mpt::format_value_default<std::wstring>(x); }
  72. std::wstring ToWString(const signed long long & x) { return mpt::format_value_default<std::wstring>(x); }
  73. std::wstring ToWString(const unsigned long long & x) { return mpt::format_value_default<std::wstring>(x); }
  74. std::wstring ToWString(const float & x) { return mpt::format_value_default<std::wstring>(x); }
  75. std::wstring ToWString(const double & x) { return mpt::format_value_default<std::wstring>(x); }
  76. std::wstring ToWString(const long double & x) { return mpt::format_value_default<std::wstring>(x); }
  77. #endif
  78. std::string FormatValA(const bool & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  79. std::string FormatValA(const signed char & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  80. std::string FormatValA(const unsigned char & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  81. std::string FormatValA(const signed short & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  82. std::string FormatValA(const unsigned short & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  83. std::string FormatValA(const signed int & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  84. std::string FormatValA(const unsigned int & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  85. std::string FormatValA(const signed long & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  86. std::string FormatValA(const unsigned long & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  87. std::string FormatValA(const signed long long & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  88. std::string FormatValA(const unsigned long long & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  89. std::string FormatValA(const float & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  90. std::string FormatValA(const double & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  91. std::string FormatValA(const long double & x, const FormatSpec & f) { return mpt::format_simple<std::string>(x, f); }
  92. mpt::ustring FormatValU(const bool & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  93. mpt::ustring FormatValU(const signed char & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  94. mpt::ustring FormatValU(const unsigned char & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  95. mpt::ustring FormatValU(const signed short & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  96. mpt::ustring FormatValU(const unsigned short & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  97. mpt::ustring FormatValU(const signed int & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  98. mpt::ustring FormatValU(const unsigned int & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  99. mpt::ustring FormatValU(const signed long & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  100. mpt::ustring FormatValU(const unsigned long & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  101. mpt::ustring FormatValU(const signed long long & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  102. mpt::ustring FormatValU(const unsigned long long & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  103. mpt::ustring FormatValU(const float & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  104. mpt::ustring FormatValU(const double & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  105. mpt::ustring FormatValU(const long double & x, const FormatSpec & f) { return mpt::format_simple<mpt::ustring>(x, f); }
  106. #if MPT_WSTRING_FORMAT
  107. std::wstring FormatValW(const bool & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  108. std::wstring FormatValW(const signed char & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  109. std::wstring FormatValW(const unsigned char & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  110. std::wstring FormatValW(const signed short & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  111. std::wstring FormatValW(const unsigned short & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  112. std::wstring FormatValW(const signed int & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  113. std::wstring FormatValW(const unsigned int & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  114. std::wstring FormatValW(const signed long & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  115. std::wstring FormatValW(const unsigned long & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  116. std::wstring FormatValW(const signed long long & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  117. std::wstring FormatValW(const unsigned long long & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  118. std::wstring FormatValW(const float & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  119. std::wstring FormatValW(const double & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  120. std::wstring FormatValW(const long double & x, const FormatSpec & f) { return mpt::format_simple<std::wstring>(x, f); }
  121. #endif
  122. } // namespace mpt
  123. OPENMPT_NAMESPACE_END