Doxygen
Toggle main menu visibility
Loading...
Searching...
No Matches
anchor.h
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* Copyright (C) 1997-2023 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
#ifndef ANCHOR_H
17
#define ANCHOR_H
18
19
#include <memory>
20
#include <string>
21
22
#include "
construct.h
"
23
24
/** Singleton class used to generate anchors for Markdown headers */
25
class
AnchorGenerator
26
{
27
public
:
28
/** Returns the singleton instance */
29
static
AnchorGenerator
&
instance
();
30
31
/** generates an anchor for a section with \a title.
32
* Returns the anchor.
33
*/
34
std::string
generate
(
const
std::string &title);
35
36
/** Returns true iff \a anchor is one of the generated anchors */
37
bool
isGenerated
(
const
std::string &anchor)
const
;
38
39
/** Reserves a non-generated anchor */
40
int
reserve
(
const
std::string &anchor);
41
42
/** Returns true if \a anchor is a potentially generated anchor.
43
* Note this is a much weaker check than isGenerated() and may not always work.
44
*/
45
static
bool
looksGenerated
(
const
std::string &anchor);
46
47
static
std::string
addPrefixIfNeeded
(
const
std::string &anchor);
48
49
private
:
50
AnchorGenerator
();
51
~AnchorGenerator
();
52
NON_COPYABLE
(
AnchorGenerator
)
53
struct
Private
;
54
std::unique_ptr<Private>
p
;
55
};
56
57
#endif
AnchorGenerator::isGenerated
bool isGenerated(const std::string &anchor) const
Returns true iff anchor is one of the generated anchors.
Definition
anchor.cpp:122
AnchorGenerator::instance
static AnchorGenerator & instance()
Returns the singleton instance.
Definition
anchor.cpp:38
AnchorGenerator::~AnchorGenerator
~AnchorGenerator()
AnchorGenerator::AnchorGenerator
AnchorGenerator()
Definition
anchor.cpp:34
AnchorGenerator::addPrefixIfNeeded
static std::string addPrefixIfNeeded(const std::string &anchor)
Definition
anchor.cpp:46
AnchorGenerator::generate
std::string generate(const std::string &title)
generates an anchor for a section with title.
Definition
anchor.cpp:53
AnchorGenerator::reserve
int reserve(const std::string &anchor)
Reserves a non-generated anchor.
Definition
anchor.cpp:128
AnchorGenerator::looksGenerated
static bool looksGenerated(const std::string &anchor)
Returns true if anchor is a potentially generated anchor.
Definition
anchor.cpp:134
AnchorGenerator::p
std::unique_ptr< Private > p
Definition
anchor.h:54
construct.h
NON_COPYABLE
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition
construct.h:37
AnchorGenerator::Private
Definition
anchor.cpp:27
src
anchor.h
Generated by
1.17.0