9#ifndef LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H
10#define LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H
61 llvm::StringRef type_lexer(type);
63 type_lexer.consume_front(
"class ");
64 type_lexer.consume_front(
"enum ");
65 type_lexer.consume_front(
"struct ");
66 type_lexer.consume_front(
"union ");
67 type_lexer = type_lexer.ltrim();
96 return m_name == type_name ||
109 std::make_shared<TypeImpl>(candidate_type.
GetType()));
140 typedef typename std::shared_ptr<ValueType>
ValueSP;
141 typedef std::vector<std::pair<TypeMatcher, ValueSP>>
MapType;
144 typedef typename std::shared_ptr<FormattersContainer<ValueType>>
153 entry->GetRevision() =
listener->GetCurrentRevision();
155 entry->GetRevision() = 0;
157 std::lock_guard<std::recursive_mutex> guard(
m_map_mutex);
159 m_map.emplace_back(std::move(matcher), std::move(entry));
165 std::lock_guard<std::recursive_mutex> guard(
m_map_mutex);
166 for (
auto iter =
m_map.begin(); iter !=
m_map.end(); ++iter)
167 if (iter->first.CreatedBySameMatchString(matcher)) {
178 std::lock_guard<std::recursive_mutex> guard(
m_map_mutex);
179 for (
auto &formatter : llvm::reverse(
m_map)) {
180 if (formatter.first.Matches(candidate)) {
181 entry = formatter.second;
192 if (
Get(candidate, entry)) {
193 if (candidate.IsMatch(entry))
203 std::lock_guard<std::recursive_mutex> guard(
m_map_mutex);
204 for (
const auto &pos :
m_map)
205 if (pos.first.CreatedBySameMatchString(matcher)) {
213 std::lock_guard<std::recursive_mutex> guard(
m_map_mutex);
214 if (index >=
m_map.size())
216 return m_map[index].second;
220 std::lock_guard<std::recursive_mutex> guard(
m_map_mutex);
221 if (index >=
m_map.size())
224 return std::make_shared<TypeNameSpecifierImpl>(
229 std::lock_guard<std::recursive_mutex> guard(
m_map_mutex);
237 std::lock_guard<std::recursive_mutex> guard(
m_map_mutex);
238 for (
const auto &pos :
m_map) {
240 if (!callback(type, pos.second))
247 std::lock_guard<std::recursive_mutex> guard(
m_map_mutex);
static llvm::StringRef GetName(XcodeSDK::Type type)
"lldb/Utility/ArgCompletionRequest.h"
void TryCompleteCurrentArg(llvm::StringRef completion, llvm::StringRef description="")
Adds a possible completion string if the completion would complete the current argument.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
virtual bool FormatterCallbackFunction(const char *function_name, lldb::TypeImplSP type_impl_sp)
Class for matching type names.
TypeMatcher(lldb::TypeNameSpecifierImplSP type_specifier)
Creates a matcher using the matching type and string from the given type name specifier.
lldb::FormatterMatchType m_match_type
Indicates what kind of matching strategy should be used:
llvm::StringRef GetMatchString() const
Returns the underlying match string for this TypeMatcher.
RegularExpression m_type_name_regex
lldb::FormatterMatchType GetMatchType() const
std::string m_name
Type name for exact match, or name of the python callback if m_match_type is eFormatterMatchCallback.
bool CreatedBySameMatchString(TypeMatcher other) const
Returns true if this TypeMatcher and the given one were most created by the same match string.
TypeMatcher(RegularExpression regex)
Creates a matcher that accepts any type matching the given regex.
bool Matches(FormattersMatchCandidate candidate_type) const
True iff this matches the given type.
TypeMatcher(std::string type_name)
Creates a matcher that accepts any type with exactly the given type name.
static llvm::StringRef StripTypeName(llvm::StringRef type)
A class that represents a running process on the host machine.
std::vector< FormattersMatchCandidate > FormattersMatchVector
std::shared_ptr< lldb_private::TypeNameSpecifierImpl > TypeNameSpecifierImplSP
FormatterMatchType
Type of match to be performed when looking for a formatter for a data type.
@ eFormatterMatchCallback