summaryrefslogtreecommitdiffstats
path: root/src/translators/bibtexhandler.h
blob: 76ee90bd091b6e763456247209516fac25fbdefc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/***************************************************************************
    copyright            : (C) 2003-2006 by Robby Stephenson
    email                : robby@periapsis.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of version 2 of the GNU General Public License as  *
 *   published by the Free Software Foundation;                            *
 *                                                                         *
 ***************************************************************************/

#ifndef BIBTEXHANDLER_H
#define BIBTEXHANDLER_H

class TQString;
class TQStringList;
class TQRegExp;

#include "../datavectors.h"

#include <tqmap.h>

namespace Tellico {

/**
 * @author Robby Stephenson
 */
class BibtexHandler {
public:
  enum QuoteStyle { BRACES=0, QUOTES=1 };
  static TQStringList bibtexKeys(const Data::EntryVec& entries);
  static TQString bibtexKey(Data::ConstEntryPtr entry);
  static TQString importText(char* text);
  static TQString exportText(const TQString& text, const TQStringList& macros);
  static bool setFieldValue(Data::EntryPtr entry, const TQString& bibtexField, const TQString& value);
  /**
   * Strips the text of all vestiges of LaTeX.
   *
   * @param text A reference to the text
   * @return A reference to the text
   */
  static TQString& cleanText(TQString& text);

  static QuoteStyle s_quoteStyle;

private:
  typedef TQMap<TQString, TQStringList> StringListMap;

  static TQString bibtexKey(const TQString& author, const TQString& title, const TQString& year);
  static void loadTranslationMaps();
  static TQString& addBraces(TQString& string);

  static StringListMap* s_utf8LatexMap;
  static const TQRegExp s_badKeyChars;
};

} // end namespace
#endif