lyx_mirror/src/author.C
John Levon ae87b94515 The big change tracking patch. Changes from posted version :
1) abstract time_t into lyx::time_type
2) abstrace struct passwd into support/userinfo
3) make authorlist a per-buffer property instead of global

I will look at the paragraph breaking soon, in the meantime I opened a bug on bugzilla.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6074 a592a061-630c-0410-9148-cb99ea01b6c8
2003-02-08 19:18:01 +00:00

95 lines
1.7 KiB
C

/**
* \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"
#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;
}
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;
}
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;
}
void AuthorList::record(int id, Author const & a)
{
lyx::Assert(id < authors_.size());
authors_[id] = a;
}
Author const & AuthorList::get(int id)
{
Authors::const_iterator it(authors_.find(id));
lyx::Assert(it != authors_.end());
return it->second;
}
AuthorList::Authors::const_iterator AuthorList::begin() const
{
return authors_.begin();
}
AuthorList::Authors::const_iterator AuthorList::end() const
{
return authors_.end();
}