/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <array> #include <cstdint> #include <limits> #include <folly/detail/base64_detail/Base64Constants.h> namespace folly::detail::base64_detail::constants { // Some constants we have to expose for everyone in order to // support constexpr operations. // These we can internalize. // SWAR ----------------------------------------- constexpr std::uint32_t kSwarDecodeErrorMarker = …; template <typename DecodeChar> constexpr std::array<std::array<std::uint32_t, 256>, 4> buildSWARDecodeTable( DecodeChar decodeChar) { … } constexpr auto kBase64SwarDecodeTable = …; constexpr auto kBase64SwarURLDecodeTable = …; // Simd ----------------------------------------- // clang-format off constexpr std::array<std::int8_t, 16> kEncodeTable { … }; // clang-format on constexpr auto kEncodeURLTable = …auto res = …; constexpr auto kValidHighByLowNibble = …auto build = …::uint8_t nibblesArr[] = …::uint8_t res = …::uint8_t nibble : nibblesArr) { … } return res; }; std::array<std::uint8_t, 16> res{ … }; res[0] = …int i = …; // clang-format off constexpr std::array<std::int8_t, 16> kOffsetByHighNibbleDecodeTable { … }; // clang-format on } // namespace folly::detail::base64_detail::constants