Doxygen
Loading...
Searching...
No Matches
sqlite3gen.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2015 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16// own header
17#include "sqlite3gen.h"
18
19// standard includes
20#include <sys/stat.h>
21#include <string.h>
22#include <sqlite3.h>
23
24// other includes
25#include "arguments.h"
26#include "classlist.h"
27#include "conceptdef.h"
28#include "config.h"
29#include "datetime.h"
30#include "dir.h"
31#include "docnode.h"
32#include "docparser.h"
33#include "doxygen.h"
34#include "filedef.h"
35#include "fileinfo.h"
36#include "filename.h"
37#include "groupdef.h"
38#include "memberdef.h"
39#include "membername.h"
40#include "message.h"
41#include "moduledef.h"
42#include "namespacedef.h"
43#include "outputlist.h"
44#include "pagedef.h"
45#include "util.h"
46#include "version.h"
47#include "xmldocvisitor.h"
48
49
50// enable to show general debug messages
51// #define SQLITE3_DEBUG
52
53// enable to print all executed SQL statements.
54// I recommend using the smallest possible input list.
55// #define SQLITE3_DEBUG_SQL
56
57# ifdef SQLITE3_DEBUG
58# define DBG_CTX(x) printf x
59# else // SQLITE3_DEBUG
60# define DBG_CTX(x) do { } while(0)
61# endif
62
63# ifdef SQLITE3_DEBUG_SQL
64// used by sqlite3_trace in generateSqlite3()
65static void sqlLog(void *dbName, const char *sql){
66 msg("SQL: '{}'\n", sql);
67}
68# endif
69
70const char * table_schema[][2] = {
71 /* TABLES */
72 { "meta",
73 "CREATE TABLE IF NOT EXISTS meta (\n"
74 "\t-- Information about this db and how it was generated.\n"
75 "\t-- Doxygen info\n"
76 "\tdoxygen_version TEXT PRIMARY KEY NOT NULL,\n"
77 /*
78 Doxygen's version is likely to rollover much faster than the schema, and
79 at least until it becomes a core output format, we might want to make
80 fairly large schema changes even on minor iterations for Doxygen itself.
81 If these tools just track a predefined semver schema version that can
82 iterate independently, it *might* not be as hard to keep them in sync?
83 */
84 "\tschema_version TEXT NOT NULL, -- Schema-specific semver\n"
85 "\t-- run info\n"
86 "\tgenerated_at TEXT NOT NULL,\n"
87 "\tgenerated_on TEXT NOT NULL,\n"
88 "\t-- project info\n"
89 "\tproject_name TEXT NOT NULL,\n"
90 "\tproject_number TEXT,\n"
91 "\tproject_brief TEXT\n"
92 ");"
93 },
94 { "includes",
95 "CREATE TABLE IF NOT EXISTS includes (\n"
96 "\t-- #include relations.\n"
97 "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
98 "\tlocal INTEGER NOT NULL,\n"
99 "\tsrc_id INTEGER NOT NULL REFERENCES path, -- File id of the includer.\n"
100 "\tdst_id INTEGER NOT NULL REFERENCES path, -- File id of the includee.\n"
101 /*
102 In theory we could include name here to be informationally equivalent
103 with the XML, but I don't see an obvious use for it.
104 */
105 "\tUNIQUE(local, src_id, dst_id) ON CONFLICT IGNORE\n"
106 ");"
107 },
108 { "contains",
109 "CREATE TABLE IF NOT EXISTS contains (\n"
110 "\t-- inner/outer relations (file, namespace, dir, class, group, page)\n"
111 "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
112 "\tinner_rowid INTEGER NOT NULL REFERENCES compounddef,\n"
113 "\touter_rowid INTEGER NOT NULL REFERENCES compounddef\n"
114 ");"
115 },
116 /* TODO: Path can also share rowids with refid/compounddef/def. (It could
117 * even collapse into that table...)
118 *
119 * I took a first swing at this by changing insertPath() to:
120 * - accept a FileDef
121 * - make its own call to insertRefid
122 * - return a refid struct.
123 *
124 * I rolled this back when I had trouble getting a FileDef for all types
125 * (PageDef in particular).
126 *
127 * Note: all columns referencing path would need an update.
128 */
129 { "path",
130 "CREATE TABLE IF NOT EXISTS path (\n"
131 "\t-- Paths of source files and includes.\n"
132 "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
133 "\ttype INTEGER NOT NULL, -- 1:file 2:dir\n"
134 "\tlocal INTEGER NOT NULL,\n"
135 "\tfound INTEGER NOT NULL,\n"
136 "\tname TEXT NOT NULL\n"
137 ");"
138 },
139 { "refid",
140 "CREATE TABLE IF NOT EXISTS refid (\n"
141 "\t-- Distinct refid for all documented entities.\n"
142 "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
143 "\trefid TEXT NOT NULL UNIQUE\n"
144 ");"
145 },
146 { "xrefs",
147 "CREATE TABLE IF NOT EXISTS xrefs (\n"
148 "\t-- Cross-reference relation\n"
149 "\t-- (combines xml <referencedby> and <references> nodes).\n"
150 "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
151 "\tsrc_rowid INTEGER NOT NULL REFERENCES refid, -- referrer id.\n"
152 "\tdst_rowid INTEGER NOT NULL REFERENCES refid, -- referee id.\n"
153 "\tcontext TEXT NOT NULL, -- inline, argument, initializer\n"
154 "\t-- Just need to know they link; ignore duplicates.\n"
155 "\tUNIQUE(src_rowid, dst_rowid, context) ON CONFLICT IGNORE\n"
156 ");\n"
157 },
158 { "memberdef",
159 "CREATE TABLE IF NOT EXISTS memberdef (\n"
160 "\t-- All processed identifiers.\n"
161 "\trowid INTEGER PRIMARY KEY NOT NULL,\n"
162 "\tname TEXT NOT NULL,\n"
163 "\tdefinition TEXT,\n"
164 "\ttype TEXT,\n"
165 "\targsstring TEXT,\n"
166 "\tscope TEXT,\n"
167 "\tinitializer TEXT,\n"
168 "\tbitfield TEXT,\n"
169 "\tread TEXT,\n"
170 "\twrite TEXT,\n"
171 "\tprot INTEGER DEFAULT 0, -- 0:public 1:protected 2:private 3:package\n"
172 "\tstatic INTEGER DEFAULT 0, -- 0:no 1:yes\n"
173 "\textern INTEGER DEFAULT 0, -- 0:no 1:yes\n"
174 "\tconst INTEGER DEFAULT 0, -- 0:no 1:yes\n"
175 "\texplicit INTEGER DEFAULT 0, -- 0:no 1:yes\n"
176 "\tinline INTEGER DEFAULT 0, -- 0:no 1:yes 2:both (set after encountering inline and not-inline)\n"
177 "\tfinal INTEGER DEFAULT 0, -- 0:no 1:yes\n"
178 "\tsealed INTEGER DEFAULT 0, -- 0:no 1:yes\n"
179 "\tnew INTEGER DEFAULT 0, -- 0:no 1:yes\n"
180 "\toptional INTEGER DEFAULT 0, -- 0:no 1:yes\n"
181 "\trequired INTEGER DEFAULT 0, -- 0:no 1:yes\n"
182 "\tvolatile INTEGER DEFAULT 0, -- 0:no 1:yes\n"
183 "\tvirt INTEGER DEFAULT 0, -- 0:no 1:virtual 2:pure-virtual\n"
184 "\tmutable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
185 "\tthread_local INTEGER DEFAULT 0, -- 0:no 1:yes\n"
186 "\tinitonly INTEGER DEFAULT 0, -- 0:no 1:yes\n"
187 "\tattribute INTEGER DEFAULT 0, -- 0:no 1:yes\n"
188 "\tproperty INTEGER DEFAULT 0, -- 0:no 1:yes\n"
189 "\treadonly INTEGER DEFAULT 0, -- 0:no 1:yes\n"
190 "\tbound INTEGER DEFAULT 0, -- 0:no 1:yes\n"
191 "\tconstrained INTEGER DEFAULT 0, -- 0:no 1:yes\n"
192 "\ttransient INTEGER DEFAULT 0, -- 0:no 1:yes\n"
193 "\tmaybevoid INTEGER DEFAULT 0, -- 0:no 1:yes\n"
194 "\tmaybedefault INTEGER DEFAULT 0, -- 0:no 1:yes\n"
195 "\tmaybeambiguous INTEGER DEFAULT 0, -- 0:no 1:yes\n"
196 "\treadable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
197 "\twritable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
198 "\tgettable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
199 "\tprivategettable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
200 "\tprotectedgettable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
201 "\tsettable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
202 "\tprivatesettable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
203 "\tprotectedsettable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
204 "\taccessor INTEGER DEFAULT 0, -- 0:no 1:assign 2:copy 3:retain 4:string 5:weak\n"
205 "\taddable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
206 "\tremovable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
207 "\traisable INTEGER DEFAULT 0, -- 0:no 1:yes\n"
208 "\tkind TEXT NOT NULL, -- 'macro definition' 'function' 'variable' 'typedef' 'enumeration' 'enumvalue' 'signal' 'slot' 'friend' 'dcop' 'property' 'event' 'interface' 'service'\n"
209 "\tbodystart INTEGER DEFAULT 0, -- starting line of definition\n"
210 "\tbodyend INTEGER DEFAULT 0, -- ending line of definition\n"
211 "\tbodyfile_id INTEGER REFERENCES path, -- file of definition\n"
212 "\tfile_id INTEGER NOT NULL REFERENCES path, -- file where this identifier is located\n"
213 "\tline INTEGER NOT NULL, -- line where this identifier is located\n"
214 "\tcolumn INTEGER NOT NULL, -- column where this identifier is located\n"
215 "\tdetaileddescription TEXT,\n"
216 "\tbriefdescription TEXT,\n"
217 "\tinbodydescription TEXT,\n"
218 "\tFOREIGN KEY (rowid) REFERENCES refid (rowid)\n"
219 ");"
220 },
221 { "member",
222 "CREATE TABLE IF NOT EXISTS member (\n"
223 "\t-- Memberdef <-> containing compound relation.\n"
224 "\t-- Similar to XML listofallmembers.\n"
225 "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
226 "\tscope_rowid INTEGER NOT NULL REFERENCES compounddef,\n"
227 "\tmemberdef_rowid INTEGER NOT NULL REFERENCES memberdef,\n"
228 "\tprot INTEGER NOT NULL,\n"
229 "\tvirt INTEGER NOT NULL,\n"
230 "\tUNIQUE(scope_rowid, memberdef_rowid)\n"
231 ");"
232 },
233 { "reimplements",
234 "CREATE TABLE IF NOT EXISTS reimplements (\n"
235 "\t-- Inherited member reimplementation relations.\n"
236 "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
237 "\tmemberdef_rowid INTEGER NOT NULL REFERENCES memberdef, -- reimplementing memberdef id.\n"
238 "\treimplemented_rowid INTEGER NOT NULL REFERENCES memberdef, -- reimplemented memberdef id.\n"
239 "\tUNIQUE(memberdef_rowid, reimplemented_rowid) ON CONFLICT IGNORE\n"
240 ");\n"
241 },
242 { "compounddef",
243 "CREATE TABLE IF NOT EXISTS compounddef (\n"
244 "\t-- Class/struct definitions.\n"
245 "\trowid INTEGER PRIMARY KEY NOT NULL,\n"
246 "\tname TEXT NOT NULL,\n"
247 "\ttitle TEXT,\n"
248 // probably won't be empty '' or unknown, but the source *could* return them...
249 "\tkind TEXT NOT NULL, -- 'category' 'class' 'constants' 'dir' 'enum' 'example' 'exception' 'file' 'group' 'interface' 'library' 'module' 'namespace' 'package' 'page' 'protocol' 'record' 'service' 'singleton' 'struct' 'type' 'union' 'unknown' ''\n"
250 "\tprot INTEGER,\n"
251 "\tfile_id INTEGER NOT NULL REFERENCES path,\n"
252 "\tline INTEGER NOT NULL,\n"
253 "\tcolumn INTEGER NOT NULL,\n"
254 "\theader_id INTEGER REFERENCES path,\n"
255 "\tfinal INTEGER, -- 0:no 1:yes\n"
256 "\tsealed INTEGER, -- 0:no 1:yes\n"
257 "\tabstract INTEGER, -- 0:no 1:yes\n"
258 "\tref INTEGER, -- 0:no 1:yes\n"
259 "\tdetaileddescription TEXT,\n"
260 "\tbriefdescription TEXT,\n"
261 "\tFOREIGN KEY (rowid) REFERENCES refid (rowid)\n"
262 ");"
263 },
264 { "compoundref",
265 "CREATE TABLE IF NOT EXISTS compoundref (\n"
266 "\t-- Inheritance relation.\n"
267 "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
268 "\tbase_rowid INTEGER NOT NULL REFERENCES compounddef,\n"
269 "\tderived_rowid INTEGER NOT NULL REFERENCES compounddef,\n"
270 "\tprot INTEGER NOT NULL,\n"
271 "\tvirt INTEGER NOT NULL,\n"
272 "\tUNIQUE(base_rowid, derived_rowid)\n"
273 ");"
274 },
275 { "param",
276 "CREATE TABLE IF NOT EXISTS param (\n"
277 "\t-- All processed parameters.\n"
278 "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
279 "\tattributes TEXT,\n"
280 "\ttype TEXT,\n"
281 "\tdeclname TEXT,\n"
282 "\tdefname TEXT,\n"
283 "\tarray TEXT,\n"
284 "\tdefval TEXT,\n"
285 "\ttypeconstraint TEXT,\n"
286 "\tbriefdescription TEXT\n"
287 ");"
288 "CREATE UNIQUE INDEX idx_param ON param\n"
289 "\t(type, defname);"
290 },
291 { "memberdef_param",
292 "CREATE TABLE IF NOT EXISTS memberdef_param (\n"
293 "\t-- Junction table for memberdef parameters.\n"
294 "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
295 "\tmemberdef_id INTEGER NOT NULL REFERENCES memberdef,\n"
296 "\tparam_id INTEGER NOT NULL REFERENCES param\n"
297 ");"
298 },
299};
300 const char * view_schema[][2] = {
301 /* VIEWS *
302 We'll set these up AFTER we build the database, so that they can be indexed,
303 but so we don't have to pay a performance penalty for inserts as we build.
304 */
305 {
306 /*
307 Makes all reference/relation tables easier to use. For example:
308 1. query xrefs and join this view on either xrefs.dst_rowid=def.rowid or
309 xrefs.src_rowid=def.rowid
310 2. get everything you need to output a list of references to/from an entity
311
312 Also supports simple name search/lookup for both compound and member types.
313
314 NOTES:
315 - summary for compounds generalizes title and briefdescription because
316 there's no single field that works as a quick introduction for both
317 pages and classes
318 - May be value in eventually extending this to fulltext or levenshtein
319 distance-driven lookup/search, but I'm avoiding these for now as it
320 takes some effort to enable them.
321 */
322 "def",
323 "CREATE VIEW IF NOT EXISTS def (\n"
324 "\t-- Combined summary of all -def types for easier joins.\n"
325 "\trowid,\n"
326 "\trefid,\n"
327 "\tkind,\n"
328 "\tname,\n"
329 "\tsummary"
330 ")\n"
331 "as SELECT \n"
332 "\trefid.rowid,\n"
333 "\trefid.refid,\n"
334 "\tmemberdef.kind,\n"
335 "\tmemberdef.name,\n"
336 "\tmemberdef.briefdescription \n"
337 "FROM refid \n"
338 "JOIN memberdef ON refid.rowid=memberdef.rowid \n"
339 "UNION ALL \n"
340 "SELECT \n"
341 "\trefid.rowid,\n"
342 "\trefid.refid,\n"
343 "\tcompounddef.kind,\n"
344 "\tcompounddef.name,\n"
345 "\tCASE \n"
346 "\t\tWHEN briefdescription IS NOT NULL \n"
347 "\t\tTHEN briefdescription \n"
348 "\t\tELSE title \n"
349 "\tEND summary\n"
350 "FROM refid \n"
351 "JOIN compounddef ON refid.rowid=compounddef.rowid;"
352 },
353 {
354 "local_file",
355 "CREATE VIEW IF NOT EXISTS local_file (\n"
356 "\t-- File paths found within the project.\n"
357 "\trowid,\n"
358 "\tfound,\n"
359 "\tname\n"
360 ")\n"
361 "as SELECT \n"
362 "\tpath.rowid,\n"
363 "\tpath.found,\n"
364 "\tpath.name\n"
365 "FROM path WHERE path.type=1 AND path.local=1 AND path.found=1;\n"
366 },
367 {
368 "external_file",
369 "CREATE VIEW IF NOT EXISTS external_file (\n"
370 "\t-- File paths outside the project (found or not).\n"
371 "\trowid,\n"
372 "\tfound,\n"
373 "\tname\n"
374 ")\n"
375 "as SELECT \n"
376 "\tpath.rowid,\n"
377 "\tpath.found,\n"
378 "\tpath.name\n"
379 "FROM path WHERE path.type=1 AND path.local=0;\n"
380 },
381 {
382 "inline_xrefs",
383 "CREATE VIEW IF NOT EXISTS inline_xrefs (\n"
384 "\t-- Crossrefs from inline member source.\n"
385 "\trowid,\n"
386 "\tsrc_rowid,\n"
387 "\tdst_rowid\n"
388 ")\n"
389 "as SELECT \n"
390 "\txrefs.rowid,\n"
391 "\txrefs.src_rowid,\n"
392 "\txrefs.dst_rowid\n"
393 "FROM xrefs WHERE xrefs.context='inline';\n"
394 },
395 {
396 "argument_xrefs",
397 "CREATE VIEW IF NOT EXISTS argument_xrefs (\n"
398 "\t-- Crossrefs from member def/decl arguments\n"
399 "\trowid,\n"
400 "\tsrc_rowid,\n"
401 "\tdst_rowid\n"
402 ")\n"
403 "as SELECT \n"
404 "\txrefs.rowid,\n"
405 "\txrefs.src_rowid,\n"
406 "\txrefs.dst_rowid\n"
407 "FROM xrefs WHERE xrefs.context='argument';\n"
408 },
409 {
410 "initializer_xrefs",
411 "CREATE VIEW IF NOT EXISTS initializer_xrefs (\n"
412 "\t-- Crossrefs from member initializers\n"
413 "\trowid,\n"
414 "\tsrc_rowid,\n"
415 "\tdst_rowid\n"
416 ")\n"
417 "as SELECT \n"
418 "\txrefs.rowid,\n"
419 "\txrefs.src_rowid,\n"
420 "\txrefs.dst_rowid\n"
421 "FROM xrefs WHERE xrefs.context='initializer';\n"
422 },
423 {
424 "inner_outer",
425 "CREATE VIEW IF NOT EXISTS inner_outer\n"
426 "\t-- Joins 'contains' relations to simplify inner/outer 'rel' queries.\n"
427 "as SELECT \n"
428 "\tinner.*,\n"
429 "\touter.*\n"
430 "FROM def as inner\n"
431 "\tJOIN contains ON inner.rowid=contains.inner_rowid\n"
432 "\tJOIN def AS outer ON outer.rowid=contains.outer_rowid;\n"
433 },
434 {
435 "rel",
436 "CREATE VIEW IF NOT EXISTS rel (\n"
437 "\t-- Boolean indicator of relations available for a given entity.\n"
438 "\t-- Join to (compound-|member-)def to find fetch-worthy relations.\n"
439 "\trowid,\n"
440 "\treimplemented,\n"
441 "\treimplements,\n"
442 "\tinnercompounds,\n"
443 "\toutercompounds,\n"
444 "\tinnerpages,\n"
445 "\touterpages,\n"
446 "\tinnerdirs,\n"
447 "\touterdirs,\n"
448 "\tinnerfiles,\n"
449 "\touterfiles,\n"
450 "\tinnerclasses,\n"
451 "\touterclasses,\n"
452 "\tinnernamespaces,\n"
453 "\touternamespaces,\n"
454 "\tinnergroups,\n"
455 "\toutergroups,\n"
456 "\tmembers,\n"
457 "\tcompounds,\n"
458 "\tsubclasses,\n"
459 "\tsuperclasses,\n"
460 "\tlinks_in,\n"
461 "\tlinks_out,\n"
462 "\targument_links_in,\n"
463 "\targument_links_out,\n"
464 "\tinitializer_links_in,\n"
465 "\tinitializer_links_out\n"
466 ")\n"
467 "as SELECT \n"
468 "\tdef.rowid,\n"
469 "\tEXISTS (SELECT rowid FROM reimplements WHERE reimplemented_rowid=def.rowid),\n"
470 "\tEXISTS (SELECT rowid FROM reimplements WHERE memberdef_rowid=def.rowid),\n"
471 "\t-- rowid/kind for inner, [rowid:1/kind:1] for outer\n"
472 "\tEXISTS (SELECT * FROM inner_outer WHERE [rowid:1]=def.rowid),\n"
473 "\tEXISTS (SELECT * FROM inner_outer WHERE rowid=def.rowid),\n"
474 "\tEXISTS (SELECT * FROM inner_outer WHERE [rowid:1]=def.rowid AND kind='page'),\n"
475 "\tEXISTS (SELECT * FROM inner_outer WHERE rowid=def.rowid AND [kind:1]='page'),\n"
476 "\tEXISTS (SELECT * FROM inner_outer WHERE [rowid:1]=def.rowid AND kind='dir'),\n"
477 "\tEXISTS (SELECT * FROM inner_outer WHERE rowid=def.rowid AND [kind:1]='dir'),\n"
478 "\tEXISTS (SELECT * FROM inner_outer WHERE [rowid:1]=def.rowid AND kind='file'),\n"
479 "\tEXISTS (SELECT * FROM inner_outer WHERE rowid=def.rowid AND [kind:1]='file'),\n"
480 "\tEXISTS (SELECT * FROM inner_outer WHERE [rowid:1]=def.rowid AND kind in (\n"
481 "'category','class','enum','exception','interface','module','protocol',\n"
482 "'record','service','singleton','struct','type','union'\n"
483 ")),\n"
484 "\tEXISTS (SELECT * FROM inner_outer WHERE rowid=def.rowid AND [kind:1] in (\n"
485 "'category','class','enum','exception','interface','module','protocol',\n"
486 "'record','service','singleton','struct','type','union'\n"
487 ")),\n"
488 "\tEXISTS (SELECT * FROM inner_outer WHERE [rowid:1]=def.rowid AND kind='namespace'),\n"
489 "\tEXISTS (SELECT * FROM inner_outer WHERE rowid=def.rowid AND [kind:1]='namespace'),\n"
490 "\tEXISTS (SELECT * FROM inner_outer WHERE [rowid:1]=def.rowid AND kind='group'),\n"
491 "\tEXISTS (SELECT * FROM inner_outer WHERE rowid=def.rowid AND [kind:1]='group'),\n"
492 "\tEXISTS (SELECT rowid FROM member WHERE scope_rowid=def.rowid),\n"
493 "\tEXISTS (SELECT rowid FROM member WHERE memberdef_rowid=def.rowid),\n"
494 "\tEXISTS (SELECT rowid FROM compoundref WHERE base_rowid=def.rowid),\n"
495 "\tEXISTS (SELECT rowid FROM compoundref WHERE derived_rowid=def.rowid),\n"
496 "\tEXISTS (SELECT rowid FROM inline_xrefs WHERE dst_rowid=def.rowid),\n"
497 "\tEXISTS (SELECT rowid FROM inline_xrefs WHERE src_rowid=def.rowid),\n"
498 "\tEXISTS (SELECT rowid FROM argument_xrefs WHERE dst_rowid=def.rowid),\n"
499 "\tEXISTS (SELECT rowid FROM argument_xrefs WHERE src_rowid=def.rowid),\n"
500 "\tEXISTS (SELECT rowid FROM initializer_xrefs WHERE dst_rowid=def.rowid),\n"
501 "\tEXISTS (SELECT rowid FROM initializer_xrefs WHERE src_rowid=def.rowid)\n"
502 "FROM def ORDER BY def.rowid;"
503 }
504};
505
506//////////////////////////////////////////////////////
507struct SqlStmt {
508 const char *query = nullptr;
509 sqlite3_stmt *stmt = nullptr;
510 sqlite3 *db = nullptr;
511};
512//////////////////////////////////////////////////////
513/* If you add a new statement below, make sure to add it to
514 prepareStatements(). If sqlite3 is segfaulting (especially in
515 sqlite3_clear_bindings()), using an un-prepared statement may
516 be the cause. */
518 "INSERT INTO meta "
519 "( doxygen_version, schema_version, generated_at, generated_on, project_name, project_number, project_brief )"
520 "VALUES "
521 "(:doxygen_version,:schema_version,:generated_at,:generated_on,:project_name,:project_number,:project_brief )"
522 ,nullptr
523};
524//////////////////////////////////////////////////////
526 "INSERT INTO includes "
527 "( local, src_id, dst_id ) "
528 "VALUES "
529 "(:local,:src_id,:dst_id )"
530 ,nullptr
531};
533 "SELECT COUNT(*) FROM includes WHERE "
534 "local=:local AND src_id=:src_id AND dst_id=:dst_id"
535 ,nullptr
536};
537//////////////////////////////////////////////////////
539 "INSERT INTO contains "
540 "( inner_rowid, outer_rowid )"
541 "VALUES "
542 "(:inner_rowid,:outer_rowid )"
543 ,nullptr
544};
545//////////////////////////////////////////////////////
547 "SELECT rowid FROM path WHERE name=:name"
548 ,nullptr
549};
551 "INSERT INTO path "
552 "( type, local, found, name )"
553 "VALUES "
554 "(:type,:local,:found,:name )"
555 ,nullptr
556};
557//////////////////////////////////////////////////////
559 "SELECT rowid FROM refid WHERE refid=:refid"
560 ,nullptr
561};
563 "INSERT INTO refid "
564 "( refid )"
565 "VALUES "
566 "(:refid )"
567 ,nullptr
568};
569//////////////////////////////////////////////////////
571 "INSERT INTO xrefs "
572 "( src_rowid, dst_rowid, context )"
573 "VALUES "
574 "(:src_rowid,:dst_rowid,:context )"
575 ,nullptr
576};//////////////////////////////////////////////////////
578 "INSERT INTO reimplements "
579 "( memberdef_rowid, reimplemented_rowid )"
580 "VALUES "
581 "(:memberdef_rowid,:reimplemented_rowid )"
582 ,nullptr
583};
584//////////////////////////////////////////////////////
586 "SELECT EXISTS (SELECT * FROM memberdef WHERE rowid = :rowid)"
587 ,nullptr
588};
589
591 "SELECT EXISTS ("
592 "SELECT * FROM memberdef WHERE "
593 "rowid = :rowid AND inline != 2 AND inline != :new_inline"
594 ")"
595 ,nullptr
596};
597
599 "INSERT INTO memberdef "
600 "("
601 "rowid,"
602 "name,"
603 "definition,"
604 "type,"
605 "argsstring,"
606 "scope,"
607 "initializer,"
608 "bitfield,"
609 "read,"
610 "write,"
611 "prot,"
612 "static,"
613 "extern,"
614 "const,"
615 "explicit,"
616 "inline,"
617 "final,"
618 "sealed,"
619 "new,"
620 "optional,"
621 "required,"
622 "volatile,"
623 "virt,"
624 "mutable,"
625 "thread_local,"
626 "initonly,"
627 "attribute,"
628 "property,"
629 "readonly,"
630 "bound,"
631 "constrained,"
632 "transient,"
633 "maybevoid,"
634 "maybedefault,"
635 "maybeambiguous,"
636 "readable,"
637 "writable,"
638 "gettable,"
639 "protectedsettable,"
640 "protectedgettable,"
641 "settable,"
642 "privatesettable,"
643 "privategettable,"
644 "accessor,"
645 "addable,"
646 "removable,"
647 "raisable,"
648 "kind,"
649 "bodystart,"
650 "bodyend,"
651 "bodyfile_id,"
652 "file_id,"
653 "line,"
654 "column,"
655 "detaileddescription,"
656 "briefdescription,"
657 "inbodydescription"
658 ")"
659 "VALUES "
660 "("
661 ":rowid,"
662 ":name,"
663 ":definition,"
664 ":type,"
665 ":argsstring,"
666 ":scope,"
667 ":initializer,"
668 ":bitfield,"
669 ":read,"
670 ":write,"
671 ":prot,"
672 ":static,"
673 ":extern,"
674 ":const,"
675 ":explicit,"
676 ":inline,"
677 ":final,"
678 ":sealed,"
679 ":new,"
680 ":optional,"
681 ":required,"
682 ":volatile,"
683 ":virt,"
684 ":mutable,"
685 ":thread_local,"
686 ":initonly,"
687 ":attribute,"
688 ":property,"
689 ":readonly,"
690 ":bound,"
691 ":constrained,"
692 ":transient,"
693 ":maybevoid,"
694 ":maybedefault,"
695 ":maybeambiguous,"
696 ":readable,"
697 ":writable,"
698 ":gettable,"
699 ":protectedsettable,"
700 ":protectedgettable,"
701 ":settable,"
702 ":privatesettable,"
703 ":privategettable,"
704 ":accessor,"
705 ":addable,"
706 ":removable,"
707 ":raisable,"
708 ":kind,"
709 ":bodystart,"
710 ":bodyend,"
711 ":bodyfile_id,"
712 ":file_id,"
713 ":line,"
714 ":column,"
715 ":detaileddescription,"
716 ":briefdescription,"
717 ":inbodydescription"
718 ")"
719 ,nullptr
720};
721/*
722We have a slightly different need than the XML here. The XML can have two
723memberdef nodes with the same refid to document the declaration and the
724definition. This doesn't play very nice with a referential model. It isn't a
725big issue if only one is documented, but in case both are, we'll fall back on
726this kludge to combine them in a single row...
727*/
729 "UPDATE memberdef SET "
730 "inline = :inline,"
731 "file_id = :file_id,"
732 "line = :line,"
733 "column = :column,"
734 "detaileddescription = 'Declaration: ' || :detaileddescription || 'Definition: ' || detaileddescription,"
735 "briefdescription = 'Declaration: ' || :briefdescription || 'Definition: ' || briefdescription,"
736 "inbodydescription = 'Declaration: ' || :inbodydescription || 'Definition: ' || inbodydescription "
737 "WHERE rowid = :rowid"
738 ,nullptr
739};
741 "UPDATE memberdef SET "
742 "inline = :inline,"
743 "bodystart = :bodystart,"
744 "bodyend = :bodyend,"
745 "bodyfile_id = :bodyfile_id,"
746 "detaileddescription = 'Declaration: ' || detaileddescription || 'Definition: ' || :detaileddescription,"
747 "briefdescription = 'Declaration: ' || briefdescription || 'Definition: ' || :briefdescription,"
748 "inbodydescription = 'Declaration: ' || inbodydescription || 'Definition: ' || :inbodydescription "
749 "WHERE rowid = :rowid"
750 ,nullptr
751};
752//////////////////////////////////////////////////////
754 "INSERT INTO member "
755 "( scope_rowid, memberdef_rowid, prot, virt ) "
756 "VALUES "
757 "(:scope_rowid,:memberdef_rowid,:prot,:virt )"
758 ,nullptr
759};
760//////////////////////////////////////////////////////
762 "INSERT INTO compounddef "
763 "("
764 "rowid,"
765 "name,"
766 "title,"
767 "kind,"
768 "prot,"
769 "file_id,"
770 "line,"
771 "column,"
772 "header_id,"
773 "final,"
774 "sealed,"
775 "abstract,"
776 "ref,"
777 "briefdescription,"
778 "detaileddescription"
779 ")"
780 "VALUES "
781 "("
782 ":rowid,"
783 ":name,"
784 ":title,"
785 ":kind,"
786 ":prot,"
787 ":file_id,"
788 ":line,"
789 ":column,"
790 ":header_id,"
791 ":final,"
792 ":sealed,"
793 ":abstract,"
794 ":ref,"
795 ":briefdescription,"
796 ":detaileddescription"
797 ")"
798 ,nullptr
799};
801 "SELECT EXISTS ("
802 "SELECT * FROM compounddef WHERE rowid = :rowid"
803 ")"
804 ,nullptr
805};
806//////////////////////////////////////////////////////
808 "INSERT INTO compoundref "
809 "( base_rowid, derived_rowid, prot, virt ) "
810 "VALUES "
811 "(:base_rowid,:derived_rowid,:prot,:virt )"
812 ,nullptr
813};
814//////////////////////////////////////////////////////
816 "SELECT rowid FROM param WHERE "
817 "(attributes IS NULL OR attributes=:attributes) AND "
818 "(type IS NULL OR type=:type) AND "
819 "(declname IS NULL OR declname=:declname) AND "
820 "(defname IS NULL OR defname=:defname) AND "
821 "(array IS NULL OR array=:array) AND "
822 "(defval IS NULL OR defval=:defval) AND "
823 "typeconstraint IS :typeconstraint AND "
824 "(briefdescription IS NULL OR briefdescription=:briefdescription)"
825 ,nullptr
826};
828 "INSERT INTO param "
829 "( attributes, type, declname, defname, array, defval, typeconstraint, briefdescription ) "
830 "VALUES "
831 "(:attributes,:type,:declname,:defname,:array,:defval,:typeconstraint,:briefdescription)"
832 ,nullptr
833};
834//////////////////////////////////////////////////////
836 "INSERT INTO memberdef_param "
837 "( memberdef_id, param_id)"
838 "VALUES "
839 "(:memberdef_id,:param_id)"
840 ,nullptr
841};
842
844{
845 public:
847 void writeString(std::string_view /*s*/,bool /*keepSpaces*/) const override
848 {
849 }
850 void writeBreak(int) const override
851 {
852 DBG_CTX(("writeBreak\n"));
853 }
854 void writeLink(const DString & /*extRef*/,const DString &file,
855 const DString &anchor,std::string_view /*text*/
856 ) const override
857 {
858 std::string rs = file.str();
859 if (!anchor.empty())
860 {
861 rs+="_1";
862 rs+=anchor.str();
863 }
864 m_list.push_back(rs);
865 }
866 private:
868 // the list is filled by linkifyText and consumed by the caller
869};
870
871
872static bool bindTextParameter(SqlStmt &s,const char *name,const DString &value)
873{
874 int idx = sqlite3_bind_parameter_index(s.stmt, name);
875 if (idx==0) {
876 err("sqlite3_bind_parameter_index({})[{}] failed: {}\n", name, s.query, sqlite3_errmsg(s.db));
877 return false;
878 }
879 int rv = sqlite3_bind_text(s.stmt, idx, value.data(), -1, SQLITE_TRANSIENT);
880 if (rv!=SQLITE_OK) {
881 err("sqlite3_bind_text({})[{}] failed: {}\n", name, s.query, sqlite3_errmsg(s.db));
882 return false;
883 }
884 return true;
885}
886
887static bool bindIntParameter(SqlStmt &s,const char *name,int value)
888{
889 int idx = sqlite3_bind_parameter_index(s.stmt, name);
890 if (idx==0) {
891 err("sqlite3_bind_parameter_index({})[{}] failed to find column: {}\n", name, s.query, sqlite3_errmsg(s.db));
892 return false;
893 }
894 int rv = sqlite3_bind_int(s.stmt, idx, value);
895 if (rv!=SQLITE_OK) {
896 err("sqlite3_bind_int({})[{}] failed: {}\n", name, s.query, sqlite3_errmsg(s.db));
897 return false;
898 }
899 return true;
900}
901
902static bool bindIntParameter(SqlStmt &s,const char *name,size_t value)
903{
904 return bindIntParameter(s,name,static_cast<int>(value));
905}
906
907static int step(SqlStmt &s,bool getRowId=false, bool select=false)
908{
909 int rowid=-1;
910 int rc = sqlite3_step(s.stmt);
911 if (rc!=SQLITE_DONE && rc!=SQLITE_ROW)
912 {
913 DBG_CTX(("sqlite3_step: %s (rc: %d)\n", sqlite3_errmsg(s.db), rc));
914 sqlite3_reset(s.stmt);
915 sqlite3_clear_bindings(s.stmt);
916 return -1;
917 }
918 if (getRowId && select) rowid = sqlite3_column_int(s.stmt, 0); // works on selects, doesn't on inserts
919 if (getRowId && !select) rowid = static_cast<int>(sqlite3_last_insert_rowid(s.db)); //works on inserts, doesn't on selects
920 sqlite3_reset(s.stmt);
921 sqlite3_clear_bindings(s.stmt); // XXX When should this really be called
922 return rowid;
923}
924
925static int insertPath(DString name, bool local=true, bool found=true, int type=1)
926{
927 int rowid=-1;
928 if (name==nullptr) return rowid;
929
930 name = stripFromPath(name);
931
932 bindTextParameter(path_select,":name",name.data());
933 rowid=step(path_select,true,true);
934 if (rowid==0)
935 {
936 bindTextParameter(path_insert,":name",name.data());
937 bindIntParameter(path_insert,":type",type);
938 bindIntParameter(path_insert,":local",local?1:0);
939 bindIntParameter(path_insert,":found",found?1:0);
940 rowid=step(path_insert,true);
941 }
942 return rowid;
943}
944
945static void recordMetadata()
946{
947 bindTextParameter(meta_insert,":doxygen_version",getFullVersion());
948 bindTextParameter(meta_insert,":schema_version","0.2.1"); //TODO: this should be a constant somewhere; not sure where
951 bindTextParameter(meta_insert,":project_name",Config_getString(PROJECT_NAME));
952 bindTextParameter(meta_insert,":project_number",Config_getString(PROJECT_NUMBER));
953 bindTextParameter(meta_insert,":project_brief",Config_getString(PROJECT_BRIEF));
955}
956
957struct Refid {
958 int rowid;
961};
962
964{
965 Refid ret;
966 ret.rowid=-1;
967 ret.refid=refid;
968 ret.created = false;
969 if (refid.empty()) return ret;
970
972 ret.rowid=step(refid_select,true,true);
973 if (ret.rowid==0)
974 {
976 ret.rowid=step(refid_insert,true);
977 ret.created = true;
978 }
979
980 return ret;
981}
982
983static bool memberdefExists(struct Refid refid)
984{
986 int test = step(memberdef_exists,true,true);
987 return test ? true : false;
988}
989
990static bool memberdefIncomplete(struct Refid refid, const MemberDef* md)
991{
994 int test = step(memberdef_incomplete,true,true);
995 return test ? true : false;
996}
997
998static bool compounddefExists(struct Refid refid)
999{
1001 int test = step(compounddef_exists,true,true);
1002 return test ? true : false;
1003}
1004
1005static bool insertMemberReference(struct Refid src_refid, struct Refid dst_refid, const char *context)
1006{
1007 if (src_refid.rowid==-1||dst_refid.rowid==-1)
1008 return false;
1009
1010 if (
1011 !bindIntParameter(xrefs_insert,":src_rowid",src_refid.rowid) ||
1012 !bindIntParameter(xrefs_insert,":dst_rowid",dst_refid.rowid)
1013 )
1014 {
1015 return false;
1016 }
1017 else
1018 {
1019 bindTextParameter(xrefs_insert,":context",context);
1020 }
1021
1023 return true;
1024}
1025
1026static void insertMemberReference(const MemberDef *src, const MemberDef *dst, const char *context)
1027{
1028 DString qdst_refid = dst->getOutputFileBase() + "_1" + dst->anchor();
1029 DString qsrc_refid = src->getOutputFileBase() + "_1" + src->anchor();
1030
1031 struct Refid src_refid = insertRefid(qsrc_refid);
1032 struct Refid dst_refid = insertRefid(qdst_refid);
1033 insertMemberReference(src_refid,dst_refid,context);
1034}
1035
1036static void insertMemberFunctionParams(int memberdef_id, const MemberDef *md, const Definition *def)
1037{
1038 LinkifyTextOptions options;
1039 options.setScope(def).setFileScope(md->getBodyDef()).setSelf(md);
1040 const ArgumentList &declAl = md->declArgumentList();
1041 const ArgumentList &defAl = md->argumentList();
1042 if (declAl.size()>0)
1043 {
1044 auto defIt = defAl.begin();
1045 for (const Argument &a : declAl)
1046 {
1047 //const Argument *defArg = defAli.current();
1048 const Argument *defArg = nullptr;
1049 if (defIt!=defAl.end())
1050 {
1051 defArg = &(*defIt);
1052 ++defIt;
1053 }
1054
1055 if (!a.attrib.empty())
1056 {
1057 bindTextParameter(param_select,":attributes",a.attrib);
1058 bindTextParameter(param_insert,":attributes",a.attrib);
1059 }
1060 if (!a.type.empty())
1061 {
1062 StringVector list;
1063 linkifyText(TextGeneratorSqlite3Impl(list),a.type,options);
1064
1065 for (const auto &s : list)
1066 {
1067 DString qsrc_refid = md->getOutputFileBase() + "_1" + md->anchor();
1068 struct Refid src_refid = insertRefid(qsrc_refid);
1069 struct Refid dst_refid = insertRefid(s);
1070 insertMemberReference(src_refid,dst_refid, "argument");
1071 }
1072 bindTextParameter(param_select,":type",a.type);
1073 bindTextParameter(param_insert,":type",a.type);
1074 }
1075 if (!a.name.empty())
1076 {
1077 bindTextParameter(param_select,":declname",a.name);
1078 bindTextParameter(param_insert,":declname",a.name);
1079 }
1080 if (defArg && !defArg->name.empty() && defArg->name!=a.name)
1081 {
1082 bindTextParameter(param_select,":defname",defArg->name);
1083 bindTextParameter(param_insert,":defname",defArg->name);
1084 }
1085 if (!a.array.empty())
1086 {
1087 bindTextParameter(param_select,":array",a.array);
1088 bindTextParameter(param_insert,":array",a.array);
1089 }
1090 if (!a.defval.empty())
1091 {
1092 StringVector list;
1093 linkifyText(TextGeneratorSqlite3Impl(list),a.defval,options);
1094 bindTextParameter(param_select,":defval",a.defval);
1095 bindTextParameter(param_insert,":defval",a.defval);
1096 }
1097
1098 int param_id=step(param_select,true,true);
1099 if (param_id==0) {
1100 param_id=step(param_insert,true);
1101 }
1102 if (param_id==-1) {
1103 DBG_CTX(("error INSERT params failed\n"));
1104 continue;
1105 }
1106
1107 bindIntParameter(memberdef_param_insert,":memberdef_id",memberdef_id);
1108 bindIntParameter(memberdef_param_insert,":param_id",param_id);
1110 }
1111 }
1112}
1113
1114static void insertMemberDefineParams(int memberdef_id,const MemberDef *md, const Definition *def)
1115{
1116 if (md->argumentList().empty()) // special case for "foo()" to
1117 // distinguish it from "foo".
1118 {
1119 DBG_CTX(("no params\n"));
1120 }
1121 else
1122 {
1123 for (const Argument &a : md->argumentList())
1124 {
1125 bindTextParameter(param_insert,":defname",a.type);
1126 int param_id=step(param_insert,true);
1127 if (param_id==-1) {
1128 continue;
1129 }
1130
1131 bindIntParameter(memberdef_param_insert,":memberdef_id",memberdef_id);
1132 bindIntParameter(memberdef_param_insert,":param_id",param_id);
1134 }
1135 }
1136}
1137
1138static void associateMember(const MemberDef *md, struct Refid member_refid, struct Refid scope_refid)
1139{
1140 // TODO: skip EnumValue only to guard against recording refids and member records
1141 // for enumvalues until we can support documenting them as entities.
1142 if (md->memberType()==MemberType::EnumValue) return;
1143 if (!md->isAnonymous()) // skip anonymous members
1144 {
1145 bindIntParameter(member_insert, ":scope_rowid", scope_refid.rowid);
1146 bindIntParameter(member_insert, ":memberdef_rowid", member_refid.rowid);
1147
1148 bindIntParameter(member_insert, ":prot", static_cast<int>(md->protection()));
1149 bindIntParameter(member_insert, ":virt", static_cast<int>(md->virtualness()));
1151 }
1152}
1153
1154static void stripQualifiers(DString &typeStr)
1155{
1156 bool done=false;
1157 while (!done)
1158 {
1159 if (typeStr.stripPrefix("static "));
1160 else if (typeStr.stripPrefix("virtual "));
1161 else if (typeStr=="virtual") typeStr="";
1162 else done=true;
1163 }
1164}
1165
1166static int prepareStatement(sqlite3 *db, SqlStmt &s)
1167{
1168 int rc = sqlite3_prepare_v2(db,s.query,-1,&s.stmt,nullptr);
1169 if (rc!=SQLITE_OK)
1170 {
1171 err("prepare failed for:\n {}\n {}\n", s.query, sqlite3_errmsg(db));
1172 s.db = nullptr;
1173 return -1;
1174 }
1175 s.db = db;
1176 return rc;
1177}
1178
1179static int prepareStatements(sqlite3 *db)
1180{
1181 if (
1182 -1==prepareStatement(db, meta_insert) ||
1189 -1==prepareStatement(db, path_insert) ||
1190 -1==prepareStatement(db, path_select) ||
1191 -1==prepareStatement(db, refid_insert) ||
1192 -1==prepareStatement(db, refid_select) ||
1193 -1==prepareStatement(db, incl_insert)||
1194 -1==prepareStatement(db, incl_select)||
1195 -1==prepareStatement(db, param_insert) ||
1196 -1==prepareStatement(db, param_select) ||
1197 -1==prepareStatement(db, xrefs_insert) ||
1204 )
1205 {
1206 return -1;
1207 }
1208 return 0;
1209}
1210
1211static void beginTransaction(sqlite3 *db)
1212{
1213 char * sErrMsg = nullptr;
1214 sqlite3_exec(db, "BEGIN TRANSACTION", nullptr, nullptr, &sErrMsg);
1215}
1216
1217static void endTransaction(sqlite3 *db)
1218{
1219 char * sErrMsg = nullptr;
1220 sqlite3_exec(db, "END TRANSACTION", nullptr, nullptr, &sErrMsg);
1221}
1222
1223static void pragmaTuning(sqlite3 *db)
1224{
1225 char * sErrMsg = nullptr;
1226 sqlite3_exec(db, "PRAGMA synchronous = OFF", nullptr, nullptr, &sErrMsg);
1227 sqlite3_exec(db, "PRAGMA journal_mode = MEMORY", nullptr, nullptr, &sErrMsg);
1228 sqlite3_exec(db, "PRAGMA temp_store = MEMORY;", nullptr, nullptr, &sErrMsg);
1229}
1230
1231static int initializeTables(sqlite3* db)
1232{
1233 msg("Initializing DB schema (tables)...\n");
1234 for (unsigned int k = 0; k < sizeof(table_schema) / sizeof(table_schema[0]); k++)
1235 {
1236 const char *q = table_schema[k][1];
1237 char *errmsg = nullptr;
1238 int rc = sqlite3_exec(db, q, nullptr, nullptr, &errmsg);
1239 if (rc != SQLITE_OK)
1240 {
1241 err("failed to execute query: {}\n\t{}\n", q, errmsg);
1242 return -1;
1243 }
1244 }
1245 return 0;
1246}
1247
1248static int initializeViews(sqlite3* db)
1249{
1250 msg("Initializing DB schema (views)...\n");
1251 for (unsigned int k = 0; k < sizeof(view_schema) / sizeof(view_schema[0]); k++)
1252 {
1253 const char *q = view_schema[k][1];
1254 char *errmsg = nullptr;
1255 int rc = sqlite3_exec(db, q, nullptr, nullptr, &errmsg);
1256 if (rc != SQLITE_OK)
1257 {
1258 err("failed to execute query: {}\n\t{}\n", q, errmsg);
1259 return -1;
1260 }
1261 }
1262 return 0;
1263}
1264
1265////////////////////////////////////////////
1266/* TODO:
1267I collapsed all innerX tables into 'contains', which raises the prospect that
1268all of these very similar writeInnerX funcs could be refactored into a one,
1269or a small set of common parts.
1270
1271I think the hurdles are:
1272- picking a first argument that every call location can pass
1273- which yields a consistent iterator
1274- accommodates PageDef's slightly different rules for generating the
1275 inner_refid (unless I'm missing a method that would uniformly return
1276 the correct refid for all types).
1277*/
1278static void writeInnerClasses(const ClassLinkedRefMap &cl, struct Refid outer_refid)
1279{
1280 for (const auto &cd : cl)
1281 {
1282 if (!cd->isHidden() && !cd->isAnonymous())
1283 {
1284 struct Refid inner_refid = insertRefid(cd->getOutputFileBase());
1285
1286 bindIntParameter(contains_insert,":inner_rowid", inner_refid.rowid);
1287 bindIntParameter(contains_insert,":outer_rowid", outer_refid.rowid);
1289 }
1290 }
1291}
1292
1293static void writeInnerConcepts(const ConceptLinkedRefMap &cl, struct Refid outer_refid)
1294{
1295 for (const auto &cd : cl)
1296 {
1297 struct Refid inner_refid = insertRefid(cd->getOutputFileBase());
1298
1299 bindIntParameter(contains_insert,":inner_rowid", inner_refid.rowid);
1300 bindIntParameter(contains_insert,":outer_rowid", outer_refid.rowid);
1302 }
1303}
1304
1305static void writeInnerModules(const ModuleLinkedRefMap &ml, struct Refid outer_refid)
1306{
1307 for (const auto &mod : ml)
1308 {
1309 struct Refid inner_refid = insertRefid(mod->getOutputFileBase());
1310
1311 bindIntParameter(contains_insert,":inner_rowid", inner_refid.rowid);
1312 bindIntParameter(contains_insert,":outer_rowid", outer_refid.rowid);
1314 }
1315}
1316
1317
1318static void writeInnerPages(const PageLinkedRefMap &pl, struct Refid outer_refid)
1319{
1320 for (const auto &pd : pl)
1321 {
1322 struct Refid inner_refid = insertRefid(
1323 pd->getGroupDef() ? pd->getOutputFileBase()+"_"+pd->name() : pd->getOutputFileBase()
1324 );
1325
1326 bindIntParameter(contains_insert,":inner_rowid", inner_refid.rowid);
1327 bindIntParameter(contains_insert,":outer_rowid", outer_refid.rowid);
1329 }
1330}
1331
1332static void writeInnerGroups(const GroupList &gl, struct Refid outer_refid)
1333{
1334 for (const auto &sgd : gl)
1335 {
1336 struct Refid inner_refid = insertRefid(sgd->getOutputFileBase());
1337
1338 bindIntParameter(contains_insert,":inner_rowid", inner_refid.rowid);
1339 bindIntParameter(contains_insert,":outer_rowid", outer_refid.rowid);
1341 }
1342}
1343
1344static void writeInnerFiles(const FileList &fl, struct Refid outer_refid)
1345{
1346 for (const auto &fd: fl)
1347 {
1348 struct Refid inner_refid = insertRefid(fd->getOutputFileBase());
1349
1350 bindIntParameter(contains_insert,":inner_rowid", inner_refid.rowid);
1351 bindIntParameter(contains_insert,":outer_rowid", outer_refid.rowid);
1353 }
1354}
1355
1356static void writeInnerDirs(const DirList &dl, struct Refid outer_refid)
1357{
1358 for (const auto &subdir : dl)
1359 {
1360 struct Refid inner_refid = insertRefid(subdir->getOutputFileBase());
1361
1362 bindIntParameter(contains_insert,":inner_rowid", inner_refid.rowid);
1363 bindIntParameter(contains_insert,":outer_rowid", outer_refid.rowid);
1365 }
1366}
1367
1368static void writeInnerNamespaces(const NamespaceLinkedRefMap &nl, struct Refid outer_refid)
1369{
1370 for (const auto &nd : nl)
1371 {
1372 if (!nd->isHidden() && !nd->isAnonymous())
1373 {
1374 struct Refid inner_refid = insertRefid(nd->getOutputFileBase());
1375
1376 bindIntParameter(contains_insert,":inner_rowid",inner_refid.rowid);
1377 bindIntParameter(contains_insert,":outer_rowid",outer_refid.rowid);
1379 }
1380 }
1381}
1382
1383
1385 const Definition * scope,
1386 const FileDef * fileScope,
1387 const ArgumentList &typeConstraints=ArgumentList())
1388{
1389 for (const Argument &a : al)
1390 {
1391 if (!a.type.empty())
1392 {
1393//#warning linkifyText(TextGeneratorXMLImpl(t),a.type,LinkifyTextOptions().setScope(scope).setFileScope(fileScope));
1394 bindTextParameter(param_select,":type",a.type);
1395 bindTextParameter(param_insert,":type",a.type);
1396 }
1397 if (!a.name.empty())
1398 {
1399 bindTextParameter(param_select,":declname",a.name);
1400 bindTextParameter(param_insert,":declname",a.name);
1401 bindTextParameter(param_select,":defname",a.name);
1402 bindTextParameter(param_insert,":defname",a.name);
1403 }
1404 if (!a.defval.empty())
1405 {
1406//#warning linkifyText(TextGeneratorXMLImpl(t),a.defval,LinkifyTextOptions().setScope(scope).setFileScope(fileScope));
1407 bindTextParameter(param_select,":defval",a.defval);
1408 bindTextParameter(param_insert,":defval",a.defval);
1409 }
1410 DString typeConstraint = a.typeConstraint;
1411 // C# where clauses, with one entry per constraint. A C# type parameter has its name in type.
1412 const DString &paramName = a.name.empty() ? a.type : a.name;
1413 for (const Argument &tc : typeConstraints)
1414 {
1415 if (tc.name==paramName && !tc.type.empty())
1416 {
1417 if (!typeConstraint.empty()) typeConstraint+=", ";
1418 typeConstraint+=tc.type;
1419 }
1420 }
1421 if (!typeConstraint.empty())
1422 {
1423 bindTextParameter(param_select,":typeconstraint",typeConstraint);
1424 bindTextParameter(param_insert,":typeconstraint",typeConstraint);
1425 }
1426 if (!step(param_select,true,true))
1428 }
1429}
1430
1435
1436static void writeTemplateList(const ClassDef *cd)
1437{
1439}
1440
1441static void writeTemplateList(const ConceptDef *cd)
1442{
1444}
1445
1447 const Definition *def,
1448 const DString &doc,
1449 const DString &fileName,
1450 int lineNr)
1451{
1452 if (doc.empty()) return "";
1453
1454 TextStream t;
1455 auto parser { createDocParser() };
1456 auto ast { validatingParseDoc(*parser.get(),
1457 fileName,
1458 lineNr,
1459 scope,
1460 toMemberDef(def),
1461 doc,
1462 DocOptions())
1463 };
1464 auto astImpl = dynamic_cast<const DocNodeAST*>(ast.get());
1465 if (astImpl)
1466 {
1467 OutputCodeList xmlCodeList;
1468 xmlCodeList.add<XMLCodeGenerator>(&t);
1469 // create a parse tree visitor for XML
1470 XmlDocVisitor visitor(t,xmlCodeList,
1471 scope ? scope->getDefFileExtension() : DString(""));
1472 std::visit(visitor,astImpl->root);
1473 }
1475}
1476
1477static void getSQLDesc(SqlStmt &s,const char *col,const DString &value,const Definition *def)
1478{
1480 s,
1481 col,
1483 def->getOuterScope(),
1484 def,
1485 value,
1486 def->docFile(),
1487 def->docLine()
1488 )
1489 );
1490}
1491
1492static void getSQLDescCompound(SqlStmt &s,const char *col,const DString &value,const Definition *def)
1493{
1495 s,
1496 col,
1498 def,
1499 def,
1500 value,
1501 def->docFile(),
1502 def->docLine()
1503 )
1504 );
1505}
1506////////////////////////////////////////////
1507
1508/* (updated Sep 01 2018)
1509DoxMemberKind and DoxCompoundKind (compound.xsd) gave me some
1510faulty assumptions about "kind" strings, so I compiled a reference
1511
1512The XML schema claims:
1513 DoxMemberKind: (14)
1514 dcop define enum event friend function interface property prototype
1515 service signal slot typedef variable
1516
1517 DoxCompoundKind: (18)
1518 category class dir example exception file group interface module
1519 namespace page protocol record service singleton struct type union
1520
1521Member kind comes from MemberDef::memberTypeName()
1522 types.h defines 14 MemberType::*s
1523 _DCOP _Define _Enumeration _EnumValue _Event _Friend _Function _Interface
1524 _Property _Service _Signal _Slot _Typedef _Variable
1525 - xml doesn't include enumvalue here
1526 (but renders enumvalue as) a sub-node of memberdef/templateparamlist
1527 - xml includes 'prototype' that is unlisted here
1528 vestigial? commented out in docsets.cpp and perlmodgen.cpp
1529 MemberDef::memberTypeName() can return 15 strings:
1530 (sorted by MemberType to match above; quoted because whitespace...)
1531 "dcop" "macro definition" "enumeration" "enumvalue" "event" "friend"
1532 "function" "interface" "property" "service" "signal" "slot" "typedef"
1533 "variable"
1534
1535 Above describes potential values for memberdef.kind
1536
1537Compound kind is more complex. *Def::compoundTypeString()
1538 ClassDef kind comes from ::compoundTypeString()
1539 classdef.h defines 9 compound types
1540 Category Class Exception Interface Protocol Service Singleton Struct Record Union
1541 But ClassDef::compoundTypeString() "could" return 13 strings
1542 - default "unknown" shouldn't actually return
1543 - other 13 can vary by source language; see method for specifics
1544 category class enum exception interface module protocol record service
1545 singleton struct type record union
1546
1547 DirDef, FileDef, GroupDef have no method to return a string
1548 tagfile/outputs hard-code kind to 'dir' 'file' or 'group'
1549
1550 NamespaceDef kind comes from ::compoundTypeString()
1551 NamespaceDef::compoundTypeString() "could" return 6 strings
1552 - default empty ("") string
1553 - other 5 differ by source language
1554 constants library module namespace package
1555
1556 PageDef also has no method to return a string
1557 - some locations hard-code the kind to 'page'
1558 - others conditionally output 'page' or 'example'
1559
1560 All together, that's 24 potential strings (22 excl "" and unknown)
1561 "" category class constants dir enum example exception file group
1562 interface library module namespace package page protocol record service singleton
1563 struct type union unknown
1564
1565 Above describes potential values for compounddef.kind
1566
1567For reference, there are 36 potential values of def.kind (34 excl "" and unknown):
1568 "" "category" "class" "constants" "dcop" "dir" "enum" "enumeration"
1569 "enumvalue" "event" "example" "exception" "file" "friend" "function" "group"
1570 "interface" "library" "macro definition" "module" "namespace" "package"
1571 "page" "property" "protocol" |"record" "service" "signal" "singleton" "slot" "struct"
1572 "type" "typedef" "union" "unknown" "variable"
1573
1574This is relevant because the 'def' view generalizes memberdef and compounddef,
1575and two member+compound kind strings (interface and service) overlap.
1576
1577I have no grasp of whether a real user docset would include one or more
1578member and compound using the interface or service kind.
1579*/
1580
1581//////////////////////////////////////////////////////////////////////////////
1582static void generateSqlite3ForMember(const MemberDef *md, struct Refid scope_refid, const Definition *def)
1583{
1584 // + declaration/definition arg lists
1585 // + reimplements
1586 // + reimplementedBy
1587 // - exceptions
1588 // + const/volatile specifiers
1589 // - examples
1590 // + source definition
1591 // + source references
1592 // + source referenced by
1593 // - body code
1594 // + template arguments
1595 // (templateArguments(), definitionTemplateParameterLists())
1596 // - call graph
1597
1598 // enum values are written as part of the enum
1599 if (md->memberType()==MemberType::EnumValue) return;
1600 if (md->isHidden()) return;
1601
1602 DString memType;
1603
1604 // memberdef
1605 DString qrefid = md->getOutputFileBase() + "_1" + md->anchor();
1606 struct Refid refid = insertRefid(qrefid);
1607
1608 associateMember(md, refid, scope_refid);
1609
1610 // compacting duplicate defs
1611 if(!refid.created && memberdefExists(refid) && memberdefIncomplete(refid, md))
1612 {
1613 /*
1614 For performance, ideal to skip a member we've already added.
1615 Unfortunately, we can have two memberdefs with the same refid documenting
1616 the declaration and definition. memberdefIncomplete() uses the 'inline'
1617 value to figure this out. Once we get to this point, we should *only* be
1618 seeing the *other* type of def/decl, so we'll set inline to a new value (2),
1619 indicating that this entry covers both inline types.
1620 */
1621 struct SqlStmt memberdef_update;
1622
1623 // definitions have bodyfile/start/end
1624 if (md->getStartBodyLine()!=-1)
1625 {
1626 memberdef_update = memberdef_update_def;
1627 int bodyfile_id = insertPath(md->getBodyDef()->absFilePath(),!md->getBodyDef()->isReference());
1628 if (bodyfile_id == -1)
1629 {
1630 sqlite3_clear_bindings(memberdef_update.stmt);
1631 }
1632 else
1633 {
1634 bindIntParameter(memberdef_update,":bodyfile_id",bodyfile_id);
1635 bindIntParameter(memberdef_update,":bodystart",md->getStartBodyLine());
1636 bindIntParameter(memberdef_update,":bodyend",md->getEndBodyLine());
1637 }
1638 }
1639 // declarations don't
1640 else
1641 {
1642 memberdef_update = memberdef_update_decl;
1643 if (md->getDefLine() != -1)
1644 {
1645 int file_id = insertPath(md->getDefFileName(),!md->isReference());
1646 if (file_id!=-1)
1647 {
1648 bindIntParameter(memberdef_update,":file_id",file_id);
1649 bindIntParameter(memberdef_update,":line",md->getDefLine());
1650 bindIntParameter(memberdef_update,":column",md->getDefColumn());
1651 }
1652 }
1653 }
1654
1655 bindIntParameter(memberdef_update, ":rowid", refid.rowid);
1656 // value 2 indicates we've seen "both" inline types.
1657 bindIntParameter(memberdef_update,":inline", 2);
1658
1659 /* in case both are used, append/prepend descriptions */
1660 getSQLDesc(memberdef_update,":briefdescription",md->briefDescription(),md);
1661 getSQLDesc(memberdef_update,":detaileddescription",md->documentation(),md);
1662 getSQLDesc(memberdef_update,":inbodydescription",md->inbodyDocumentation(),md);
1663
1664 step(memberdef_update,true);
1665
1666 // don't think we need to repeat params; should have from first encounter
1667
1668 // + source references
1669 // The cross-references in initializers only work when both the src and dst
1670 // are defined.
1671 auto refList = md->getReferencesMembers();
1672 for (const auto &rmd : refList)
1673 {
1674 insertMemberReference(md,rmd, "inline");
1675 }
1676 // + source referenced by
1677 auto refByList = md->getReferencedByMembers();
1678 for (const auto &rmd : refByList)
1679 {
1680 insertMemberReference(rmd,md, "inline");
1681 }
1682 return;
1683 }
1684
1685 bindIntParameter(memberdef_insert,":rowid", refid.rowid);
1687 bindIntParameter(memberdef_insert,":prot",static_cast<int>(md->protection()));
1688
1691
1692 bool isFunc=to_isFunction(md->memberType());
1693
1694 if (isFunc)
1695 {
1696 const ArgumentList &al = md->argumentList();
1699 bindIntParameter(memberdef_insert,":explicit",md->isExplicit());
1704 bindIntParameter(memberdef_insert,":optional",md->isOptional());
1705 bindIntParameter(memberdef_insert,":required",md->isRequired());
1706
1707 bindIntParameter(memberdef_insert,":virt",static_cast<int>(md->virtualness()));
1708 }
1709
1710 if (md->memberType() == MemberType::Variable)
1711 {
1713 bindIntParameter(memberdef_insert,":thread_local",md->isThreadLocal());
1714 bindIntParameter(memberdef_insert,":initonly",md->isInitonly());
1715 bindIntParameter(memberdef_insert,":attribute",md->isAttribute());
1716 bindIntParameter(memberdef_insert,":property",md->isProperty());
1717 bindIntParameter(memberdef_insert,":readonly",md->isReadonly());
1719 bindIntParameter(memberdef_insert,":removable",md->isRemovable());
1720 bindIntParameter(memberdef_insert,":constrained",md->isConstrained());
1721 bindIntParameter(memberdef_insert,":transient",md->isTransient());
1722 bindIntParameter(memberdef_insert,":maybevoid",md->isMaybeVoid());
1723 bindIntParameter(memberdef_insert,":maybedefault",md->isMaybeDefault());
1724 bindIntParameter(memberdef_insert,":maybeambiguous",md->isMaybeAmbiguous());
1725 if (!md->bitfieldString().empty())
1726 {
1727 DString bitfield = md->bitfieldString();
1728 if (bitfield.at(0)==':') bitfield=bitfield.mid(1);
1729 bindTextParameter(memberdef_insert,":bitfield",bitfield.stripWhiteSpace());
1730 }
1731 }
1732 else if (md->memberType() == MemberType::Property)
1733 {
1734 bindIntParameter(memberdef_insert,":readable",md->isReadable());
1735 bindIntParameter(memberdef_insert,":writable",md->isWritable());
1736 bindIntParameter(memberdef_insert,":gettable",md->isGettable());
1737 bindIntParameter(memberdef_insert,":privategettable",md->isPrivateGettable());
1738 bindIntParameter(memberdef_insert,":protectedgettable",md->isProtectedGettable());
1739 bindIntParameter(memberdef_insert,":settable",md->isSettable());
1740 bindIntParameter(memberdef_insert,":privatesettable",md->isPrivateSettable());
1741 bindIntParameter(memberdef_insert,":protectedsettable",md->isProtectedSettable());
1742 bindIntParameter(memberdef_insert,":initonly",md->isInitonly());
1743
1744 if (md->isAssign() || md->isCopy() || md->isRetain()
1745 || md->isStrong() || md->isWeak())
1746 {
1747 int accessor=0;
1748 if (md->isAssign()) accessor = 1;
1749 else if (md->isCopy()) accessor = 2;
1750 else if (md->isRetain()) accessor = 3;
1751 else if (md->isStrong()) accessor = 4;
1752 else if (md->isWeak()) accessor = 5;
1753
1754 bindIntParameter(memberdef_insert,":accessor",accessor);
1755 }
1758 }
1759 else if (md->memberType() == MemberType::Event)
1760 {
1762 bindIntParameter(memberdef_insert,":removable",md->isRemovable());
1763 bindIntParameter(memberdef_insert,":raisable",md->isRaisable());
1764 }
1765
1766 const MemberDef *rmd = md->reimplements();
1767 if (rmd)
1768 {
1769 DString qreimplemented_refid = rmd->getOutputFileBase() + "_1" + rmd->anchor();
1770
1771 struct Refid reimplemented_refid = insertRefid(qreimplemented_refid);
1772
1773 bindIntParameter(reimplements_insert,":memberdef_rowid", refid.rowid);
1774 bindIntParameter(reimplements_insert,":reimplemented_rowid", reimplemented_refid.rowid);
1776 }
1777
1778 LinkifyTextOptions options;
1779 options.setScope(def).setFileScope(md->getBodyDef()).setSelf(md);
1780
1781 // + declaration/definition arg lists
1782 if (md->memberType()!=MemberType::Define &&
1783 md->memberType()!=MemberType::Enumeration
1784 )
1785 {
1786 if (md->memberType()!=MemberType::Typedef)
1787 {
1789 }
1790 DString typeStr = md->typeString();
1791 stripQualifiers(typeStr);
1792 StringVector list;
1793 linkifyText(TextGeneratorSqlite3Impl(list),typeStr,options);
1794 if (!typeStr.empty())
1795 {
1796 bindTextParameter(memberdef_insert,":type",typeStr);
1797 }
1798
1799 if (!md->definition().empty())
1800 {
1801 bindTextParameter(memberdef_insert,":definition",md->definition());
1802 }
1803
1804 if (!md->argsString().empty())
1805 {
1806 bindTextParameter(memberdef_insert,":argsstring",md->argsString());
1807 }
1808 }
1809
1811
1812 // Extract references from initializer
1814 {
1815 bindTextParameter(memberdef_insert,":initializer",md->initializer());
1816
1817 StringVector list;
1819 for (const auto &s : list)
1820 {
1821 if (md->getBodyDef())
1822 {
1823 DBG_CTX(("initializer:%s %s %s %d\n",
1824 qPrint(md->anchor()),
1825 qPrint(s),
1827 md->getStartBodyLine()));
1828 DString qsrc_refid = md->getOutputFileBase() + "_1" + md->anchor();
1829 struct Refid src_refid = insertRefid(qsrc_refid);
1830 struct Refid dst_refid = insertRefid(s);
1831 insertMemberReference(src_refid,dst_refid, "initializer");
1832 }
1833 }
1834 }
1835
1836 if ( !md->getScopeString().empty() )
1837 {
1839 }
1840
1841 // +Brief, detailed and inbody description
1842 getSQLDesc(memberdef_insert,":briefdescription",md->briefDescription(),md);
1843 getSQLDesc(memberdef_insert,":detaileddescription",md->documentation(),md);
1844 getSQLDesc(memberdef_insert,":inbodydescription",md->inbodyDocumentation(),md);
1845
1846 // File location
1847 if (md->getDefLine() != -1)
1848 {
1849 int file_id = insertPath(md->getDefFileName(),!md->isReference());
1850 if (file_id!=-1)
1851 {
1852 bindIntParameter(memberdef_insert,":file_id",file_id);
1855
1856 // definitions also have bodyfile/start/end
1857 if (md->getStartBodyLine()!=-1)
1858 {
1859 int bodyfile_id = insertPath(md->getBodyDef()->absFilePath(),!md->getBodyDef()->isReference());
1860 if (bodyfile_id == -1)
1861 {
1862 sqlite3_clear_bindings(memberdef_insert.stmt);
1863 }
1864 else
1865 {
1866 bindIntParameter(memberdef_insert,":bodyfile_id",bodyfile_id);
1869 }
1870 }
1871 }
1872 }
1873
1874 int memberdef_id=step(memberdef_insert,true);
1875
1876 if (isFunc)
1877 {
1878 insertMemberFunctionParams(memberdef_id,md,def);
1879 }
1880 else if (md->memberType()==MemberType::Define &&
1881 !md->argsString().empty())
1882 {
1883 insertMemberDefineParams(memberdef_id,md,def);
1884 }
1885
1886 // + source references
1887 // The cross-references in initializers only work when both the src and dst
1888 // are defined.
1889 for (const auto &refmd : md->getReferencesMembers())
1890 {
1891 insertMemberReference(md,refmd, "inline");
1892 }
1893 // + source referenced by
1894 for (const auto &refmd : md->getReferencedByMembers())
1895 {
1896 insertMemberReference(refmd,md, "inline");
1897 }
1898}
1899
1901 const MemberList *ml,
1902 struct Refid scope_refid,
1903 const char * /*kind*/,
1904 const DString & /*header*/=DString(),
1905 const DString & /*documentation*/=DString())
1906{
1907 if (ml==nullptr) return;
1908 for (const auto &md : *ml)
1909 {
1910 // TODO: necessary? just tracking what xmlgen does; xmlgen says:
1911 // namespace members are also inserted in the file scope, but
1912 // to prevent this duplication in the XML output, we filter those here.
1913 if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==nullptr)
1914 {
1915 generateSqlite3ForMember(md, scope_refid, d);
1916 }
1917 }
1918}
1919
1920static void associateAllClassMembers(const ClassDef *cd, struct Refid scope_refid)
1921{
1922 for (auto &mni : cd->memberNameInfoLinkedMap())
1923 {
1924 for (auto &mi : *mni)
1925 {
1926 const MemberDef *md = mi->memberDef();
1927 DString qrefid = md->getOutputFileBase() + "_1" + md->anchor();
1928 associateMember(md, insertRefid(qrefid), scope_refid);
1929 }
1930 }
1931}
1932
1933// many kinds: category class enum exception interface
1934// module protocol record service singleton struct type union
1935// enum is Java only (and is distinct from enum memberdefs)
1936static void generateSqlite3ForClass(const ClassDef *cd)
1937{
1938 // NOTE: Skeptical about XML's version of these
1939 // 'x' marks missing items XML claims to include
1940
1941 // + brief description
1942 // + detailed description
1943 // + template argument list(s)
1944 // + include file
1945 // + member groups
1946 // x inheritance DOT diagram
1947 // + list of direct super classes
1948 // + list of direct sub classes
1949 // + list of inner classes
1950 // x collaboration DOT diagram
1951 // + list of all members
1952 // x user defined member sections
1953 // x standard member sections
1954 // x detailed member documentation
1955 // - examples using the class
1956
1957 if (cd->isReference()) return; // skip external references.
1958 if (cd->isHidden()) return; // skip hidden classes.
1959 if (cd->isAnonymous()) return; // skip anonymous compounds.
1960 if (cd->isImplicitTemplateInstance()) return; // skip generated template instances.
1961
1962 struct Refid refid = insertRefid(cd->getOutputFileBase());
1963
1964 // can omit a class that already has a refid
1965 if(!refid.created && compounddefExists(refid)){return;}
1966
1967 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
1968
1972 bindIntParameter(compounddef_insert,":prot",static_cast<int>(cd->protection()));
1977
1978 int file_id = insertPath(cd->getDefFileName());
1979 bindIntParameter(compounddef_insert,":file_id",file_id);
1982
1983 // + include file
1984 /*
1985 TODO: I wonder if this can actually be cut (just here)
1986
1987 We were adding this "include" to the "includes" table alongside
1988 other includes (from a FileDef). However, FileDef and ClassDef are using
1989 "includes" nodes in very a different way:
1990 - With FileDef, it means the file includes another.
1991 - With ClassDef, it means you should include this file to use this class.
1992
1993 Because of this difference, I added a column to compounddef, header_id, and
1994 linked it back to the appropriate file. We could just add a nullable text
1995 column that would hold a string equivalent to what the HTML docs include,
1996 but the logic for generating it is embedded in
1997 ClassDef::writeIncludeFiles(OutputList &ol).
1998
1999 That said, at least on the handful of test sets I have, header_id == file_id,
2000 suggesting it could be cut and clients might be able to reconstruct it from
2001 other values if there's a solid heuristic for *when a class will
2002 have a header file*.
2003 */
2004 const IncludeInfo *ii=cd->includeInfo();
2005 if (ii)
2006 {
2007 DString nm = ii->includeName;
2008 if (nm.empty() && ii->fileDef) nm = ii->fileDef->docName();
2009 if (!nm.empty())
2010 {
2011 int header_id=-1;
2012 if (ii->fileDef)
2013 {
2015 }
2016 DBG_CTX(("-----> ClassDef includeInfo for %s\n", qPrint(nm)));
2017 DBG_CTX((" local : %d\n", ii->local));
2018 DBG_CTX((" imported : %d\n", ii->imported));
2019 if (ii->fileDef)
2020 {
2021 DBG_CTX(("header: %s\n", qPrint(ii->fileDef->absFilePath())));
2022 }
2023 DBG_CTX((" file_id : %d\n", file_id));
2024 DBG_CTX((" header_id: %d\n", header_id));
2025
2026 if(header_id!=-1)
2027 {
2028 bindIntParameter(compounddef_insert,":header_id",header_id);
2029 }
2030 }
2031 }
2032
2033 getSQLDescCompound(compounddef_insert,":briefdescription",cd->briefDescription(),cd);
2034 getSQLDescCompound(compounddef_insert,":detaileddescription",cd->documentation(),cd);
2035
2037
2038 // + list of direct super classes
2039 for (const auto &bcd : cd->baseClasses())
2040 {
2041 struct Refid base_refid = insertRefid(bcd.classDef->getOutputFileBase());
2042 struct Refid derived_refid = insertRefid(cd->getOutputFileBase());
2043 bindIntParameter(compoundref_insert,":base_rowid", base_refid.rowid);
2044 bindIntParameter(compoundref_insert,":derived_rowid", derived_refid.rowid);
2045 bindIntParameter(compoundref_insert,":prot",static_cast<int>(bcd.prot));
2046 bindIntParameter(compoundref_insert,":virt",static_cast<int>(bcd.virt));
2048 }
2049
2050 // + list of direct sub classes
2051 for (const auto &bcd : cd->subClasses())
2052 {
2053 struct Refid derived_refid = insertRefid(bcd.classDef->getOutputFileBase());
2054 struct Refid base_refid = insertRefid(cd->getOutputFileBase());
2055 bindIntParameter(compoundref_insert,":base_rowid", base_refid.rowid);
2056 bindIntParameter(compoundref_insert,":derived_rowid", derived_refid.rowid);
2057 bindIntParameter(compoundref_insert,":prot",static_cast<int>(bcd.prot));
2058 bindIntParameter(compoundref_insert,":virt",static_cast<int>(bcd.virt));
2060 }
2061
2062 // + list of inner classes
2064
2065 // + template argument list(s)
2067
2068 // + member groups
2069 for (const auto &mg : cd->getMemberGroups())
2070 {
2071 generateSqlite3Section(cd,&mg->members(),refid,"user-defined",mg->header(),
2072 mg->documentation());
2073 }
2074
2075 // this is just a list of *local* members
2076 for (const auto &ml : cd->getMemberLists())
2077 {
2078 if (!ml->listType().isDetailed())
2079 {
2080 generateSqlite3Section(cd,ml.get(),refid,"user-defined");
2081 }
2082 }
2083
2084 // + list of all members
2086}
2087
2089{
2090 if (cd->isReference() || cd->isHidden()) return; // skip external references
2091
2092 struct Refid refid = insertRefid(cd->getOutputFileBase());
2093 if(!refid.created && compounddefExists(refid)){return;}
2094 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2096 bindTextParameter(compounddef_insert,":kind","concept");
2097
2098 int file_id = insertPath(cd->getDefFileName());
2099 bindIntParameter(compounddef_insert,":file_id",file_id);
2102
2103 getSQLDescCompound(compounddef_insert,":briefdescription",cd->briefDescription(),cd);
2104 getSQLDescCompound(compounddef_insert,":detaileddescription",cd->documentation(),cd);
2105
2107
2108 // + template argument list(s)
2110}
2111
2113{
2114 // + contained class definitions
2115 // + contained concept definitions
2116 // + member groups
2117 // + normal members
2118 // + brief desc
2119 // + detailed desc
2120 // + location (file_id, line, column)
2121 // - exports
2122 // + used files
2123
2124 if (mod->isReference() || mod->isHidden()) return;
2125 struct Refid refid = insertRefid(mod->getOutputFileBase());
2126 if(!refid.created && compounddefExists(refid)){return;}
2127 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2129 bindTextParameter(compounddef_insert,":kind","module");
2130
2131 int file_id = insertPath(mod->getDefFileName());
2132 bindIntParameter(compounddef_insert,":file_id",file_id);
2135
2136 getSQLDescCompound(compounddef_insert,":briefdescription",mod->briefDescription(),mod);
2137 getSQLDescCompound(compounddef_insert,":detaileddescription",mod->documentation(),mod);
2138
2140
2141 // + contained class definitions
2143
2144 // + contained concept definitions
2146
2147 // + member groups
2148 for (const auto &mg : mod->getMemberGroups())
2149 {
2150 generateSqlite3Section(mod,&mg->members(),refid,"user-defined",mg->header(),
2151 mg->documentation());
2152 }
2153
2154 // + normal members
2155 for (const auto &ml : mod->getMemberLists())
2156 {
2157 if (ml->listType().isDeclaration())
2158 {
2159 generateSqlite3Section(mod,ml.get(),refid,"user-defined");
2160 }
2161 }
2162
2163 // + files
2165}
2166
2167// kinds: constants library module namespace package
2169{
2170 // + contained class definitions
2171 // + contained namespace definitions
2172 // + member groups
2173 // + normal members
2174 // + brief desc
2175 // + detailed desc
2176 // + location (file_id, line, column)
2177 // - files containing (parts of) the namespace definition
2178
2179 if (nd->isReference() || nd->isHidden()) return; // skip external references
2180 struct Refid refid = insertRefid(nd->getOutputFileBase());
2181 if(!refid.created && compounddefExists(refid)){return;}
2182 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2183
2186 bindTextParameter(compounddef_insert,":kind","namespace");
2187
2188 int file_id = insertPath(nd->getDefFileName());
2189 bindIntParameter(compounddef_insert,":file_id",file_id);
2192
2193 getSQLDescCompound(compounddef_insert,":briefdescription",nd->briefDescription(),nd);
2194 getSQLDescCompound(compounddef_insert,":detaileddescription",nd->documentation(),nd);
2195
2197
2198 // + contained class definitions
2200
2201 // + contained concept definitions
2203
2204 // + contained namespace definitions
2206
2207 // + member groups
2208 for (const auto &mg : nd->getMemberGroups())
2209 {
2210 generateSqlite3Section(nd,&mg->members(),refid,"user-defined",mg->header(),
2211 mg->documentation());
2212 }
2213
2214 // + normal members
2215 for (const auto &ml : nd->getMemberLists())
2216 {
2217 if (ml->listType().isDeclaration())
2218 {
2219 generateSqlite3Section(nd,ml.get(),refid,"user-defined");
2220 }
2221 }
2222}
2223
2224// kind: file
2225static void generateSqlite3ForFile(const FileDef *fd)
2226{
2227 // + includes files
2228 // + includedby files
2229 // x include graph
2230 // x included by graph
2231 // + contained class definitions
2232 // + contained namespace definitions
2233 // + member groups
2234 // + normal members
2235 // + brief desc
2236 // + detailed desc
2237 // x source code
2238 // + location (file_id, line, column)
2239 // - number of lines
2240
2241 if (fd->isReference()) return; // skip external references
2242
2243 struct Refid refid = insertRefid(fd->getOutputFileBase());
2244 if(!refid.created && compounddefExists(refid)){return;}
2245 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2246
2249 bindTextParameter(compounddef_insert,":kind","file");
2250
2251 int file_id = insertPath(fd->getDefFileName());
2252 bindIntParameter(compounddef_insert,":file_id",file_id);
2255
2256 getSQLDesc(compounddef_insert,":briefdescription",fd->briefDescription(),fd);
2257 getSQLDesc(compounddef_insert,":detaileddescription",fd->documentation(),fd);
2258
2260
2261 // + includes files
2262 for (const auto &ii : fd->includeFileList())
2263 {
2264 int src_id=insertPath(fd->absFilePath(),!fd->isReference());
2265 int dst_id=0;
2266 DString dst_path;
2267 bool isLocal = (ii.kind & IncludeKind_LocalMask)!=0;
2268
2269 if(ii.fileDef) // found file
2270 {
2271 if(ii.fileDef->isReference())
2272 {
2273 // strip tagfile from path
2274 DString tagfile = ii.fileDef->getReference();
2275 dst_path = ii.fileDef->absFilePath();
2276 dst_path.stripPrefix(tagfile+":");
2277 }
2278 else
2279 {
2280 dst_path = ii.fileDef->absFilePath();
2281 }
2282 dst_id = insertPath(dst_path,isLocal);
2283 }
2284 else // can't find file
2285 {
2286 dst_id = insertPath(ii.includeName,isLocal,false);
2287 }
2288
2289 DBG_CTX(("-----> FileDef includeInfo for %s\n", qPrint(ii.includeName)));
2290 DBG_CTX((" local: %d\n", isLocal));
2291 DBG_CTX((" imported: %d\n", (ii.kind & IncludeKind_ImportMask)!=0));
2292 if(ii.fileDef)
2293 {
2294 DBG_CTX(("include: %s\n", qPrint(ii.fileDef->absFilePath())));
2295 }
2296 DBG_CTX((" src_id : %d\n", src_id));
2297 DBG_CTX((" dst_id: %d\n", dst_id));
2298
2299 bindIntParameter(incl_select,":local",isLocal);
2300 bindIntParameter(incl_select,":src_id",src_id);
2301 bindIntParameter(incl_select,":dst_id",dst_id);
2302 if (step(incl_select,true,true)==0) {
2303 bindIntParameter(incl_insert,":local",isLocal);
2304 bindIntParameter(incl_insert,":src_id",src_id);
2305 bindIntParameter(incl_insert,":dst_id",dst_id);
2307 }
2308 }
2309
2310 // + includedby files
2311 for (const auto &ii : fd->includedByFileList())
2312 {
2313 int dst_id=insertPath(fd->absFilePath(),!fd->isReference());
2314 int src_id=0;
2315 DString src_path;
2316 bool isLocal = (ii.kind & IncludeKind_LocalMask)!=0;
2317
2318 if(ii.fileDef) // found file
2319 {
2320 if(ii.fileDef->isReference())
2321 {
2322 // strip tagfile from path
2323 DString tagfile = ii.fileDef->getReference();
2324 src_path = ii.fileDef->absFilePath();
2325 src_path.stripPrefix(tagfile+":");
2326 }
2327 else
2328 {
2329 src_path = ii.fileDef->absFilePath();
2330 }
2331 src_id = insertPath(src_path,isLocal);
2332 }
2333 else // can't find file
2334 {
2335 src_id = insertPath(ii.includeName,isLocal,false);
2336 }
2337
2338 bindIntParameter(incl_select,":local",isLocal);
2339 bindIntParameter(incl_select,":src_id",src_id);
2340 bindIntParameter(incl_select,":dst_id",dst_id);
2341 if (step(incl_select,true,true)==0) {
2342 bindIntParameter(incl_insert,":local",isLocal);
2343 bindIntParameter(incl_insert,":src_id",src_id);
2344 bindIntParameter(incl_insert,":dst_id",dst_id);
2346 }
2347 }
2348
2349 // + contained class definitions
2351
2352 // + contained concept definitions
2354
2355 // + contained namespace definitions
2357
2358 // + member groups
2359 for (const auto &mg : fd->getMemberGroups())
2360 {
2361 generateSqlite3Section(fd,&mg->members(),refid,"user-defined",mg->header(),
2362 mg->documentation());
2363 }
2364
2365 // + normal members
2366 for (const auto &ml : fd->getMemberLists())
2367 {
2368 if (ml->listType().isDeclaration())
2369 {
2370 generateSqlite3Section(fd,ml.get(),refid,"user-defined");
2371 }
2372 }
2373}
2374
2375// kind: group
2376static void generateSqlite3ForGroup(const GroupDef *gd)
2377{
2378 // + members
2379 // + member groups
2380 // + files
2381 // + classes
2382 // + namespaces
2383 // - packages
2384 // + pages
2385 // + child groups
2386 // - examples
2387 // + brief description
2388 // + detailed description
2389
2390 if (gd->isReference()) return; // skip external references.
2391
2392 struct Refid refid = insertRefid(gd->getOutputFileBase());
2393 if(!refid.created && compounddefExists(refid)){return;}
2394 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2395
2398 bindTextParameter(compounddef_insert,":kind","group");
2399
2400 int file_id = insertPath(gd->getDefFileName());
2401 bindIntParameter(compounddef_insert,":file_id",file_id);
2404
2405 getSQLDesc(compounddef_insert,":briefdescription",gd->briefDescription(),gd);
2406 getSQLDesc(compounddef_insert,":detaileddescription",gd->documentation(),gd);
2407
2409
2410 // + files
2412
2413 // + classes
2415
2416 // + concepts
2418
2419 // + modules
2421
2422 // + namespaces
2424
2425 // + pages
2427
2428 // + groups
2430
2431 // + member groups
2432 for (const auto &mg : gd->getMemberGroups())
2433 {
2434 generateSqlite3Section(gd,&mg->members(),refid,"user-defined",mg->header(),
2435 mg->documentation());
2436 }
2437
2438 // + members
2439 for (const auto &ml : gd->getMemberLists())
2440 {
2441 if (ml->listType().isDeclaration())
2442 {
2443 generateSqlite3Section(gd,ml.get(),refid,"user-defined");
2444 }
2445 }
2446}
2447
2448// kind: dir
2449static void generateSqlite3ForDir(const DirDef *dd)
2450{
2451 // + dirs
2452 // + files
2453 // + briefdescription
2454 // + detaileddescription
2455 // + location (below uses file_id, line, column; XML just uses file)
2456 if (dd->isReference()) return; // skip external references
2457
2458 struct Refid refid = insertRefid(dd->getOutputFileBase());
2459 if(!refid.created && compounddefExists(refid)){return;}
2460 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2461
2464
2465 int file_id = insertPath(dd->getDefFileName(),true,true,2);
2466 bindIntParameter(compounddef_insert,":file_id",file_id);
2467
2468 /*
2469 line and column are weird here, but:
2470 - dir goes into compounddef with all of the others
2471 - the semantics would be fine if we set them to NULL here
2472 - but defining line and column as NOT NULL is an important promise
2473 for other compounds, so I don't want to loosen it
2474
2475 For reference, the queries return 1.
2476 0 or -1 make more sense, but I see that as a change for DirDef.
2477 */
2480
2481 getSQLDesc(compounddef_insert,":briefdescription",dd->briefDescription(),dd);
2482 getSQLDesc(compounddef_insert,":detaileddescription",dd->documentation(),dd);
2483
2485
2486 // + files
2488
2489 // + files
2491}
2492
2493// kinds: page, example
2494static void generateSqlite3ForPage(const PageDef *pd,bool isExample)
2495{
2496 // + name
2497 // + title
2498 // + brief description
2499 // + documentation (detailed description)
2500 // + inbody documentation
2501 // + sub pages
2502 if (pd->isReference()) return; // skip external references.
2503
2504 // TODO: do we more special handling if isExample?
2505
2506 DString qrefid = pd->getOutputFileBase();
2507 if (pd->getGroupDef())
2508 {
2509 qrefid+="_"+pd->name();
2510 }
2511 if (qrefid=="index") qrefid="indexpage"; // to prevent overwriting the generated index page.
2512
2513 struct Refid refid = insertRefid(qrefid);
2514
2515 // can omit a page that already has a refid
2516 if(!refid.created && compounddefExists(refid)){return;}
2517
2519 // + name
2521
2522 DString title;
2523 if (pd==Doxygen::mainPage.get()) // main page is special
2524 {
2525 if (mainPageHasTitle())
2526 {
2527 title = filterTitle(HtmlEntityMapper::instance().convertCharEntitiesToUTF8(Doxygen::mainPage->title()));
2528 }
2529 else
2530 {
2531 title = Config_getString(PROJECT_NAME);
2532 }
2533 }
2534 else
2535 {
2537 if (si)
2538 {
2539 title = si->title();
2540 }
2541 if (title.empty())
2542 {
2543 title = pd->title();
2544 }
2545 }
2546
2547 // + title
2548 bindTextParameter(compounddef_insert,":title",title);
2549
2550 bindTextParameter(compounddef_insert,":kind", isExample ? "example" : "page");
2551
2552 int file_id = insertPath(pd->getDefFileName());
2553
2554 bindIntParameter(compounddef_insert,":file_id",file_id);
2557
2558 // + brief description
2559 getSQLDesc(compounddef_insert,":briefdescription",pd->briefDescription(),pd);
2560 // + documentation (detailed description)
2561 getSQLDesc(compounddef_insert,":detaileddescription",pd->documentation(),pd);
2562
2564 // + sub pages
2566}
2567
2568
2569static sqlite3* openDbConnection()
2570{
2571
2572 DString outputDirectory = Config_getString(SQLITE3_OUTPUT);
2573 sqlite3 *db = nullptr;
2574
2575 int rc = sqlite3_initialize();
2576 if (rc != SQLITE_OK)
2577 {
2578 err("sqlite3_initialize failed\n");
2579 return nullptr;
2580 }
2581
2582 std::string dbFileName = "doxygen_sqlite3.db";
2583 FileInfo fi(outputDirectory.str()+"/"+dbFileName);
2584
2585 if (fi.exists())
2586 {
2587 if (Config_getBool(SQLITE3_RECREATE_DB))
2588 {
2589 Dir().remove(fi.absFilePath());
2590 }
2591 else
2592 {
2593 err("doxygen_sqlite3.db already exists! Rename, remove, or archive it to regenerate\n");
2594 return nullptr;
2595 }
2596 }
2597
2598 rc = sqlite3_open_v2(
2599 fi.absFilePath().c_str(),
2600 &db,
2601 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
2602 nullptr
2603 );
2604 if (rc != SQLITE_OK)
2605 {
2606 sqlite3_close(db);
2607 err("Database open failed: doxygen_sqlite3.db\n");
2608 }
2609 return db;
2610}
2611//////////////////////////////////////////////////////////////////////////////
2612//////////////////////////////////////////////////////////////////////////////
2614{
2615 // + classes
2616 // + namespaces
2617 // + files
2618 // + groups
2619 // + related pages
2620 // + examples
2621 // + main page
2622 sqlite3 *db = openDbConnection();
2623 if (db==nullptr)
2624 {
2625 return;
2626 }
2627
2628# ifdef SQLITE3_DEBUG
2629 // debug: show all executed statements
2630 sqlite3_trace(db, &sqlLog, nullptr);
2631# endif
2632
2633 beginTransaction(db);
2634 pragmaTuning(db);
2635
2636 if (-1==initializeTables(db))
2637 return;
2638
2639 if ( -1 == prepareStatements(db) )
2640 {
2641 err("sqlite generator: prepareStatements failed!\n");
2642 return;
2643 }
2644
2646
2647 // + classes
2648 for (const auto &cd : *Doxygen::classLinkedMap)
2649 {
2650 msg("Generating Sqlite3 output for class {}\n",cd->name());
2651 generateSqlite3ForClass(cd.get());
2652 }
2653
2654 // + concepts
2655 for (const auto &cd : *Doxygen::conceptLinkedMap)
2656 {
2657 msg("Generating Sqlite3 output for concept {}\n",cd->name());
2658 generateSqlite3ForConcept(cd.get());
2659 }
2660
2661 // + modules
2662 for (const auto &mod : ModuleManager::instance().modules())
2663 {
2664 msg("Generating Sqlite3 output for module {}\n",mod->name());
2665 generateSqlite3ForModule(mod.get());
2666 }
2667
2668 // + namespaces
2669 for (const auto &nd : *Doxygen::namespaceLinkedMap)
2670 {
2671 msg("Generating Sqlite3 output for namespace {}\n",nd->name());
2673 }
2674
2675 // + files
2676 for (const auto &fn : *Doxygen::inputNameLinkedMap)
2677 {
2678 for (const auto &fd : *fn)
2679 {
2680 msg("Generating Sqlite3 output for file {}\n",fd->name());
2681 generateSqlite3ForFile(fd.get());
2682 }
2683 }
2684
2685 // + groups
2686 for (const auto &gd : *Doxygen::groupLinkedMap)
2687 {
2688 msg("Generating Sqlite3 output for group {}\n",gd->name());
2689 generateSqlite3ForGroup(gd.get());
2690 }
2691
2692 // + page
2693 for (const auto &pd : *Doxygen::pageLinkedMap)
2694 {
2695 msg("Generating Sqlite3 output for page {}\n",pd->name());
2696 generateSqlite3ForPage(pd.get(),false);
2697 }
2698
2699 // + dirs
2700 for (const auto &dd : *Doxygen::dirLinkedMap)
2701 {
2702 msg("Generating Sqlite3 output for dir {}\n",dd->name());
2703 generateSqlite3ForDir(dd.get());
2704 }
2705
2706 // + examples
2707 for (const auto &pd : *Doxygen::exampleLinkedMap)
2708 {
2709 msg("Generating Sqlite3 output for example {}\n",pd->name());
2710 generateSqlite3ForPage(pd.get(),true);
2711 }
2712
2713 // + main page
2715 {
2716 msg("Generating Sqlite3 output for the main page\n");
2718 }
2719
2720 // TODO: copied from initializeSchema; not certain if we should say/do more
2721 // if there's a failure here?
2722 if (-1==initializeViews(db))
2723 return;
2724
2725 endTransaction(db);
2726}
2727
2728// vim: noai:ts=2:sw=2:ss=2:expandtab
This class contains the information about the argument of a function or template.
Definition arguments.h:27
DString name
Definition arguments.h:45
This class represents an function or template argument list.
Definition arguments.h:66
iterator end()
Definition arguments.h:95
size_t size() const
Definition arguments.h:101
bool constSpecifier() const
Definition arguments.h:112
bool empty() const
Definition arguments.h:100
iterator begin()
Definition arguments.h:94
bool volatileSpecifier() const
Definition arguments.h:113
A abstract class representing of a compound symbol.
Definition classdef.h:100
virtual bool isAbstract() const =0
Returns true if there is at least one pure virtual member in this class.
virtual bool isFinal() const =0
Returns true if this class is marked as final.
virtual const ArgumentList & templateArguments() const =0
Returns the template arguments of this class.
virtual const MemberLists & getMemberLists() const =0
Returns the list containing the list of members sorted per type.
virtual const BaseClassList & baseClasses() const =0
Returns the list of base classes from which this class directly inherits.
virtual bool isSealed() const =0
Returns true if this class is marked as sealed.
virtual Protection protection() const =0
Return the protection level (Public,Protected,Private) in which this compound was found.
virtual DString compoundTypeString() const =0
Returns the type of compound as a string.
virtual const ArgumentList & typeConstraints() const =0
virtual const MemberNameInfoLinkedMap & memberNameInfoLinkedMap() const =0
Returns a dictionary of all members.
virtual bool isImplicitTemplateInstance() const =0
virtual const MemberGroupList & getMemberGroups() const =0
Returns the member groups defined for this class.
virtual bool isRef() const =0
Returns true if this class is a C# ref struct or a C++/CLI ref class.
virtual ClassLinkedRefMap getClasses() const =0
returns the classes nested into this class
virtual FileDef * getFileDef() const =0
Returns the file in which this compound's definition can be found.
virtual const IncludeInfo * includeInfo() const =0
virtual DString title() const =0
virtual const BaseClassList & subClasses() const =0
Returns the list of sub classes that directly derive from this class.
virtual ArgumentList getTemplateParameterList() const =0
virtual const FileDef * getFileDef() const =0
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:318
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
char & at(size_t i)
Returns a reference to the character at index i.
Definition dstring.h:686
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition dstring.h:337
const std::string & str() const
Definition dstring.h:645
bool stripPrefix(const DString &prefix)
Definition dstring.h:290
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:157
The common base class of all entity definitions found in the sources.
Definition definition.h:77
virtual DString briefDescription(bool abbreviate=false) const =0
virtual int getEndBodyLine() const =0
virtual DString getDefFileExtension() const =0
virtual int docLine() const =0
virtual DString getDefFileName() const =0
virtual DString documentation() const =0
virtual DString inbodyDocumentation() const =0
virtual int getDefLine() const =0
virtual DefType definitionType() const =0
virtual const DString & name() const =0
virtual const FileDef * getBodyDef() const =0
virtual size_t getDefColumn() const =0
virtual bool isAnonymous() const =0
virtual DString displayName(bool includeScope=true) const =0
virtual bool isHidden() const =0
virtual DString anchor() const =0
virtual Definition * getOuterScope() const =0
virtual DString docFile() const =0
virtual const MemberVector & getReferencedByMembers() const =0
virtual int getStartBodyLine() const =0
virtual bool isReference() const =0
virtual const MemberVector & getReferencesMembers() const =0
virtual DString getOutputFileBase() const =0
A model of a directory symbol.
Definition dirdef.h:108
virtual const DirList & subDirs() const =0
virtual const FileList & getFiles() const =0
Class representing a directory in the file system.
Definition dir.h:73
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:319
A list of directories.
Definition dirdef.h:178
Class representing the abstract syntax tree of a documentation block.
Definition docnode.h:1471
static NamespaceLinkedMap * namespaceLinkedMap
Definition doxygen.h:108
static ConceptLinkedMap * conceptLinkedMap
Definition doxygen.h:90
static std::unique_ptr< PageDef > mainPage
Definition doxygen.h:93
static FileNameLinkedMap * inputNameLinkedMap
Definition doxygen.h:97
static ClassLinkedMap * classLinkedMap
Definition doxygen.h:88
static PageLinkedMap * exampleLinkedMap
Definition doxygen.h:91
static PageLinkedMap * pageLinkedMap
Definition doxygen.h:92
static DirLinkedMap * dirLinkedMap
Definition doxygen.h:120
static GroupLinkedMap * groupLinkedMap
Definition doxygen.h:107
A model of a file symbol.
Definition filedef.h:97
virtual const NamespaceLinkedRefMap & getNamespaces() const =0
virtual const MemberGroupList & getMemberGroups() const =0
virtual DString absFilePath() const =0
virtual const DString & docName() const =0
virtual const ClassLinkedRefMap & getClasses() const =0
virtual const IncludeInfoList & includeFileList() const =0
virtual const MemberLists & getMemberLists() const =0
virtual DString title() const =0
virtual const ConceptLinkedRefMap & getConcepts() const =0
virtual const IncludeInfoList & includedByFileList() const =0
Minimal replacement for QFileInfo.
Definition fileinfo.h:26
bool exists() const
Definition fileinfo.cpp:35
std::string absFilePath() const
Definition fileinfo.cpp:106
A model of a group of symbols.
Definition groupdef.h:48
virtual DString groupTitle() const =0
virtual const GroupList & getSubGroups() const =0
virtual const FileList & getFiles() const =0
virtual const MemberLists & getMemberLists() const =0
virtual const MemberGroupList & getMemberGroups() const =0
virtual const ConceptLinkedRefMap & getConcepts() const =0
virtual const PageLinkedRefMap & getPages() const =0
virtual const NamespaceLinkedRefMap & getNamespaces() const =0
virtual const ClassLinkedRefMap & getClasses() const =0
virtual const ModuleLinkedRefMap & getModules() const =0
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
DString convertCharEntitiesToUTF8(const DString &s) const
Class representing the data associated with a #include statement.
Definition filedef.h:72
const FileDef * fileDef
Definition filedef.h:77
DString includeName
Definition filedef.h:78
const T * find(const std::string &key) const
Definition linkedmap.h:47
A model of a class/file/namespace member symbol.
Definition memberdef.h:45
virtual bool isInitonly() const =0
virtual bool isAssign() const =0
virtual bool isExplicit() const =0
virtual bool isNew() const =0
virtual bool isMaybeVoid() const =0
virtual DString argsString() const =0
virtual bool isSealed() const =0
virtual DString definition() const =0
virtual const ClassDef * getClassDef() const =0
virtual const ArgumentList & templateArguments() const =0
virtual const DString & initializer() const =0
virtual bool isSettable() const =0
virtual bool isRetain() const =0
virtual bool isAddable() const =0
virtual const FileDef * getFileDef() const =0
virtual bool isInline() const =0
virtual DString getReadAccessor() const =0
virtual const ArgumentList & argumentList() const =0
virtual bool isWritable() const =0
virtual bool isMaybeAmbiguous() const =0
virtual bool isPrivateGettable() const =0
virtual bool isRequired() const =0
virtual bool isAttribute() const =0
virtual bool isExternal() const =0
virtual bool isCopy() const =0
virtual DString bitfieldString() const =0
virtual bool isStatic() const =0
virtual const MemberDef * reimplements() const =0
virtual bool isMaybeDefault() const =0
virtual bool isPrivateSettable() const =0
virtual bool isRaisable() const =0
virtual bool isRemovable() const =0
virtual bool isConstrained() const =0
virtual DString getWriteAccessor() const =0
virtual bool isReadonly() const =0
virtual bool isBound() const =0
virtual bool isThreadLocal() const =0
virtual DString getScopeString() const =0
virtual const ArgumentList & typeConstraints() const =0
virtual bool isProtectedSettable() const =0
virtual bool isProtectedGettable() const =0
virtual bool hasOneLineInitializer() const =0
virtual bool isTransient() const =0
virtual bool hasMultiLineInitializer() const =0
virtual Protection protection() const =0
virtual bool isOptional() const =0
virtual bool isGettable() const =0
virtual MemberType memberType() const =0
virtual bool isReadable() const =0
virtual bool isWeak() const =0
virtual bool isStrong() const =0
virtual DString typeString() const =0
virtual Specifier virtualness(int count=0) const =0
virtual bool isFinal() const =0
virtual const ArgumentList & declArgumentList() const =0
virtual DString memberTypeName() const =0
virtual bool isMutable() const =0
virtual bool isProperty() const =0
A list of MemberDef objects as shown in documentation sections.
Definition memberlist.h:126
MemberListType listType() const
Definition memberlist.h:131
constexpr bool isDeclaration() const noexcept
Definition types.h:384
constexpr bool isDetailed() const noexcept
Definition types.h:383
virtual const MemberGroupList & getMemberGroups() const =0
virtual const MemberLists & getMemberLists() const =0
virtual FileList getUsedFiles() const =0
virtual const ConceptLinkedRefMap & getConcepts() const =0
virtual const ClassLinkedRefMap & getClasses() const =0
static ModuleManager & instance()
An abstract interface of a namespace symbol.
virtual ConceptLinkedRefMap getConcepts() const =0
virtual const MemberLists & getMemberLists() const =0
virtual NamespaceLinkedRefMap getNamespaces() const =0
virtual DString title() const =0
virtual ClassLinkedRefMap getClasses() const =0
virtual const MemberGroupList & getMemberGroups() const =0
Class representing a list of different code generators.
Definition outputlist.h:162
void add(OutputCodeIntfPtr &&p)
Definition outputlist.h:192
A model of a page symbol.
Definition pagedef.h:27
virtual const PageLinkedRefMap & getSubPages() const =0
virtual DString title() const =0
virtual const GroupDef * getGroupDef() const =0
class that provide information about a section.
Definition section.h:58
DString title() const
Definition section.h:70
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:179
Abstract interface for a hyperlinked text fragment.
Definition linkifytext.h:31
void writeBreak(int) const override
void writeLink(const DString &, const DString &file, const DString &anchor, std::string_view) const override
TextGeneratorSqlite3Impl(StringVector &l)
void writeString(std::string_view, bool) const override
Text streaming class that buffers data.
Definition textstream.h:36
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:232
Concrete visitor implementation for XML output.
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
std::vector< std::string > StringVector
Definition containers.h:33
DString dateToString(DateTimeType includeTime)
Returns the current date, when includeTime is set also the time is provided.
Definition datetime.cpp:64
IDocParserPtr createDocParser()
factory function to create a parser
Definition docparser.cpp:59
IDocNodeASTPtr validatingParseDoc(IDocParser &parserIntf, const DString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const DString &input, const DocOptions &options)
const char * qPrint(const char *s)
Definition dstring.h:783
constexpr uint32_t IncludeKind_ImportMask
Definition filedef.h:62
constexpr uint32_t IncludeKind_LocalMask
Definition filedef.h:60
void linkifyText(const TextGeneratorIntf &out, const DString &text, const LinkifyTextOptions &options)
MemberDef * toMemberDef(Definition *d)
#define msg(fmt,...)
Definition message.h:94
#define err(fmt,...)
Definition message.h:127
SqlStmt memberdef_insert
static bool memberdefExists(struct Refid refid)
static void recordMetadata()
static int prepareStatement(sqlite3 *db, SqlStmt &s)
SqlStmt compounddef_exists
static bool compounddefExists(struct Refid refid)
SqlStmt incl_select
static bool insertMemberReference(struct Refid src_refid, struct Refid dst_refid, const char *context)
#define DBG_CTX(x)
static int initializeTables(sqlite3 *db)
static void stripQualifiers(DString &typeStr)
struct Refid insertRefid(const DString &refid)
static bool memberdefIncomplete(struct Refid refid, const MemberDef *md)
SqlStmt memberdef_incomplete
static void generateSqlite3ForModule(const ModuleDef *mod)
SqlStmt compoundref_insert
static void beginTransaction(sqlite3 *db)
static void generateSqlite3ForConcept(const ConceptDef *cd)
static void insertMemberFunctionParams(int memberdef_id, const MemberDef *md, const Definition *def)
static void writeInnerClasses(const ClassLinkedRefMap &cl, struct Refid outer_refid)
SqlStmt refid_insert
static void generateSqlite3ForGroup(const GroupDef *gd)
static void writeInnerConcepts(const ConceptLinkedRefMap &cl, struct Refid outer_refid)
static void writeInnerGroups(const GroupList &gl, struct Refid outer_refid)
static void writeInnerPages(const PageLinkedRefMap &pl, struct Refid outer_refid)
SqlStmt param_select
static void writeInnerNamespaces(const NamespaceLinkedRefMap &nl, struct Refid outer_refid)
static int prepareStatements(sqlite3 *db)
SqlStmt xrefs_insert
static void writeInnerModules(const ModuleLinkedRefMap &ml, struct Refid outer_refid)
SqlStmt reimplements_insert
static void insertMemberDefineParams(int memberdef_id, const MemberDef *md, const Definition *def)
static void writeTemplateList(const ClassDef *cd)
static void getSQLDesc(SqlStmt &s, const char *col, const DString &value, const Definition *def)
const char * table_schema[][2]
static void endTransaction(sqlite3 *db)
SqlStmt member_insert
static void generateSqlite3Section(const Definition *d, const MemberList *ml, struct Refid scope_refid, const char *, const DString &=DString(), const DString &=DString())
static void associateAllClassMembers(const ClassDef *cd, struct Refid scope_refid)
static void generateSqlite3ForDir(const DirDef *dd)
SqlStmt memberdef_update_def
SqlStmt contains_insert
const char * view_schema[][2]
SqlStmt incl_insert
SqlStmt memberdef_update_decl
static void writeInnerFiles(const FileList &fl, struct Refid outer_refid)
DString getSQLDocBlock(const Definition *scope, const Definition *def, const DString &doc, const DString &fileName, int lineNr)
SqlStmt memberdef_param_insert
static int initializeViews(sqlite3 *db)
SqlStmt path_insert
static int insertPath(DString name, bool local=true, bool found=true, int type=1)
static void getSQLDescCompound(SqlStmt &s, const char *col, const DString &value, const Definition *def)
static bool bindTextParameter(SqlStmt &s, const char *name, const DString &value)
static sqlite3 * openDbConnection()
static void writeTemplateArgumentList(const ArgumentList &al, const Definition *scope, const FileDef *fileScope, const ArgumentList &typeConstraints=ArgumentList())
SqlStmt meta_insert
static void generateSqlite3ForClass(const ClassDef *cd)
static void writeInnerDirs(const DirList &dl, struct Refid outer_refid)
static void generateSqlite3ForNamespace(const NamespaceDef *nd)
SqlStmt memberdef_exists
static void writeMemberTemplateLists(const MemberDef *md)
static void generateSqlite3ForMember(const MemberDef *md, struct Refid scope_refid, const Definition *def)
void generateSqlite3()
static void generateSqlite3ForFile(const FileDef *fd)
SqlStmt path_select
static void generateSqlite3ForPage(const PageDef *pd, bool isExample)
static int step(SqlStmt &s, bool getRowId=false, bool select=false)
SqlStmt param_insert
SqlStmt refid_select
static void pragmaTuning(sqlite3 *db)
SqlStmt compounddef_insert
static bool bindIntParameter(SqlStmt &s, const char *name, int value)
static void associateMember(const MemberDef *md, struct Refid member_refid, struct Refid scope_refid)
Helper class to pass options when calling OutputList::generateDoc().
Definition docoptions.h:24
LinkifyTextOptions & setScope(const Definition *scope)
Definition linkifytext.h:60
LinkifyTextOptions & setSelf(const Definition *self)
Definition linkifytext.h:66
LinkifyTextOptions & setFileScope(const FileDef *fileScope)
Definition linkifytext.h:63
bool created
DString refid
int rowid
const char * query
sqlite3 * db
sqlite3_stmt * stmt
bool mainPageHasTitle()
Definition util.cpp:5095
DString filterTitle(const DString &title)
Definition util.cpp:4590
DString stripFromPath(const DString &path)
Definition util.cpp:219
A bunch of utility functions.