This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdjvu-outline.hh
83 lines (71 loc) · 2.07 KB
/
djvu-outline.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* Copyright © 2015-2022 Jakub Wilk <[email protected]>
*
* This file is part of pdf2djvu.
*
* pdf2djvu is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* pdf2djvu is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#ifndef PDF2DJVU_DJVU_OUTLINE_H
#define PDF2DJVU_DJVU_OUTLINE_H
#include <cstddef>
#include <ostream>
#include <stdexcept>
#include <string>
#include <vector>
namespace djvu
{
class OutlineError
: public std::runtime_error
{
public:
OutlineError();
};
class OutlineItem;
class OutlineBase
{
public:
virtual OutlineItem& add(std::string description, std::string url) = 0;
OutlineBase() = default;
OutlineBase(const OutlineBase &) = default;
virtual ~OutlineBase()
{ }
};
class OutlineItem
: public OutlineBase
{
public:
OutlineItem(const std::string &description, const std::string &url)
: description(description),
url(url)
{ }
OutlineItem& add(std::string description, std::string url);
private:
std::vector<OutlineItem> children;
std::string description;
std::string url;
size_t size() const;
friend std::ostream &operator<<(std::ostream &, const OutlineItem &);
friend class Outline;
};
class Outline
: public OutlineBase
{
private:
std::vector<OutlineItem> items;
size_t size() const;
public:
OutlineItem& add(std::string description, std::string url);
operator bool() const;
friend std::ostream &operator<<(std::ostream &, const Outline &);
};
std::ostream &operator<<(std::ostream &, const OutlineItem &);
std::ostream &operator<<(std::ostream &, const Outline &);
}
#endif
// vim:ts=4 sts=4 sw=4 et