]> git.lyx.org Git - lyx.git/blob - src/author.C
Change the color of the background widget to red.
[lyx.git] / src / author.C
1 /**
2  * \file author.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "author.h"
14
15 #include "support/lstrings.h"
16
17 #include <boost/assert.hpp>
18
19 #include "support/std_istream.h"
20
21 using lyx::support::token;
22 using lyx::support::trim;
23
24 using std::string;
25
26
27 bool operator==(Author const & l, Author const & r)
28 {
29         return l.name() == r.name() && l.email() == r.email();
30 }
31
32
33 std::ostream & operator<<(std::ostream & os, Author const & a)
34 {
35         os << "\"" << a.name() << "\" " << a.email();
36         return os;
37 }
38
39 std::istream & operator>>(std::istream & is, Author & a)
40 {
41         string s;
42         getline(is, s);
43         a.name_ = trim(token(s, '\"', 1));
44         a.email_ = trim(token(s, '\"', 2));
45         return is;
46 }
47
48
49 AuthorList::AuthorList()
50         : last_id_(0)
51 {
52 }
53
54
55 int AuthorList::record(Author const & a)
56 {
57         Authors::const_iterator it(authors_.begin());
58         Authors::const_iterator itend(authors_.end());
59
60         for (;  it != itend; ++it) {
61                 if (it->second == a)
62                         return it->first;
63         }
64
65         authors_[last_id_++] = a;
66         return last_id_ - 1;
67 }
68
69
70 void AuthorList::record(int id, Author const & a)
71 {
72         BOOST_ASSERT(unsigned(id) < authors_.size());
73
74         authors_[id] = a;
75 }
76
77
78 Author const & AuthorList::get(int id)
79 {
80         Authors::const_iterator it(authors_.find(id));
81         BOOST_ASSERT(it != authors_.end());
82         return it->second;
83 }
84
85
86 AuthorList::Authors::const_iterator AuthorList::begin() const
87 {
88         return authors_.begin();
89 }
90
91
92 AuthorList::Authors::const_iterator AuthorList::end() const
93 {
94         return authors_.end();
95 }