Doxygen
Loading...
Searching...
No Matches
cite.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 2020 by Dimitri van Heesch
4 * Based on a patch by David Munger
5 *
6 * Permission to use, copy, modify, and distribute this software and its
7 * documentation under the terms of the GNU General Public License is hereby
8 * granted. No representations are made about the suitability of this software
9 * for any purpose. It is provided "as is" without express or implied warranty.
10 * See the GNU General Public License for more details.
11 *
12 * Documents produced by Doxygen are derivative works derived from the
13 * input used in their production; they are not affected by this license.
14 *
15 */
16
17#ifndef CITE_H
18#define CITE_H
19
20#include <memory>
21
22#include "qcstring.h"
23#include "construct.h"
24
26{
27 public:
28 constexpr CiteInfoOption() {}
29 static constexpr CiteInfoOption makeNumber() { return CiteInfoOption(NUMBER); }
31 static constexpr CiteInfoOption makeYear() { return CiteInfoOption(YEAR); }
32
33 constexpr void changeToNumber() noexcept { m_bits = (m_bits & OptionMask) | NUMBER; }
34 constexpr void setNoPar() noexcept { m_bits |= NOPAR_BIT; }
35 constexpr void setNoCite() noexcept { m_bits |= NOCITE_BIT; }
36
37 constexpr bool isUnknown() const noexcept { return (m_bits & TypeMask)==0; }
38 constexpr bool isNumber() const noexcept { return (m_bits & NUMBER)!=0; }
39 constexpr bool isShortAuthor() const noexcept { return (m_bits & SHORTAUTHOR)!=0; }
40 constexpr bool isYear() const noexcept { return (m_bits & YEAR)!=0; }
41
42 constexpr bool noPar() const noexcept { return (m_bits & NOPAR_BIT)!=0; }
43 constexpr bool noCite() const noexcept { return (m_bits & NOCITE_BIT)!=0; }
44
45 friend inline bool operator==(const CiteInfoOption &t1,const CiteInfoOption &t2) { return t1.m_bits==t2.m_bits; }
46 friend inline bool operator!=(const CiteInfoOption &t1,const CiteInfoOption &t2) { return !(operator==(t1,t2)); }
47
48 private:
49 constexpr CiteInfoOption(int bits) : m_bits(bits) {}
50
51 enum Bits
52 {
54 NUMBER = (1<<0),
55 SHORTAUTHOR = (1<<1),
56 YEAR = (1<<2),
57
58 TypeMask = 0x0000FFFF,
59 OptionMask = 0xFFFF0000,
60
61 NOPAR_BIT = (1<<16), //< Don't use square brackets
62 NOCITE_BIT = (1<<17) //< Don't create a link
63 };
64 unsigned int m_bits = UNKNOWN;
65};
66
67
68/// Citation-related data.
70{
72
73 virtual QCString label() const = 0;
74 virtual QCString text() const = 0;
75 virtual QCString shortAuthor() const = 0;
76 virtual QCString year() const = 0;
77};
78
79/**
80 * @brief Citation manager class.
81 * @details This class provides access do the database of bibliographic
82 * references through the bibtex backend.
83 */
85{
86 public:
87 static CitationManager &instance();
88
89 /** Insert a citation identified by \a label into the database */
90 void insert(const QCString &label);
91
92 /** Return the citation info for a given \a label.
93 * Ownership of the info stays with the manager.
94 */
95 const CiteInfo *find(const QCString &label) const;
96
97 /** Generate the citations page */
98 void generatePage();
99
100 /** clears the database */
101 void clear();
102
103 /** return TRUE if there are no citations.
104 */
105 bool isEmpty() const;
106
107 /** lists the bibtex cite files in a comma separated list
108 */
110
111 QCString fileName() const;
112 QCString anchorPrefix() const;
113
114 private:
115 /** Create the database, with an expected maximum of \a size entries */
117 ~CitationManager() = default;
119 void insertCrossReferencesForBibFile(const QCString &bibFile);
120 QCString getFormulas(const QCString &s);
122 struct Private;
123 std::unique_ptr<Private> p;
124};
125
126#endif // CITE_H
void insertCrossReferencesForBibFile(const QCString &bibFile)
Definition cite.cpp:132
QCString anchorPrefix() const
Definition cite.cpp:127
std::unique_ptr< Private > p
Definition cite.h:123
const CiteInfo * find(const QCString &label) const
Return the citation info for a given label.
Definition cite.cpp:102
QCString latexBibFiles()
lists the bibtex cite files in a comma separated list
Definition cite.cpp:576
static CitationManager & instance()
Definition cite.cpp:86
void clear()
clears the database
Definition cite.cpp:111
QCString replaceFormulas(const QCString &s)
Definition cite.cpp:312
~CitationManager()=default
void insert(const QCString &label)
Insert a citation identified by label into the database.
Definition cite.cpp:96
CitationManager()
Create the database, with an expected maximum of size entries.
Definition cite.cpp:92
QCString fileName() const
Definition cite.cpp:122
bool isEmpty() const
return TRUE if there are no citations.
Definition cite.cpp:116
void generatePage()
Generate the citations page.
Definition cite.cpp:332
QCString getFormulas(const QCString &s)
Definition cite.cpp:237
constexpr void setNoCite() noexcept
Definition cite.h:35
@ SHORTAUTHOR
Definition cite.h:55
constexpr bool isShortAuthor() const noexcept
Definition cite.h:39
constexpr bool isNumber() const noexcept
Definition cite.h:38
friend bool operator!=(const CiteInfoOption &t1, const CiteInfoOption &t2)
Definition cite.h:46
constexpr bool isYear() const noexcept
Definition cite.h:40
constexpr bool noPar() const noexcept
Definition cite.h:42
constexpr CiteInfoOption()
Definition cite.h:28
static constexpr CiteInfoOption makeNumber()
Definition cite.h:29
constexpr CiteInfoOption(int bits)
Definition cite.h:49
constexpr void changeToNumber() noexcept
Definition cite.h:33
constexpr void setNoPar() noexcept
Definition cite.h:34
friend bool operator==(const CiteInfoOption &t1, const CiteInfoOption &t2)
Definition cite.h:45
constexpr bool noCite() const noexcept
Definition cite.h:43
constexpr bool isUnknown() const noexcept
Definition cite.h:37
unsigned int m_bits
Definition cite.h:64
static constexpr CiteInfoOption makeYear()
Definition cite.h:31
static constexpr CiteInfoOption makeShortAuthor()
Definition cite.h:30
This is an alternative implementation of QCString.
Definition qcstring.h:101
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37
#define ABSTRACT_BASE_CLASS(cls)
Macro to implement rule of 5 for an abstract base class.
Definition construct.h:20
Citation-related data.
Definition cite.h:70
virtual QCString text() const =0
virtual QCString shortAuthor() const =0
virtual QCString label() const =0
virtual QCString year() const =0