object-introspection/src/ContainerInfo.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

95 lines
3.0 KiB
C
Raw Normal View History

2022-12-19 14:37:51 +00:00
/*
* 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 <filesystem>
#include <optional>
2022-12-20 12:54:40 +00:00
#include <regex>
2022-12-19 14:37:51 +00:00
#include <string>
#include <vector>
namespace fs = std::filesystem;
#define LIST_OF_CONTAINER_TYPES \
X(UNKNOWN_TYPE) \
X(ARRAY_TYPE) \
X(SMALL_VEC_TYPE) \
X(SET_TYPE) \
X(UNORDERED_SET_TYPE) \
X(SEQ_TYPE) \
X(LIST_TYPE) \
X(STD_MAP_TYPE) \
X(STD_UNORDERED_MAP_TYPE) \
X(MAP_SEQ_TYPE) \
X(BY_MULTI_QRT_TYPE) \
X(F14_MAP) \
X(F14_SET) \
X(FEED_QUICK_HASH_SET) \
X(FEED_QUICK_HASH_MAP) \
X(RADIX_TREE_TYPE) \
X(PAIR_TYPE) \
X(STRING_TYPE) \
X(FOLLY_IOBUF_TYPE) \
X(FOLLY_IOBUFQUEUE_TYPE) \
X(FB_STRING_TYPE) \
X(UNIQ_PTR_TYPE) \
X(SHRD_PTR_TYPE) \
X(FB_HASH_MAP_TYPE) \
X(FB_HASH_SET_TYPE) \
X(FOLLY_OPTIONAL_TYPE) \
X(OPTIONAL_TYPE) \
X(TRY_TYPE) \
X(REF_WRAPPER_TYPE) \
X(SORTED_VEC_SET_TYPE) \
X(REPEATED_FIELD_TYPE) \
X(CAFFE2_BLOB_TYPE) \
X(MULTI_MAP_TYPE) \
X(FOLLY_SMALL_HEAP_VECTOR_MAP) \
X(CONTAINER_ADAPTER_TYPE) \
X(MICROLIST_TYPE) \
X(ENUM_MAP_TYPE) \
X(BOOST_BIMAP_TYPE) \
X(STD_VARIANT_TYPE) \
X(THRIFT_ISSET_TYPE) \
X(WEAK_PTR_TYPE)
2022-12-19 14:37:51 +00:00
enum ContainerTypeEnum {
#define X(name) name,
LIST_OF_CONTAINER_TYPES
#undef X
};
ContainerTypeEnum containerTypeEnumFromStr(std::string& str);
const char* containerTypeEnumToStr(ContainerTypeEnum ty);
2022-12-19 14:37:51 +00:00
struct ContainerInfo {
std::string typeName;
2022-12-20 12:54:40 +00:00
std::regex matcher;
2022-12-19 14:37:51 +00:00
std::optional<size_t> numTemplateParams;
ContainerTypeEnum ctype = UNKNOWN_TYPE;
std::string header;
std::vector<std::string> ns;
std::vector<size_t> replaceTemplateParamIndex{};
std::optional<size_t> allocatorIndex{};
// Index of underlying container in template parameters for a container
// adapter
std::optional<size_t> underlyingContainerIndex{};
static std::unique_ptr<ContainerInfo> loadFromFile(const fs::path& path);
2022-12-19 14:37:51 +00:00
bool operator<(const ContainerInfo& rhs) const {
2022-12-19 14:37:51 +00:00
return (typeName < rhs.typeName);
}
};