]> git.lyx.org Git - lyx.git/blobdiff - src/author.C
add config.h
[lyx.git] / src / author.C
index aef006e535c5b830f50ffb25d941b2da2c9f3507..ea05ccd83d53dda7c494f6b814a1a1c09945dfb9 100644 (file)
@@ -5,25 +5,26 @@
  *
  * \author John Levon
  *
- * Full author contact details are available in file CREDITS
+ * 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;
+#include <boost/assert.hpp>
 
-namespace {
-       int cur_id;
-}
+#include "support/std_istream.h"
+
+
+namespace lyx {
+
+using support::token;
+using support::trim;
+
+using std::string;
 
 
 bool operator==(Author const & l, Author const & r)
@@ -34,7 +35,8 @@ bool operator==(Author const & l, Author const & r)
 
 std::ostream & operator<<(std::ostream & os, Author const & a)
 {
-       os << "\"" << a.name() << "\" " << a.email();
+       // FIXME UNICODE
+       os << "\"" << to_utf8(a.name()) << "\" " << to_utf8(a.email());
        return os;
 }
 
@@ -42,13 +44,19 @@ 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;
+       // FIXME UNICODE
+       a.name_ = from_utf8(trim(token(s, '\"', 1)));
+       a.email_ = from_utf8(trim(token(s, '\"', 2)));
        return is;
 }
 
 
+AuthorList::AuthorList()
+       : last_id_(0)
+{
+}
+
+
 int AuthorList::record(Author const & a)
 {
        Authors::const_iterator it(authors_.begin());
@@ -59,16 +67,14 @@ int AuthorList::record(Author const & 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;
 }
@@ -77,7 +83,7 @@ void AuthorList::record(int id, Author const & 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;
 }
 
@@ -92,3 +98,6 @@ AuthorList::Authors::const_iterator AuthorList::end() const
 {
        return authors_.end();
 }
+
+
+} // namespace lyx