2003-02-08 19:18:01 +00:00
|
|
|
/**
|
|
|
|
* \file author.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "author.h"
|
|
|
|
|
2003-03-02 12:16:00 +00:00
|
|
|
#include "support/LAssert.h"
|
2003-02-08 19:18:01 +00:00
|
|
|
#include "support/LOstream.h"
|
|
|
|
#include "support/LIstream.h"
|
|
|
|
#include "support/lstrings.h"
|
2003-03-02 12:16:00 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
bool operator==(Author const & l, Author const & r)
|
|
|
|
{
|
|
|
|
return l.name() == r.name() && l.email() == r.email();
|
|
|
|
}
|
2003-03-02 12:16:00 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream & os, Author const & a)
|
|
|
|
{
|
|
|
|
os << "\"" << a.name() << "\" " << a.email();
|
|
|
|
return os;
|
|
|
|
}
|
2003-03-02 12:16:00 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
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));
|
|
|
|
return is;
|
|
|
|
}
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
|
|
|
2003-03-12 23:25:59 +00:00
|
|
|
AuthorList::AuthorList()
|
|
|
|
: last_id_(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
int AuthorList::record(Author const & a)
|
|
|
|
{
|
|
|
|
Authors::const_iterator it(authors_.begin());
|
|
|
|
Authors::const_iterator itend(authors_.end());
|
2003-03-02 12:16:00 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
for (; it != itend; ++it) {
|
|
|
|
if (it->second == a)
|
|
|
|
return it->first;
|
2003-03-02 12:16:00 +00:00
|
|
|
}
|
|
|
|
|
2003-03-12 23:25:59 +00:00
|
|
|
authors_[last_id_++] = a;
|
|
|
|
return last_id_ - 1;
|
2003-02-08 19:18:01 +00:00
|
|
|
}
|
2003-03-02 12:16:00 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
void AuthorList::record(int id, Author const & a)
|
|
|
|
{
|
2003-03-12 23:25:59 +00:00
|
|
|
lyx::Assert(unsigned(id) < authors_.size());
|
2003-03-02 12:16:00 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
authors_[id] = a;
|
|
|
|
}
|
|
|
|
|
2003-03-02 12:16:00 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
Author const & AuthorList::get(int id)
|
|
|
|
{
|
|
|
|
Authors::const_iterator it(authors_.find(id));
|
|
|
|
lyx::Assert(it != authors_.end());
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
2003-03-02 12:16:00 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
AuthorList::Authors::const_iterator AuthorList::begin() const
|
|
|
|
{
|
|
|
|
return authors_.begin();
|
|
|
|
}
|
2003-03-02 12:16:00 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
AuthorList::Authors::const_iterator AuthorList::end() const
|
|
|
|
{
|
|
|
|
return authors_.end();
|
|
|
|
}
|