1 //===-- FormatEntity.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_FormatEntity_h_
11 #define liblldb_FormatEntity_h_
12 #if defined(__cplusplus)
17 #include "lldb/lldb-private.h"
18 #include "lldb/Core/Error.h"
25 namespace lldb_private
43 ScriptVariableSynthetic,
57 ThreadCompletedExpression,
74 FunctionInitialFunction,
79 FunctionAddrOffsetConcrete,
86 LineEntryStartAddress,
102 const char *string; // Insert this exact string into the output
104 FormatType format_type; // uint32_t, uint64_t, cstr, or anything that can be formatted by printf or lldb::Format
106 uint32_t num_children;
107 Definition *children; // An array of "num_children" Definition entries,
111 Entry (Type t = Type::Invalid,
112 const char *s = NULL,
113 const char *f = NULL) :
115 printf_format (f ? f : ""),
119 fmt (lldb::eFormatDefault),
125 Entry (llvm::StringRef s);
129 AppendChar (char ch);
132 AppendText (const llvm::StringRef &s);
135 AppendText (const char *cstr);
138 AppendEntry (const Entry &&entry)
140 children.push_back(entry);
147 printf_format.clear();
150 type = Type::Invalid;
151 fmt = lldb::eFormatDefault;
157 TypeToCString (Type t);
160 Dump (Stream &s, int depth = 0) const;
163 operator == (const Entry &rhs) const
165 if (string != rhs.string)
167 if (printf_format != rhs.printf_format)
169 const size_t n = children.size();
170 const size_t m = rhs.children.size();
171 for (size_t i=0; i < std::min<size_t>(n, m); ++i)
173 if (!(children[i] == rhs.children[i]))
176 if (children != rhs.children)
178 if (definition != rhs.definition)
180 if (type != rhs.type)
184 if (deref != rhs.deref)
190 std::string printf_format;
191 std::vector<Entry> children;
192 Definition *definition;
200 Format (const Entry &entry,
202 const SymbolContext *sc,
203 const ExecutionContext *exe_ctx,
206 bool function_changed,
207 bool initial_function);
210 FormatStringRef (const llvm::StringRef &format,
212 const SymbolContext *sc,
213 const ExecutionContext *exe_ctx,
216 bool function_changed,
217 bool initial_function);
220 FormatCString (const char *format,
222 const SymbolContext *sc,
223 const ExecutionContext *exe_ctx,
226 bool function_changed,
227 bool initial_function);
230 Parse (const llvm::StringRef &format, Entry &entry);
233 ExtractVariableInfo (llvm::StringRef &format_str,
234 llvm::StringRef &variable_name,
235 llvm::StringRef &variable_format);
238 AutoComplete (const char *s,
239 int match_start_point,
240 int max_return_elements,
242 StringList &matches);
244 //----------------------------------------------------------------------
245 // Format the current elements into the stream \a s.
247 // The root element will be stripped off and the format str passed in
248 // will be either an empty string (print a description of this object),
249 // or contain a . separated series like a domain name that identifies
250 // further sub elements to display.
251 //----------------------------------------------------------------------
253 FormatFileSpec (const FileSpec &file, Stream &s, llvm::StringRef elements, llvm::StringRef element_format);
257 ParseInternal (llvm::StringRef &format, Entry &parent_entry, uint32_t depth);
262 #endif // #if defined(__cplusplus)
263 #endif // liblldb_FormatEntity_h_