Prepare ANNOUNCE and NEWS for rc2
[lyx.git] / src / Author.cpp
blobc2dc6eeb29bed6771c3689ec4b90de08becb4b24
1 /**
2 * \file Author.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author John Levon
8 * Full author contact details are available in file CREDITS.
9 */
11 #include <config.h>
13 #include "Author.h"
15 #include "support/lstrings.h"
17 #include "support/lassert.h"
19 #include <istream>
21 using namespace std;
22 using namespace lyx::support;
24 namespace lyx {
27 bool operator==(Author const & l, Author const & r)
29 return l.name() == r.name() && l.email() == r.email();
33 ostream & operator<<(ostream & os, Author const & a)
35 // FIXME UNICODE
36 os << "\"" << to_utf8(a.name()) << "\" " << to_utf8(a.email());
37 return os;
40 istream & operator>>(istream & is, Author & a)
42 string s;
43 getline(is, s);
44 // FIXME UNICODE
45 a.name_ = from_utf8(trim(token(s, '\"', 1)));
46 a.email_ = from_utf8(trim(token(s, '\"', 2)));
47 return is;
51 AuthorList::AuthorList()
52 : last_id_(0)
57 int AuthorList::record(Author const & a)
59 Authors::const_iterator it(authors_.begin());
60 Authors::const_iterator itend(authors_.end());
62 for (; it != itend; ++it) {
63 if (it->second == a)
64 return it->first;
67 authors_[last_id_++] = a;
68 return last_id_ - 1;
72 void AuthorList::record(int id, Author const & a)
74 LASSERT(unsigned(id) < authors_.size(), /**/);
76 authors_[id] = a;
80 Author const & AuthorList::get(int id) const
82 Authors::const_iterator it(authors_.find(id));
83 LASSERT(it != authors_.end(), /**/);
84 return it->second;
88 AuthorList::Authors::const_iterator AuthorList::begin() const
90 return authors_.begin();
94 AuthorList::Authors::const_iterator AuthorList::end() const
96 return authors_.end();
100 } // namespace lyx