]> git.lyx.org Git - lyx.git/blob - src/Author.h
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / Author.h
1 // -*- C++ -*-
2 /**
3  * \file Author.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef AUTHOR_H
13 #define AUTHOR_H
14
15 #include "support/docstring.h"
16
17 #include <vector>
18
19
20 namespace lyx {
21
22 class Author {
23 public:
24         ///
25         Author() : used_(false), buffer_id_(0) {}
26         ///
27         Author(docstring const & name, docstring const & email,
28                docstring const & initials);
29         /// For when the \author line is missing (#9854)
30         Author(int buffer_id);
31         ///
32         docstring name() const { return name_; }
33         ///
34         docstring email() const { return email_; }
35         ///
36         docstring initials() const { return initials_; }
37         ///
38         docstring nameAndEmail() const;
39         ///
40         int bufferId() const { return buffer_id_; }
41         ///
42         void setBufferId(int buffer_id) const { buffer_id_ = buffer_id; }
43         ///
44         void setUsed(bool u) const { used_ = u; }
45         ///
46         bool used() const { return used_; }
47         /// Was the author line not missing?
48         bool valid() const;
49         ///
50         friend std::istream & operator>>(std::istream & os, Author & a);
51         ///
52         friend std::ostream & operator<<(std::ostream & os, Author const & a);
53
54 private:
55         /// The author's name
56         docstring name_;
57         /// The author's email address
58         docstring email_;
59         /// The author's initials
60         docstring initials_;
61         ///
62         mutable bool used_;
63         /// The id of the author in the lyx-file
64         mutable int buffer_id_;
65 };
66
67
68 class AuthorList {
69 public:
70         ///
71         AuthorList();
72         ///
73         int record(Author const & a);
74         ///
75         void record(int id, Author const & a);
76         ///
77         void recordCurrentAuthor(Author const & a);
78         ///
79         Author const & get(int id) const;
80         ///
81         void sort();
82         ///
83         typedef std::vector<Author> Authors;
84         ///
85         Authors::const_iterator begin() const;
86         ///
87         Authors::const_iterator end() const;
88         ///
89         friend
90         std::ostream & operator<<(std::ostream & os, AuthorList const & a);
91 private:
92         ///
93         Authors authors_;
94 };
95
96 bool operator==(Author const & l, Author const & r);
97
98 std::ostream & operator<<(std::ostream & os, Author const & a);
99
100 std::istream & operator>>(std::istream & os, Author & a);
101
102
103 } // namespace lyx
104
105 #endif // AUTHOR_H