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