X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fauthor.C;h=a81b67325c66523f67643cb055bc69a644dedc0b;hb=17cc48720a11a3ed65d9de29d5e7a2d29f9a41f0;hp=2cbd6986feef63f9fe5ea7e71cb1468fbd09cb05;hpb=ae87b945156585b080ed155919f64b80e48d7a04;p=lyx.git diff --git a/src/author.C b/src/author.C index 2cbd6986fe..a81b67325c 100644 --- a/src/author.C +++ b/src/author.C @@ -5,88 +5,89 @@ * * \author John Levon * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ #include #include "author.h" -#include "debug.h" - -#include "support/LAssert.h" -#include "support/LOstream.h" -#include "support/LIstream.h" #include "support/lstrings.h" - -using std::endl; - -namespace { - int cur_id; -} - - + +#include + +#include "support/std_istream.h" + +using lyx::support::token; +using lyx::support::trim; + +using std::string; + + bool operator==(Author const & l, Author const & r) { return l.name() == r.name() && l.email() == r.email(); } - + std::ostream & operator<<(std::ostream & os, Author const & a) { os << "\"" << a.name() << "\" " << a.email(); return os; } - + std::istream & operator>>(std::istream & is, Author & a) { string s; getline(is, s); a.name_ = trim(token(s, '\"', 1)); a.email_ = trim(token(s, '\"', 2)); - lyxerr << "Read name " << a.name_ << " email " << a.email_ << endl; return is; } - - + + +AuthorList::AuthorList() + : last_id_(0) +{ +} + + int AuthorList::record(Author const & a) { Authors::const_iterator it(authors_.begin()); Authors::const_iterator itend(authors_.end()); - + for (; it != itend; ++it) { if (it->second == a) return it->first; - } - - lyxerr[Debug::CHANGES] << "Adding author " << a << endl; - - authors_[cur_id++] = a; - return cur_id - 1; + } + + authors_[last_id_++] = a; + return last_id_ - 1; } - + void AuthorList::record(int id, Author const & a) { - lyx::Assert(id < authors_.size()); - + BOOST_ASSERT(unsigned(id) < authors_.size()); + authors_[id] = a; } - + Author const & AuthorList::get(int id) { Authors::const_iterator it(authors_.find(id)); - lyx::Assert(it != authors_.end()); + BOOST_ASSERT(it != authors_.end()); return it->second; } - + AuthorList::Authors::const_iterator AuthorList::begin() const { return authors_.begin(); } - + AuthorList::Authors::const_iterator AuthorList::end() const {