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,
73 FunctionInitialFunction,
78 FunctionAddrOffsetConcrete,
83 LineEntryStartAddress,
99 const char *string; // Insert this exact string into the output
101 FormatType format_type; // uint32_t, uint64_t, cstr, or anything that can be formatted by printf or lldb::Format
103 uint32_t num_children;
104 Definition *children; // An array of "num_children" Definition entries,
108 Entry (Type t = Type::Invalid,
109 const char *s = NULL,
110 const char *f = NULL) :
112 printf_format (f ? f : ""),
116 fmt (lldb::eFormatDefault),
122 Entry (llvm::StringRef s);
126 AppendChar (char ch);
129 AppendText (const llvm::StringRef &s);
132 AppendText (const char *cstr);
135 AppendEntry (const Entry &&entry)
137 children.push_back(entry);
144 printf_format.clear();
147 type = Type::Invalid;
148 fmt = lldb::eFormatDefault;
154 TypeToCString (Type t);
157 Dump (Stream &s, int depth = 0) const;
160 operator == (const Entry &rhs) const
162 if (string != rhs.string)
164 if (printf_format != rhs.printf_format)
166 const size_t n = children.size();
167 const size_t m = rhs.children.size();
168 for (size_t i=0; i < std::min<size_t>(n, m); ++i)
170 if (!(children[i] == rhs.children[i]))
173 if (children != rhs.children)
175 if (definition != rhs.definition)
177 if (type != rhs.type)
181 if (deref != rhs.deref)
187 std::string printf_format;
188 std::vector<Entry> children;
189 Definition *definition;
197 Format (const Entry &entry,
199 const SymbolContext *sc,
200 const ExecutionContext *exe_ctx,
203 bool function_changed,
204 bool initial_function);
207 FormatStringRef (const llvm::StringRef &format,
209 const SymbolContext *sc,
210 const ExecutionContext *exe_ctx,
213 bool function_changed,
214 bool initial_function);
217 FormatCString (const char *format,
219 const SymbolContext *sc,
220 const ExecutionContext *exe_ctx,
223 bool function_changed,
224 bool initial_function);
227 Parse (const llvm::StringRef &format, Entry &entry);
230 ExtractVariableInfo (llvm::StringRef &format_str,
231 llvm::StringRef &variable_name,
232 llvm::StringRef &variable_format);
235 AutoComplete (const char *s,
236 int match_start_point,
237 int max_return_elements,
239 StringList &matches);
241 //----------------------------------------------------------------------
242 // Format the current elements into the stream \a s.
244 // The root element will be stripped off and the format str passed in
245 // will be either an empty string (print a description of this object),
246 // or contain a . separated series like a domain name that identifies
247 // further sub elements to display.
248 //----------------------------------------------------------------------
250 FormatFileSpec (const FileSpec &file, Stream &s, llvm::StringRef elements, llvm::StringRef element_format);
254 ParseInternal (llvm::StringRef &format, Entry &parent_entry, uint32_t depth);
259 #endif // #if defined(__cplusplus)
260 #endif // liblldb_FormatEntity_h_