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=to_isFunction(md->memberType());
1664
1665 if (isFunc)
1666 {
1667 const ArgumentList &al = md->argumentList();
1670 bindIntParameter(memberdef_insert,":explicit",md->isExplicit());
1675 bindIntParameter(memberdef_insert,":optional",md->isOptional());
1676 bindIntParameter(memberdef_insert,":required",md->isRequired());
1677
1678 bindIntParameter(memberdef_insert,":virt",static_cast<int>(md->virtualness()));
1679 }
1680
1681 if (md->memberType() == MemberType::Variable)
1682 {
1684 bindIntParameter(memberdef_insert,":thread_local",md->isThreadLocal());
1685 bindIntParameter(memberdef_insert,":initonly",md->isInitonly());
1686 bindIntParameter(memberdef_insert,":attribute",md->isAttribute());
1687 bindIntParameter(memberdef_insert,":property",md->isProperty());
1688 bindIntParameter(memberdef_insert,":readonly",md->isReadonly());
1690 bindIntParameter(memberdef_insert,":removable",md->isRemovable());
1691 bindIntParameter(memberdef_insert,":constrained",md->isConstrained());
1692 bindIntParameter(memberdef_insert,":transient",md->isTransient());
1693 bindIntParameter(memberdef_insert,":maybevoid",md->isMaybeVoid());
1694 bindIntParameter(memberdef_insert,":maybedefault",md->isMaybeDefault());
1695 bindIntParameter(memberdef_insert,":maybeambiguous",md->isMaybeAmbiguous());
1696 if (!md->bitfieldString().isEmpty())
1697 {
1698 QCString bitfield = md->bitfieldString();
1699 if (bitfield.at(0)==':') bitfield=bitfield.mid(1);
1700 bindTextParameter(memberdef_insert,":bitfield",bitfield.stripWhiteSpace());
1701 }
1702 }
1703 else if (md->memberType() == MemberType::Property)
1704 {
1705 bindIntParameter(memberdef_insert,":readable",md->isReadable());
1706 bindIntParameter(memberdef_insert,":writable",md->isWritable());
1707 bindIntParameter(memberdef_insert,":gettable",md->isGettable());
1708 bindIntParameter(memberdef_insert,":privategettable",md->isPrivateGettable());
1709 bindIntParameter(memberdef_insert,":protectedgettable",md->isProtectedGettable());
1710 bindIntParameter(memberdef_insert,":settable",md->isSettable());
1711 bindIntParameter(memberdef_insert,":privatesettable",md->isPrivateSettable());
1712 bindIntParameter(memberdef_insert,":protectedsettable",md->isProtectedSettable());
1713
1714 if (md->isAssign() || md->isCopy() || md->isRetain()
1715 || md->isStrong() || md->isWeak())
1716 {
1717 int accessor=0;
1718 if (md->isAssign()) accessor = 1;
1719 else if (md->isCopy()) accessor = 2;
1720 else if (md->isRetain()) accessor = 3;
1721 else if (md->isStrong()) accessor = 4;
1722 else if (md->isWeak()) accessor = 5;
1723
1724 bindIntParameter(memberdef_insert,":accessor",accessor);
1725 }
1728 }
1729 else if (md->memberType() == MemberType::Event)
1730 {
1732 bindIntParameter(memberdef_insert,":removable",md->isRemovable());
1733 bindIntParameter(memberdef_insert,":raisable",md->isRaisable());
1734 }
1735
1736 const MemberDef *rmd = md->reimplements();
1737 if (rmd)
1738 {
1739 QCString qreimplemented_refid = rmd->getOutputFileBase() + "_1" + rmd->anchor();
1740
1741 struct Refid reimplemented_refid = insertRefid(qreimplemented_refid);
1742
1743 bindIntParameter(reimplements_insert,":memberdef_rowid", refid.rowid);
1744 bindIntParameter(reimplements_insert,":reimplemented_rowid", reimplemented_refid.rowid);
1746 }
1747
1748 LinkifyTextOptions options;
1749 options.setScope(def).setFileScope(md->getBodyDef()).setSelf(md);
1750
1751 // + declaration/definition arg lists
1752 if (md->memberType()!=MemberType::Define &&
1753 md->memberType()!=MemberType::Enumeration
1754 )
1755 {
1756 if (md->memberType()!=MemberType::Typedef)
1757 {
1759 }
1760 QCString typeStr = md->typeString();
1761 stripQualifiers(typeStr);
1762 StringVector list;
1763 linkifyText(TextGeneratorSqlite3Impl(list),typeStr,options);
1764 if (!typeStr.isEmpty())
1765 {
1766 bindTextParameter(memberdef_insert,":type",typeStr);
1767 }
1768
1769 if (!md->definition().isEmpty())
1770 {
1771 bindTextParameter(memberdef_insert,":definition",md->definition());
1772 }
1773
1774 if (!md->argsString().isEmpty())
1775 {
1776 bindTextParameter(memberdef_insert,":argsstring",md->argsString());
1777 }
1778 }
1779
1781
1782 // Extract references from initializer
1784 {
1785 bindTextParameter(memberdef_insert,":initializer",md->initializer());
1786
1787 StringVector list;
1789 for (const auto &s : list)
1790 {
1791 if (md->getBodyDef())
1792 {
1793 DBG_CTX(("initializer:%s %s %s %d\n",
1794 qPrint(md->anchor()),
1795 qPrint(s),
1797 md->getStartBodyLine()));
1798 QCString qsrc_refid = md->getOutputFileBase() + "_1" + md->anchor();
1799 struct Refid src_refid = insertRefid(qsrc_refid);
1800 struct Refid dst_refid = insertRefid(s);
1801 insertMemberReference(src_refid,dst_refid, "initializer");
1802 }
1803 }
1804 }
1805
1806 if ( !md->getScopeString().isEmpty() )
1807 {
1809 }
1810
1811 // +Brief, detailed and inbody description
1812 getSQLDesc(memberdef_insert,":briefdescription",md->briefDescription(),md);
1813 getSQLDesc(memberdef_insert,":detaileddescription",md->documentation(),md);
1814 getSQLDesc(memberdef_insert,":inbodydescription",md->inbodyDocumentation(),md);
1815
1816 // File location
1817 if (md->getDefLine() != -1)
1818 {
1819 int file_id = insertPath(md->getDefFileName(),!md->isReference());
1820 if (file_id!=-1)
1821 {
1822 bindIntParameter(memberdef_insert,":file_id",file_id);
1825
1826 // definitions also have bodyfile/start/end
1827 if (md->getStartBodyLine()!=-1)
1828 {
1829 int bodyfile_id = insertPath(md->getBodyDef()->absFilePath(),!md->getBodyDef()->isReference());
1830 if (bodyfile_id == -1)
1831 {
1832 sqlite3_clear_bindings(memberdef_insert.stmt);
1833 }
1834 else
1835 {
1836 bindIntParameter(memberdef_insert,":bodyfile_id",bodyfile_id);
1839 }
1840 }
1841 }
1842 }
1843
1844 int memberdef_id=step(memberdef_insert,TRUE);
1845
1846 if (isFunc)
1847 {
1848 insertMemberFunctionParams(memberdef_id,md,def);
1849 }
1850 else if (md->memberType()==MemberType::Define &&
1851 !md->argsString().isEmpty())
1852 {
1853 insertMemberDefineParams(memberdef_id,md,def);
1854 }
1855
1856 // + source references
1857 // The cross-references in initializers only work when both the src and dst
1858 // are defined.
1859 for (const auto &refmd : md->getReferencesMembers())
1860 {
1861 insertMemberReference(md,refmd, "inline");
1862 }
1863 // + source referenced by
1864 for (const auto &refmd : md->getReferencedByMembers())
1865 {
1866 insertMemberReference(refmd,md, "inline");
1867 }
1868}
1869
1871 const MemberList *ml,
1872 struct Refid scope_refid,
1873 const char * /*kind*/,
1874 const QCString & /*header*/=QCString(),
1875 const QCString & /*documentation*/=QCString())
1876{
1877 if (ml==nullptr) return;
1878 for (const auto &md : *ml)
1879 {
1880 // TODO: necessary? just tracking what xmlgen does; xmlgen says:
1881 // namespace members are also inserted in the file scope, but
1882 // to prevent this duplication in the XML output, we filter those here.
1883 if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==nullptr)
1884 {
1885 generateSqlite3ForMember(md, scope_refid, d);
1886 }
1887 }
1888}
1889
1890static void associateAllClassMembers(const ClassDef *cd, struct Refid scope_refid)
1891{
1892 for (auto &mni : cd->memberNameInfoLinkedMap())
1893 {
1894 for (auto &mi : *mni)
1895 {
1896 const MemberDef *md = mi->memberDef();
1897 QCString qrefid = md->getOutputFileBase() + "_1" + md->anchor();
1898 associateMember(md, insertRefid(qrefid), scope_refid);
1899 }
1900 }
1901}
1902
1903// many kinds: category class enum exception interface
1904// module protocol service singleton struct type union
1905// enum is Java only (and is distinct from enum memberdefs)
1906static void generateSqlite3ForClass(const ClassDef *cd)
1907{
1908 // NOTE: Skeptical about XML's version of these
1909 // 'x' marks missing items XML claims to include
1910
1911 // + brief description
1912 // + detailed description
1913 // + template argument list(s)
1914 // + include file
1915 // + member groups
1916 // x inheritance DOT diagram
1917 // + list of direct super classes
1918 // + list of direct sub classes
1919 // + list of inner classes
1920 // x collaboration DOT diagram
1921 // + list of all members
1922 // x user defined member sections
1923 // x standard member sections
1924 // x detailed member documentation
1925 // - examples using the class
1926
1927 if (cd->isReference()) return; // skip external references.
1928 if (cd->isHidden()) return; // skip hidden classes.
1929 if (cd->isAnonymous()) return; // skip anonymous compounds.
1930 if (cd->isImplicitTemplateInstance()) return; // skip generated template instances.
1931
1932 struct Refid refid = insertRefid(cd->getOutputFileBase());
1933
1934 // can omit a class that already has a refid
1935 if(!refid.created && compounddefExists(refid)){return;}
1936
1937 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
1938
1942 bindIntParameter(compounddef_insert,":prot",static_cast<int>(cd->protection()));
1943
1944 int file_id = insertPath(cd->getDefFileName());
1945 bindIntParameter(compounddef_insert,":file_id",file_id);
1948
1949 // + include file
1950 /*
1951 TODO: I wonder if this can actually be cut (just here)
1952
1953 We were adding this "include" to the "includes" table alongside
1954 other includes (from a FileDef). However, FileDef and ClassDef are using
1955 "includes" nodes in very a different way:
1956 - With FileDef, it means the file includes another.
1957 - With ClassDef, it means you should include this file to use this class.
1958
1959 Because of this difference, I added a column to compounddef, header_id, and
1960 linked it back to the appropriate file. We could just add a nullable text
1961 column that would hold a string equivalent to what the HTML docs include,
1962 but the logic for generating it is embedded in
1963 ClassDef::writeIncludeFiles(OutputList &ol).
1964
1965 That said, at least on the handful of test sets I have, header_id == file_id,
1966 suggesting it could be cut and clients might be able to reconstruct it from
1967 other values if there's a solid heuristic for *when a class will
1968 have a header file*.
1969 */
1970 const IncludeInfo *ii=cd->includeInfo();
1971 if (ii)
1972 {
1973 QCString nm = ii->includeName;
1974 if (nm.isEmpty() && ii->fileDef) nm = ii->fileDef->docName();
1975 if (!nm.isEmpty())
1976 {
1977 int header_id=-1;
1978 if (ii->fileDef)
1979 {
1981 }
1982 DBG_CTX(("-----> ClassDef includeInfo for %s\n", qPrint(nm)));
1983 DBG_CTX((" local : %d\n", ii->local));
1984 DBG_CTX((" imported : %d\n", ii->imported));
1985 if (ii->fileDef)
1986 {
1987 DBG_CTX(("header: %s\n", qPrint(ii->fileDef->absFilePath())));
1988 }
1989 DBG_CTX((" file_id : %d\n", file_id));
1990 DBG_CTX((" header_id: %d\n", header_id));
1991
1992 if(header_id!=-1)
1993 {
1994 bindIntParameter(compounddef_insert,":header_id",header_id);
1995 }
1996 }
1997 }
1998
1999 getSQLDescCompound(compounddef_insert,":briefdescription",cd->briefDescription(),cd);
2000 getSQLDescCompound(compounddef_insert,":detaileddescription",cd->documentation(),cd);
2001
2003
2004 // + list of direct super classes
2005 for (const auto &bcd : cd->baseClasses())
2006 {
2007 struct Refid base_refid = insertRefid(bcd.classDef->getOutputFileBase());
2008 struct Refid derived_refid = insertRefid(cd->getOutputFileBase());
2009 bindIntParameter(compoundref_insert,":base_rowid", base_refid.rowid);
2010 bindIntParameter(compoundref_insert,":derived_rowid", derived_refid.rowid);
2011 bindIntParameter(compoundref_insert,":prot",static_cast<int>(bcd.prot));
2012 bindIntParameter(compoundref_insert,":virt",static_cast<int>(bcd.virt));
2014 }
2015
2016 // + list of direct sub classes
2017 for (const auto &bcd : cd->subClasses())
2018 {
2019 struct Refid derived_refid = insertRefid(bcd.classDef->getOutputFileBase());
2020 struct Refid base_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 inner classes
2030
2031 // + template argument list(s)
2033
2034 // + member groups
2035 for (const auto &mg : cd->getMemberGroups())
2036 {
2037 generateSqlite3Section(cd,&mg->members(),refid,"user-defined",mg->header(),
2038 mg->documentation());
2039 }
2040
2041 // this is just a list of *local* members
2042 for (const auto &ml : cd->getMemberLists())
2043 {
2044 if (!ml->listType().isDetailed())
2045 {
2046 generateSqlite3Section(cd,ml.get(),refid,"user-defined");
2047 }
2048 }
2049
2050 // + list of all members
2052}
2053
2055{
2056 if (cd->isReference() || cd->isHidden()) return; // skip external references
2057
2058 struct Refid refid = insertRefid(cd->getOutputFileBase());
2059 if(!refid.created && compounddefExists(refid)){return;}
2060 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2062 bindTextParameter(compounddef_insert,":kind","concept");
2063
2064 int file_id = insertPath(cd->getDefFileName());
2065 bindIntParameter(compounddef_insert,":file_id",file_id);
2068
2069 getSQLDescCompound(compounddef_insert,":briefdescription",cd->briefDescription(),cd);
2070 getSQLDescCompound(compounddef_insert,":detaileddescription",cd->documentation(),cd);
2071
2073
2074 // + template argument list(s)
2076}
2077
2079{
2080 // + contained class definitions
2081 // + contained concept definitions
2082 // + member groups
2083 // + normal members
2084 // + brief desc
2085 // + detailed desc
2086 // + location (file_id, line, column)
2087 // - exports
2088 // + used files
2089
2090 if (mod->isReference() || mod->isHidden()) return;
2091 struct Refid refid = insertRefid(mod->getOutputFileBase());
2092 if(!refid.created && compounddefExists(refid)){return;}
2093 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2095 bindTextParameter(compounddef_insert,":kind","module");
2096
2097 int file_id = insertPath(mod->getDefFileName());
2098 bindIntParameter(compounddef_insert,":file_id",file_id);
2101
2102 getSQLDescCompound(compounddef_insert,":briefdescription",mod->briefDescription(),mod);
2103 getSQLDescCompound(compounddef_insert,":detaileddescription",mod->documentation(),mod);
2104
2106
2107 // + contained class definitions
2109
2110 // + contained concept definitions
2112
2113 // + member groups
2114 for (const auto &mg : mod->getMemberGroups())
2115 {
2116 generateSqlite3Section(mod,&mg->members(),refid,"user-defined",mg->header(),
2117 mg->documentation());
2118 }
2119
2120 // + normal members
2121 for (const auto &ml : mod->getMemberLists())
2122 {
2123 if (ml->listType().isDeclaration())
2124 {
2125 generateSqlite3Section(mod,ml.get(),refid,"user-defined");
2126 }
2127 }
2128
2129 // + files
2131}
2132
2133// kinds: constants library module namespace package
2135{
2136 // + contained class definitions
2137 // + contained namespace definitions
2138 // + member groups
2139 // + normal members
2140 // + brief desc
2141 // + detailed desc
2142 // + location (file_id, line, column)
2143 // - files containing (parts of) the namespace definition
2144
2145 if (nd->isReference() || nd->isHidden()) return; // skip external references
2146 struct Refid refid = insertRefid(nd->getOutputFileBase());
2147 if(!refid.created && compounddefExists(refid)){return;}
2148 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2149
2152 bindTextParameter(compounddef_insert,":kind","namespace");
2153
2154 int file_id = insertPath(nd->getDefFileName());
2155 bindIntParameter(compounddef_insert,":file_id",file_id);
2158
2159 getSQLDescCompound(compounddef_insert,":briefdescription",nd->briefDescription(),nd);
2160 getSQLDescCompound(compounddef_insert,":detaileddescription",nd->documentation(),nd);
2161
2163
2164 // + contained class definitions
2166
2167 // + contained concept definitions
2169
2170 // + contained namespace definitions
2172
2173 // + member groups
2174 for (const auto &mg : nd->getMemberGroups())
2175 {
2176 generateSqlite3Section(nd,&mg->members(),refid,"user-defined",mg->header(),
2177 mg->documentation());
2178 }
2179
2180 // + normal members
2181 for (const auto &ml : nd->getMemberLists())
2182 {
2183 if (ml->listType().isDeclaration())
2184 {
2185 generateSqlite3Section(nd,ml.get(),refid,"user-defined");
2186 }
2187 }
2188}
2189
2190// kind: file
2191static void generateSqlite3ForFile(const FileDef *fd)
2192{
2193 // + includes files
2194 // + includedby files
2195 // x include graph
2196 // x included by graph
2197 // + contained class definitions
2198 // + contained namespace definitions
2199 // + member groups
2200 // + normal members
2201 // + brief desc
2202 // + detailed desc
2203 // x source code
2204 // + location (file_id, line, column)
2205 // - number of lines
2206
2207 if (fd->isReference()) return; // skip external references
2208
2209 struct Refid refid = insertRefid(fd->getOutputFileBase());
2210 if(!refid.created && compounddefExists(refid)){return;}
2211 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2212
2215 bindTextParameter(compounddef_insert,":kind","file");
2216
2217 int file_id = insertPath(fd->getDefFileName());
2218 bindIntParameter(compounddef_insert,":file_id",file_id);
2221
2222 getSQLDesc(compounddef_insert,":briefdescription",fd->briefDescription(),fd);
2223 getSQLDesc(compounddef_insert,":detaileddescription",fd->documentation(),fd);
2224
2226
2227 // + includes files
2228 for (const auto &ii : fd->includeFileList())
2229 {
2230 int src_id=insertPath(fd->absFilePath(),!fd->isReference());
2231 int dst_id=0;
2232 QCString dst_path;
2233 bool isLocal = (ii.kind & IncludeKind_LocalMask)!=0;
2234
2235 if(ii.fileDef) // found file
2236 {
2237 if(ii.fileDef->isReference())
2238 {
2239 // strip tagfile from path
2240 QCString tagfile = ii.fileDef->getReference();
2241 dst_path = ii.fileDef->absFilePath();
2242 dst_path.stripPrefix(tagfile+":");
2243 }
2244 else
2245 {
2246 dst_path = ii.fileDef->absFilePath();
2247 }
2248 dst_id = insertPath(dst_path,isLocal);
2249 }
2250 else // can't find file
2251 {
2252 dst_id = insertPath(ii.includeName,isLocal,FALSE);
2253 }
2254
2255 DBG_CTX(("-----> FileDef includeInfo for %s\n", qPrint(ii.includeName)));
2256 DBG_CTX((" local: %d\n", isLocal));
2257 DBG_CTX((" imported: %d\n", (ii.kind & IncludeKind_ImportMask)!=0));
2258 if(ii.fileDef)
2259 {
2260 DBG_CTX(("include: %s\n", qPrint(ii.fileDef->absFilePath())));
2261 }
2262 DBG_CTX((" src_id : %d\n", src_id));
2263 DBG_CTX((" dst_id: %d\n", dst_id));
2264
2265 bindIntParameter(incl_select,":local",isLocal);
2266 bindIntParameter(incl_select,":src_id",src_id);
2267 bindIntParameter(incl_select,":dst_id",dst_id);
2268 if (step(incl_select,TRUE,TRUE)==0) {
2269 bindIntParameter(incl_insert,":local",isLocal);
2270 bindIntParameter(incl_insert,":src_id",src_id);
2271 bindIntParameter(incl_insert,":dst_id",dst_id);
2273 }
2274 }
2275
2276 // + includedby files
2277 for (const auto &ii : fd->includedByFileList())
2278 {
2279 int dst_id=insertPath(fd->absFilePath(),!fd->isReference());
2280 int src_id=0;
2281 QCString src_path;
2282 bool isLocal = (ii.kind & IncludeKind_LocalMask)!=0;
2283
2284 if(ii.fileDef) // found file
2285 {
2286 if(ii.fileDef->isReference())
2287 {
2288 // strip tagfile from path
2289 QCString tagfile = ii.fileDef->getReference();
2290 src_path = ii.fileDef->absFilePath();
2291 src_path.stripPrefix(tagfile+":");
2292 }
2293 else
2294 {
2295 src_path = ii.fileDef->absFilePath();
2296 }
2297 src_id = insertPath(src_path,isLocal);
2298 }
2299 else // can't find file
2300 {
2301 src_id = insertPath(ii.includeName,isLocal,FALSE);
2302 }
2303
2304 bindIntParameter(incl_select,":local",isLocal);
2305 bindIntParameter(incl_select,":src_id",src_id);
2306 bindIntParameter(incl_select,":dst_id",dst_id);
2307 if (step(incl_select,TRUE,TRUE)==0) {
2308 bindIntParameter(incl_insert,":local",isLocal);
2309 bindIntParameter(incl_insert,":src_id",src_id);
2310 bindIntParameter(incl_insert,":dst_id",dst_id);
2312 }
2313 }
2314
2315 // + contained class definitions
2317
2318 // + contained concept definitions
2320
2321 // + contained namespace definitions
2323
2324 // + member groups
2325 for (const auto &mg : fd->getMemberGroups())
2326 {
2327 generateSqlite3Section(fd,&mg->members(),refid,"user-defined",mg->header(),
2328 mg->documentation());
2329 }
2330
2331 // + normal members
2332 for (const auto &ml : fd->getMemberLists())
2333 {
2334 if (ml->listType().isDeclaration())
2335 {
2336 generateSqlite3Section(fd,ml.get(),refid,"user-defined");
2337 }
2338 }
2339}
2340
2341// kind: group
2342static void generateSqlite3ForGroup(const GroupDef *gd)
2343{
2344 // + members
2345 // + member groups
2346 // + files
2347 // + classes
2348 // + namespaces
2349 // - packages
2350 // + pages
2351 // + child groups
2352 // - examples
2353 // + brief description
2354 // + detailed description
2355
2356 if (gd->isReference()) return; // skip external references.
2357
2358 struct Refid refid = insertRefid(gd->getOutputFileBase());
2359 if(!refid.created && compounddefExists(refid)){return;}
2360 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2361
2364 bindTextParameter(compounddef_insert,":kind","group");
2365
2366 int file_id = insertPath(gd->getDefFileName());
2367 bindIntParameter(compounddef_insert,":file_id",file_id);
2370
2371 getSQLDesc(compounddef_insert,":briefdescription",gd->briefDescription(),gd);
2372 getSQLDesc(compounddef_insert,":detaileddescription",gd->documentation(),gd);
2373
2375
2376 // + files
2378
2379 // + classes
2381
2382 // + concepts
2384
2385 // + modules
2387
2388 // + namespaces
2390
2391 // + pages
2393
2394 // + groups
2396
2397 // + member groups
2398 for (const auto &mg : gd->getMemberGroups())
2399 {
2400 generateSqlite3Section(gd,&mg->members(),refid,"user-defined",mg->header(),
2401 mg->documentation());
2402 }
2403
2404 // + members
2405 for (const auto &ml : gd->getMemberLists())
2406 {
2407 if (ml->listType().isDeclaration())
2408 {
2409 generateSqlite3Section(gd,ml.get(),refid,"user-defined");
2410 }
2411 }
2412}
2413
2414// kind: dir
2415static void generateSqlite3ForDir(const DirDef *dd)
2416{
2417 // + dirs
2418 // + files
2419 // + briefdescription
2420 // + detaileddescription
2421 // + location (below uses file_id, line, column; XML just uses file)
2422 if (dd->isReference()) return; // skip external references
2423
2424 struct Refid refid = insertRefid(dd->getOutputFileBase());
2425 if(!refid.created && compounddefExists(refid)){return;}
2426 bindIntParameter(compounddef_insert,":rowid", refid.rowid);
2427
2430
2431 int file_id = insertPath(dd->getDefFileName(),TRUE,TRUE,2);
2432 bindIntParameter(compounddef_insert,":file_id",file_id);
2433
2434 /*
2435 line and column are weird here, but:
2436 - dir goes into compounddef with all of the others
2437 - the semantics would be fine if we set them to NULL here
2438 - but defining line and column as NOT NULL is an important promise
2439 for other compounds, so I don't want to loosen it
2440
2441 For reference, the queries return 1.
2442 0 or -1 make more sense, but I see that as a change for DirDef.
2443 */
2446
2447 getSQLDesc(compounddef_insert,":briefdescription",dd->briefDescription(),dd);
2448 getSQLDesc(compounddef_insert,":detaileddescription",dd->documentation(),dd);
2449
2451
2452 // + files
2454
2455 // + files
2457}
2458
2459// kinds: page, example
2460static void generateSqlite3ForPage(const PageDef *pd,bool isExample)
2461{
2462 // + name
2463 // + title
2464 // + brief description
2465 // + documentation (detailed description)
2466 // + inbody documentation
2467 // + sub pages
2468 if (pd->isReference()) return; // skip external references.
2469
2470 // TODO: do we more special handling if isExample?
2471
2472 QCString qrefid = pd->getOutputFileBase();
2473 if (pd->getGroupDef())
2474 {
2475 qrefid+="_"+pd->name();
2476 }
2477 if (qrefid=="index") qrefid="indexpage"; // to prevent overwriting the generated index page.
2478
2479 struct Refid refid = insertRefid(qrefid);
2480
2481 // can omit a page that already has a refid
2482 if(!refid.created && compounddefExists(refid)){return;}
2483
2485 // + name
2487
2488 QCString title;
2489 if (pd==Doxygen::mainPage.get()) // main page is special
2490 {
2491 if (mainPageHasTitle())
2492 {
2494 }
2495 else
2496 {
2497 title = Config_getString(PROJECT_NAME);
2498 }
2499 }
2500 else
2501 {
2503 if (si)
2504 {
2505 title = si->title();
2506 }
2507 if (title.isEmpty())
2508 {
2509 title = pd->title();
2510 }
2511 }
2512
2513 // + title
2514 bindTextParameter(compounddef_insert,":title",title);
2515
2516 bindTextParameter(compounddef_insert,":kind", isExample ? "example" : "page");
2517
2518 int file_id = insertPath(pd->getDefFileName());
2519
2520 bindIntParameter(compounddef_insert,":file_id",file_id);
2523
2524 // + brief description
2525 getSQLDesc(compounddef_insert,":briefdescription",pd->briefDescription(),pd);
2526 // + documentation (detailed description)
2527 getSQLDesc(compounddef_insert,":detaileddescription",pd->documentation(),pd);
2528
2530 // + sub pages
2532}
2533
2534
2535static sqlite3* openDbConnection()
2536{
2537
2538 QCString outputDirectory = Config_getString(SQLITE3_OUTPUT);
2539 sqlite3 *db = nullptr;
2540
2541 int rc = sqlite3_initialize();
2542 if (rc != SQLITE_OK)
2543 {
2544 err("sqlite3_initialize failed\n");
2545 return nullptr;
2546 }
2547
2548 std::string dbFileName = "doxygen_sqlite3.db";
2549 FileInfo fi(outputDirectory.str()+"/"+dbFileName);
2550
2551 if (fi.exists())
2552 {
2553 if (Config_getBool(SQLITE3_RECREATE_DB))
2554 {
2555 Dir().remove(fi.absFilePath());
2556 }
2557 else
2558 {
2559 err("doxygen_sqlite3.db already exists! Rename, remove, or archive it to regenerate\n");
2560 return nullptr;
2561 }
2562 }
2563
2564 rc = sqlite3_open_v2(
2565 fi.absFilePath().c_str(),
2566 &db,
2567 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
2568 nullptr
2569 );
2570 if (rc != SQLITE_OK)
2571 {
2572 sqlite3_close(db);
2573 err("Database open failed: doxygen_sqlite3.db\n");
2574 }
2575 return db;
2576}
2577//////////////////////////////////////////////////////////////////////////////
2578//////////////////////////////////////////////////////////////////////////////
2580{
2581 // + classes
2582 // + namespaces
2583 // + files
2584 // + groups
2585 // + related pages
2586 // + examples
2587 // + main page
2588 sqlite3 *db = openDbConnection();
2589 if (db==nullptr)
2590 {
2591 return;
2592 }
2593
2594# ifdef SQLITE3_DEBUG
2595 // debug: show all executed statements
2596 sqlite3_trace(db, &sqlLog, nullptr);
2597# endif
2598
2599 beginTransaction(db);
2600 pragmaTuning(db);
2601
2602 if (-1==initializeTables(db))
2603 return;
2604
2605 if ( -1 == prepareStatements(db) )
2606 {
2607 err("sqlite generator: prepareStatements failed!\n");
2608 return;
2609 }
2610
2612
2613 // + classes
2614 for (const auto &cd : *Doxygen::classLinkedMap)
2615 {
2616 msg("Generating Sqlite3 output for class {}\n",cd->name());
2617 generateSqlite3ForClass(cd.get());
2618 }
2619
2620 // + concepts
2621 for (const auto &cd : *Doxygen::conceptLinkedMap)
2622 {
2623 msg("Generating Sqlite3 output for concept {}\n",cd->name());
2624 generateSqlite3ForConcept(cd.get());
2625 }
2626
2627 // + modules
2628 for (const auto &mod : ModuleManager::instance().modules())
2629 {
2630 msg("Generating Sqlite3 output for module {}\n",mod->name());
2631 generateSqlite3ForModule(mod.get());
2632 }
2633
2634 // + namespaces
2635 for (const auto &nd : *Doxygen::namespaceLinkedMap)
2636 {
2637 msg("Generating Sqlite3 output for namespace {}\n",nd->name());
2639 }
2640
2641 // + files
2642 for (const auto &fn : *Doxygen::inputNameLinkedMap)
2643 {
2644 for (const auto &fd : *fn)
2645 {
2646 msg("Generating Sqlite3 output for file {}\n",fd->name());
2647 generateSqlite3ForFile(fd.get());
2648 }
2649 }
2650
2651 // + groups
2652 for (const auto &gd : *Doxygen::groupLinkedMap)
2653 {
2654 msg("Generating Sqlite3 output for group {}\n",gd->name());
2655 generateSqlite3ForGroup(gd.get());
2656 }
2657
2658 // + page
2659 for (const auto &pd : *Doxygen::pageLinkedMap)
2660 {
2661 msg("Generating Sqlite3 output for page {}\n",pd->name());
2662 generateSqlite3ForPage(pd.get(),FALSE);
2663 }
2664
2665 // + dirs
2666 for (const auto &dd : *Doxygen::dirLinkedMap)
2667 {
2668 msg("Generating Sqlite3 output for dir {}\n",dd->name());
2669 generateSqlite3ForDir(dd.get());
2670 }
2671
2672 // + examples
2673 for (const auto &pd : *Doxygen::exampleLinkedMap)
2674 {
2675 msg("Generating Sqlite3 output for example {}\n",pd->name());
2676 generateSqlite3ForPage(pd.get(),TRUE);
2677 }
2678
2679 // + main page
2681 {
2682 msg("Generating Sqlite3 output for the main page\n");
2684 }
2685
2686 // TODO: copied from initializeSchema; not certain if we should say/do more
2687 // if there's a failure here?
2688 if (-1==initializeViews(db))
2689 return;
2690
2691 endTransaction(db);
2692}
2693
2694// 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:1471
static NamespaceLinkedMap * namespaceLinkedMap
Definition doxygen.h:115
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:127
static GroupLinkedMap * groupLinkedMap
Definition doxygen.h:114
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:103
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:245
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:597
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:167
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:264
const std::string & str() const
Definition qcstring.h:556
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:176
bool stripPrefix(const QCString &prefix)
Definition qcstring.h:217
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:691
#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
static constexpr bool to_isFunction(MemberType mt) noexcept
Definition types.h:599
bool mainPageHasTitle()
Definition util.cpp:6302
QCString filterTitle(const QCString &title)
Definition util.cpp:5650
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:4068
A bunch of utility functions.