2003-08-23 00:17:00 +00:00
|
|
|
// -*- C++ -*-
|
2003-02-08 19:18:01 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file Author.h
|
2003-02-08 19:18:01 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-08 19:18:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AUTHOR_H
|
|
|
|
#define AUTHOR_H
|
|
|
|
|
2020-10-20 22:01:03 +00:00
|
|
|
#include "support/docstring.h"
|
2006-12-21 13:58:28 +00:00
|
|
|
|
2009-07-23 20:38:24 +00:00
|
|
|
#include <vector>
|
2003-02-08 19:18:01 +00:00
|
|
|
|
2003-03-04 09:27:27 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
class Author {
|
|
|
|
public:
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2020-02-28 06:39:06 +00:00
|
|
|
Author() : used_(false), buffer_id_(0) {}
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2019-12-24 13:31:08 +00:00
|
|
|
Author(docstring const & name, docstring const & email,
|
|
|
|
docstring const & initials);
|
2015-11-11 21:31:05 +00:00
|
|
|
/// For when the \author line is missing (#9854)
|
|
|
|
Author(int buffer_id);
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
|
|
|
docstring name() const { return name_; }
|
|
|
|
///
|
|
|
|
docstring email() const { return email_; }
|
|
|
|
///
|
2019-12-24 13:31:08 +00:00
|
|
|
docstring initials() const { return initials_; }
|
|
|
|
///
|
2016-05-03 19:40:28 +00:00
|
|
|
docstring nameAndEmail() const;
|
|
|
|
///
|
2020-11-02 22:09:13 +00:00
|
|
|
int bufferId() const { return buffer_id_; }
|
2009-07-23 20:08:05 +00:00
|
|
|
///
|
2020-11-02 22:09:13 +00:00
|
|
|
void setBufferId(int buffer_id) const { buffer_id_ = buffer_id; }
|
2009-07-23 20:08:05 +00:00
|
|
|
///
|
2007-11-01 22:17:22 +00:00
|
|
|
void setUsed(bool u) const { used_ = u; }
|
|
|
|
///
|
|
|
|
bool used() const { return used_; }
|
2015-11-11 21:31:05 +00:00
|
|
|
/// Was the author line not missing?
|
|
|
|
bool valid() const;
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2006-12-21 13:58:28 +00:00
|
|
|
friend std::istream & operator>>(std::istream & os, Author & a);
|
2010-11-17 16:12:43 +00:00
|
|
|
///
|
|
|
|
friend std::ostream & operator<<(std::ostream & os, Author const & a);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
private:
|
2007-11-01 22:17:22 +00:00
|
|
|
/// The author's name
|
2006-12-21 13:58:28 +00:00
|
|
|
docstring name_;
|
2007-11-01 22:17:22 +00:00
|
|
|
/// The author's email address
|
2006-12-21 13:58:28 +00:00
|
|
|
docstring email_;
|
2019-12-24 13:31:08 +00:00
|
|
|
/// The author's initials
|
|
|
|
docstring initials_;
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2007-07-09 20:52:34 +00:00
|
|
|
mutable bool used_;
|
2009-07-23 20:34:16 +00:00
|
|
|
/// The id of the author in the lyx-file
|
2010-11-05 18:25:29 +00:00
|
|
|
mutable int buffer_id_;
|
2003-02-08 19:18:01 +00:00
|
|
|
};
|
2003-03-04 09:27:27 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
class AuthorList {
|
|
|
|
public:
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2003-03-12 23:25:59 +00:00
|
|
|
AuthorList();
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2020-11-02 22:09:13 +00:00
|
|
|
int record(Author const & a);
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2020-11-02 22:09:13 +00:00
|
|
|
void record(int id, Author const & a);
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2010-10-29 19:27:55 +00:00
|
|
|
void recordCurrentAuthor(Author const & a);
|
|
|
|
///
|
2020-11-02 22:09:13 +00:00
|
|
|
Author const & get(int id) const;
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2009-07-23 20:08:05 +00:00
|
|
|
void sort();
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2014-04-04 19:54:32 +00:00
|
|
|
typedef std::vector<Author> Authors;
|
|
|
|
///
|
2003-02-08 19:18:01 +00:00
|
|
|
Authors::const_iterator begin() const;
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2003-02-08 19:18:01 +00:00
|
|
|
Authors::const_iterator end() const;
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2009-07-23 20:08:05 +00:00
|
|
|
friend
|
|
|
|
std::ostream & operator<<(std::ostream & os, AuthorList const & a);
|
2003-02-08 19:18:01 +00:00
|
|
|
private:
|
2007-11-01 22:17:22 +00:00
|
|
|
///
|
2003-02-08 19:18:01 +00:00
|
|
|
Authors authors_;
|
|
|
|
};
|
2003-03-04 09:27:27 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
bool operator==(Author const & l, Author const & r);
|
2003-03-04 09:27:27 +00:00
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream & os, Author const & a);
|
|
|
|
|
|
|
|
std::istream & operator>>(std::istream & os, Author & a);
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
#endif // AUTHOR_H
|