cb2bib  2.0.1
About: cb2Bib is a multiplatform application for rapidly extracting unformatted, or unstandardized bibliographic references from email alerts, journal Web pages, and PDF files.
  Fossies Dox: cb2bib-2.0.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

bibParser.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2021 by Pere Constans
3  * constans@molspaces.com
4  * cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
5  * See the LICENSE file that comes with this distribution.
6  ***************************************************************************/
7 #ifndef BIBPARSER_H
8 #define BIBPARSER_H
9 
10 #include "cb2bib_parameters.h"
11 #include "coreBibParser.h"
12 #include "journalDB.h"
13 #include "monthDB.h"
14 
15 
16 class bibPreparser;
17 class heuristicBibParser;
18 class idMaker;
19 class preprocess;
20 
21 
22 /**
23  Class for bibliographic reference parsing and manipulation
24 
25  @author Pere Constans
26 */
27 class bibParser : public coreBibParser
28 {
29 
30  Q_OBJECT
31 
32 public:
33  explicit bibParser(QObject* parento = 0);
34  virtual ~bibParser();
35 
36  QString documentFilename(const QString& base_fn, const QString& bibtex_fn);
37  QString excerpt(const QString& text, const QStringList& hints) const;
38  QString parse(const QString& field, const QString& value, const QString& init_value = QString());
39  QString setJournalsToAbbreviated(const QString& text, const bool alternate);
40  QString setJournalsToFull(const QString& text, const bool alternate);
41  QString setTags(const QString& text) const;
42  bibReference& parse(bibReference& reference);
43  virtual void setCiteID();
44  virtual void setField(const QString& name, const QString& value);
45  virtual void setReferenceType(const QString& type);
46  void guessFields(const QString& text);
47  void parse(const QString& text, QString* out_text, QString* out_tagtext);
48  void preparse(const QString& text, QString* out_text);
49 
50  inline QString abbreviatedJournal(const QString& name) const
51  {
52  return _journal_dbP->retrieve(name);
53  }
54  inline QString fullJournal(const QString& name) const
55  {
56  return _journal_dbP->retrieveFull(name);
57  }
58  inline QString alternateAbbreviatedJournal(const QString& name) const
59  {
60  return _journal_dbP->retrieveAlternate(name);
61  }
62  inline QString alternateFullJournal(const QString& name) const
63  {
64  return _journal_dbP->retrieveAlternateFull(name);
65  }
66  inline const QStringList& abbreviatedJournalList() const
67  {
68  return _journal_dbP->abbreviatedList();
69  }
70  inline bool isAutoRecognized() const
71  {
72  return _auto_recognized;
73  }
74  inline QString autoRecognizedString() const
75  {
77  }
78  inline QString toBibTeX(bool sig = true) const
79  {
80  if (sig)
81  return "% cb2Bib " + C2B_VERSION + '\n' + referenceToFomattedBibTeX(_current_reference) + '\n';
82  else
84  }
85  inline QString toBibTeX(const bibReference& ref, bool sig = true) const
86  {
87  if (sig)
88  return "% cb2Bib " + C2B_VERSION + '\n' + referenceToFomattedBibTeX(ref) + '\n';
89  else
90  return referenceToFomattedBibTeX(ref);
91  }
92  inline const bibReference& currentReference() const
93  {
94  return _current_reference;
95  }
96  inline void clearCurrentReference()
97  {
99  _auto_recognized = false;
100  _auto_recognized_string.clear();
101  }
102  inline int fieldCount() const
103  {
105  }
106 
107 
108 signals:
109  void statusMessage(const QString& ms);
110 
111 
112 protected:
117  inline virtual void currentReferenceUpdated() {}
118  virtual void checkRegExpFile(const QString& fn);
119 
120 
121 private:
123  QString metadataSection(const QString& text, const QString& identifier) const;
124  QString removeTags(const QString& text) const;
130 
131 
132  friend class heuristicBibParser;
133 };
134 
135 #endif
const QLatin1String C2B_VERSION("2.0.1")
QString setJournalsToFull(const QString &text, const bool alternate)
Definition: bibParser.cpp:168
bool _auto_recognized
Definition: bibParser.h:125
bibParser(QObject *parento=0)
Definition: bibParser.cpp:23
idMaker * _file_idmP
Definition: bibParser.h:116
const bibReference & currentReference() const
Definition: bibParser.h:92
void clearCurrentReference()
Definition: bibParser.h:96
void guessFields(const QString &text)
Definition: bibParser.cpp:623
QString removeTags(const QString &text) const
Definition: bibParser.cpp:656
QString parse(const QString &field, const QString &value, const QString &init_value=QString())
Definition: bibParser.cpp:56
QString metadataSection(const QString &text, const QString &identifier) const
QString excerpt(const QString &text, const QStringList &hints) const
Definition: bibParser.cpp:226
QString setTags(const QString &text) const
Definition: bibParser.cpp:634
virtual void setField(const QString &name, const QString &value)
Definition: bibParser.cpp:250
bibReference _current_reference
Definition: bibParser.h:114
bibPreparser * _preparserP
Definition: bibParser.h:113
bool isAutoRecognized() const
Definition: bibParser.h:70
idMaker * _cite_idmP
Definition: bibParser.h:115
QString toBibTeX(bool sig=true) const
Definition: bibParser.h:78
journalDB * _journal_dbP
Definition: bibParser.h:127
QString autoRecognizedString() const
Definition: bibParser.h:74
int fieldCount() const
Definition: bibParser.h:102
QString fullJournal(const QString &name) const
Definition: bibParser.h:54
QString toBibTeX(const bibReference &ref, bool sig=true) const
Definition: bibParser.h:85
QString alternateFullJournal(const QString &name) const
Definition: bibParser.h:62
preprocess * _preprocessP
Definition: bibParser.h:129
virtual ~bibParser()
Definition: bibParser.cpp:46
QString documentFilename(const QString &base_fn, const QString &bibtex_fn)
Definition: bibParser.cpp:265
virtual void setReferenceType(const QString &type)
Definition: bibParser.cpp:255
virtual void setCiteID()
Definition: bibParser.cpp:260
heuristicBibParser * _heuristic_parserP
Definition: bibParser.h:126
QString alternateAbbreviatedJournal(const QString &name) const
Definition: bibParser.h:58
void statusMessage(const QString &ms)
void preparse(const QString &text, QString *out_text)
Definition: bibParser.cpp:301
QString setJournalsToAbbreviated(const QString &text, const bool alternate)
Definition: bibParser.cpp:197
virtual void checkRegExpFile(const QString &fn)
Definition: bibParser.cpp:608
QString _auto_recognized_string
Definition: bibParser.h:122
QString abbreviatedJournal(const QString &name) const
Definition: bibParser.h:50
monthDB * _month_dbP
Definition: bibParser.h:128
const QStringList & abbreviatedJournalList() const
Definition: bibParser.h:66
virtual void currentReferenceUpdated()
Definition: bibParser.h:117
void clearReference()
Definition: bibReference.h:32
QString referenceToFomattedBibTeX(const bibReference &ref) const
int fieldCount(const bibReference &ref) const
Definition: coreBibParser.h:66
QString retrieveAlternate(const QString &JQuery) const
Definition: journalDB.cpp:212
const QStringList & abbreviatedList() const
Definition: journalDB.h:52
QString retrieveFull(const QString &JQuery) const
Definition: journalDB.cpp:179
QString retrieveAlternateFull(const QString &JQuery) const
Definition: journalDB.cpp:248
QString retrieve(const QString &JQuery) const
Definition: journalDB.cpp:148