mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
48a2a801f7
Summary: There will be two embedded hg object ID formats, so a single boolean is not sufficient. Introduce an enumeration to prepare for the intermediate representation. Reviewed By: kmancini Differential Revision: D33200681 fbshipit-source-id: 6ecc1488ef000fd3707f2f07094d7940e4a67d39
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#include "eden/fs/config/MountProtocol.h"
|
|
|
|
namespace facebook::eden {
|
|
|
|
namespace {
|
|
|
|
constexpr auto mountProtocolStr = [] {
|
|
std::array<folly::StringPiece, 3> mapping{};
|
|
mapping[folly::to_underlying(MountProtocol::FUSE)] = "FUSE";
|
|
mapping[folly::to_underlying(MountProtocol::PRJFS)] = "PrjFS";
|
|
mapping[folly::to_underlying(MountProtocol::NFS)] = "NFS";
|
|
return mapping;
|
|
}();
|
|
|
|
}
|
|
|
|
folly::Expected<MountProtocol, std::string>
|
|
FieldConverter<MountProtocol>::fromString(
|
|
folly::StringPiece value,
|
|
const std::map<std::string, std::string>& /*unused*/) const {
|
|
for (auto protocol = 0ul; protocol < mountProtocolStr.size(); protocol++) {
|
|
if (value.equals(
|
|
mountProtocolStr[protocol], folly::AsciiCaseInsensitive())) {
|
|
return static_cast<MountProtocol>(protocol);
|
|
}
|
|
}
|
|
|
|
return folly::makeUnexpected(
|
|
fmt::format("Failed to convert value '{}' to a MountProtocol.", value));
|
|
}
|
|
|
|
std::string FieldConverter<MountProtocol>::toDebugString(
|
|
MountProtocol value) const {
|
|
return mountProtocolStr[folly::to_underlying(value)].str();
|
|
}
|
|
|
|
} // namespace facebook::eden
|