You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/04/04 23:53:31 UTC

[03/13] mesos git commit: Stout: Added stringify for std::wstring.

Stout: Added stringify for std::wstring.

Review: https://reviews.apache.org/r/58125/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/718d3c94
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/718d3c94
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/718d3c94

Branch: refs/heads/master
Commit: 718d3c9473c29202c08263fd379ce08d61297075
Parents: 396f82a
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Mon Apr 3 16:04:37 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Tue Apr 4 16:45:16 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/stringify.hpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/718d3c94/3rdparty/stout/include/stout/stringify.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/stringify.hpp b/3rdparty/stout/include/stout/stringify.hpp
index e9588d8..6984315 100644
--- a/3rdparty/stout/include/stout/stringify.hpp
+++ b/3rdparty/stout/include/stout/stringify.hpp
@@ -21,6 +21,13 @@
 #include <string>
 #include <vector>
 
+#ifdef __WINDOWS__
+// `codecvt` is not available on older versions of Linux. Until it is needed on
+// other platforms, it's easiest to just build the UTF converter for Windows.
+#include <codecvt>
+#include <locale>
+#endif // __WINDOWS__
+
 #include "abort.hpp"
 #include "hashmap.hpp"
 #include "set.hpp"
@@ -36,6 +43,15 @@ std::string stringify(T t)
   return out.str();
 }
 
+#ifdef __WINDOWS__
+inline std::string stringify(const std::wstring& str)
+{
+  // Convert UTF-16 `wstring` to UTF-8 `string`.
+  std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> converter;
+  return converter.to_bytes(str);
+}
+#endif // __WINDOWS__
+
 
 template <>
 inline std::string stringify(bool b)