"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/c2b/metadataParser.h" (12 Feb 2021, 2126 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "metadataParser.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.0.0_vs_2.0.1.

    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 METADATAPARSER_H
    8 #define METADATAPARSER_H
    9 
   10 #include <bibReference.h>
   11 
   12 #include <QObject>
   13 
   14 class coreBibParser;
   15 class settings;
   16 
   17 
   18 class metadataParser : public QObject
   19 {
   20 
   21     Q_OBJECT
   22 
   23 public:
   24     explicit metadataParser(QObject* parento = 0);
   25     explicit metadataParser(coreBibParser* cbp, QObject* parento = 0);
   26     inline ~metadataParser() {}
   27 
   28     bool insertMetadata(const bibReference& ref, const QString& fn, QString* error = 0,
   29                         const bool has_reference = false);
   30     bool metadata(const QString& fn, bibReference* ref);
   31     const QString metadata(const QString& fn);
   32 
   33 
   34 signals:
   35     void showMessage(const QString& title, const QString& ms);
   36 
   37 
   38 private:
   39     QHash<QString, QString> _bibtex_key;
   40     QRegExp _bibtex_fields;
   41     QRegExp _fields;
   42     bibReference _ref;
   43     bool _has_bibtex;
   44     bool _has_cb2bib;
   45     bool _has_prism;
   46     bool _metadata(const QString& fn);
   47     const QString _pdfDictionary(const QByteArray& rawpdf);
   48     coreBibParser* _cbpP;
   49     settings* _settingsP;
   50     void _fuzzyParser(const QString& data);
   51     void _metadataXmp(const QString& fn, const QByteArray& raw_contents, QStringList* xmls);
   52     void _metadataXmpExifTool(const QString& fn, QStringList* xmls);
   53     void _miscellaneousData(const QString& fn, const QByteArray& raw_contents);
   54     void init();
   55 
   56     inline QString formattedAuthor(const QString& author) const
   57     {
   58         const QStringList alist(author.split(" and ", QString::SkipEmptyParts));
   59         int na(alist.count());
   60         if (na <= 2)
   61             return author;
   62         QString formatted(alist.first());
   63         for (int i = 1; i < na - 1; ++i)
   64             formatted += ", " + alist.at(i);
   65         formatted += ", and " + alist.last();
   66         return formatted;
   67     }
   68 };
   69 
   70 #endif