// Copyright Epic Games, Inc. All Rights Reserved. #include "cachekey.h" #include namespace zen { using namespace std::literals; namespace detail { namespace cacheopt { constexpr std::string_view Local = "local"sv; constexpr std::string_view Remote = "remote"sv; constexpr std::string_view Data = "data"sv; constexpr std::string_view Meta = "meta"sv; constexpr std::string_view Value = "value"sv; constexpr std::string_view Attachments = "attachments"sv; }} // namespace detail::cacheopt CachePolicy ParseQueryCachePolicy(std::string_view QueryPolicy, CachePolicy Default) { if (QueryPolicy.empty()) { return Default; } CachePolicy Result = CachePolicy::None; ForEachStrTok(QueryPolicy, ',', [&Result](const std::string_view& Token) { if (Token == detail::cacheopt::Local) { Result |= CachePolicy::QueryLocal; } if (Token == detail::cacheopt::Remote) { Result |= CachePolicy::QueryRemote; } return true; }); return Result; } CachePolicy ParseStoreCachePolicy(std::string_view StorePolicy, CachePolicy Default) { if (StorePolicy.empty()) { return Default; } CachePolicy Result = CachePolicy::None; ForEachStrTok(StorePolicy, ',', [&Result](const std::string_view& Token) { if (Token == detail::cacheopt::Local) { Result |= CachePolicy::StoreLocal; } if (Token == detail::cacheopt::Remote) { Result |= CachePolicy::StoreRemote; } return true; }); return Result; } CachePolicy ParseSkipCachePolicy(std::string_view SkipPolicy, CachePolicy Default) { if (SkipPolicy.empty()) { return Default; } CachePolicy Result = CachePolicy::None; ForEachStrTok(SkipPolicy, ',', [&Result](const std::string_view& Token) { if (Token == detail::cacheopt::Meta) { Result |= CachePolicy::SkipMeta; } if (Token == detail::cacheopt::Value) { Result |= CachePolicy::SkipValue; } if (Token == detail::cacheopt::Attachments) { Result |= CachePolicy::SkipAttachments; } if (Token == detail::cacheopt::Data) { Result |= CachePolicy::SkipData; } return true; }); return Result; } CacheKey CacheKey::None = CacheKey{.Bucket = std::string(), .Hash = IoHash()}; } // namespace zen