Windows: Specialized `flags::parse<int_fd>`. Review: https://reviews.apache.org/r/66834
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0b38be5f Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0b38be5f Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0b38be5f Branch: refs/heads/master Commit: 0b38be5ffa788029cb2aec4b89687d1f8f75af9c Parents: 72c9e86 Author: Andrew Schwartzmeyer <[email protected]> Authored: Thu Apr 26 14:15:21 2018 -0700 Committer: Andrew Schwartzmeyer <[email protected]> Committed: Tue May 1 18:36:04 2018 -0700 ---------------------------------------------------------------------- 3rdparty/stout/include/stout/flags/parse.hpp | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/0b38be5f/3rdparty/stout/include/stout/flags/parse.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/stout/include/stout/flags/parse.hpp b/3rdparty/stout/include/stout/flags/parse.hpp index eb6d527..4566b79 100644 --- a/3rdparty/stout/include/stout/flags/parse.hpp +++ b/3rdparty/stout/include/stout/flags/parse.hpp @@ -189,6 +189,35 @@ inline Try<SecurePathOrValue> parse(const std::string& value) return result; } + +#ifdef __WINDOWS__ +template <> +inline Try<int_fd> parse(const std::string& value) +{ + // Looks like "WindowsFD::Type::HANDLE=0000000000000000". + std::vector<std::string> fd = strings::split(value, "="); + if (fd.size() != 2) { + return Error("Expected to split string into exactly two parts."); + } + + if (strings::endsWith(fd[0], "HANDLE")) { + Try<HANDLE> t = parse<HANDLE>(fd[1]); + if (t.isError()) { + return Error(t.error()); + } + return int_fd(t.get()); + } else if (strings::endsWith(fd[0], "SOCKET")) { + Try<SOCKET> t = parse<SOCKET>(fd[1]); + if (t.isError()) { + return Error(t.error()); + } + return int_fd(t.get()); + } + + return Error("`int_fd` was neither a `HANDLE` nor a `SOCKET`"); +} +#endif // __WINDOWS__ + } // namespace flags { #endif // __STOUT_FLAGS_PARSE_HPP__
