"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/c2b/collectionIndex.h" (12 Feb 2021, 2243 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 "collectionIndex.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 COLLECTIONINDEX_H
    8 #define COLLECTIONINDEX_H
    9 
   10 #include <QMap>
   11 #include <QString>
   12 
   13 
   14 class bibParser;
   15 class settings;
   16 
   17 class QTextStream;
   18 
   19 
   20 class collectionIndex
   21 {
   22 
   23 public:
   24     explicit collectionIndex(bibParser* bp);
   25     ~collectionIndex();
   26 
   27     int index(const QString& dir);
   28 
   29 
   30 private:
   31     struct KeysentenceData
   32     {
   33         inline KeysentenceData() : ndocuments(0) {}
   34         inline explicit KeysentenceData(const int document) : ndocuments(1)
   35         {
   36             documents.append(document);
   37         }
   38         inline void update(const int document)
   39         {
   40             ++ndocuments;
   41             documents.append(document);
   42         }
   43         int ndocuments;
   44         QList<int> documents;
   45     };
   46 
   47     static inline bool _last_equals_first(const QString& text)
   48     {
   49         const ushort* r((const ushort*)text.constData());
   50         const ushort* const cn(r + text.length());
   51         const ushort* s;
   52         for (s = cn - 1; s > r; --s)
   53             if (*s == 32)
   54                 break;
   55         ++s;
   56         while (s < cn)
   57             if (*(s++) != *(r++))
   58                 return false;
   59         return *r == 32;
   60     }
   61 
   62     KeysentenceData* _digest_sentence(KeysentenceData* ksd, KeysentenceData* ksdndmax, int* ndmax) const;
   63     QString preprocessedText(const QString& journal, const QString& text) const;
   64     QString& replace(QString& str, const QChar& a, const QChar& b) const;
   65     bool isValidKeySentence(const QString& text) const;
   66     void analyzeKeySentences();
   67     void cleanupKeySentences();
   68     void digestKeySentences();
   69     void setKeySentences(const int documentid, const QString& text);
   70 
   71     QTextStream& _out;
   72     bibParser* _bpP;
   73     const QChar _space_char;
   74     int _nerrors;
   75     settings* _settingsP;
   76 
   77     QMap<QString, KeysentenceData> _keysentences;
   78     QMultiMap<int, QString> _document_sentences;
   79     QMultiMap<int, int> _document_sentenceids;
   80 };
   81 
   82 #endif