"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/c2b/documentParser.h" (12 Feb 2021, 1739 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 "documentParser.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 DOCUMENTPARSER_H
    8 #define DOCUMENTPARSER_H
    9 
   10 #include <QString>
   11 
   12 
   13 class documentParser
   14 {
   15 
   16 public:
   17     documentParser(const QString& text, const int maximum);
   18     ~documentParser();
   19 
   20     bool parses();
   21     inline QStringRef subsentence() const
   22     {
   23         return _text.midRef(_current_ssentence_origin, _current_ssentence_length);
   24     }
   25     inline int nlength() const
   26     {
   27         return _current_ssentence_length;
   28     }
   29     inline int nwords() const
   30     {
   31         return _current_nwords;
   32     }
   33 
   34 
   35 private:
   36     int nextWord(const int pos) const;
   37 
   38     static inline bool _is_letter(const QChar& c)
   39     {
   40         const ushort uc(c.unicode());
   41         if ((uc > 96 && uc < 123) || uc == 95 || uc == 39)
   42             return true;
   43         else
   44             return c.isLetter();
   45     }
   46     static inline bool _is_letter_or_number(const QChar& c)
   47     {
   48         const ushort uc(c.unicode());
   49         if ((uc > 96 && uc < 123) || (uc > 47 && uc < 58) || uc == 95 || uc == 39)
   50             return true;
   51         else
   52             return c.isLetterOrNumber();
   53     }
   54 
   55     bool _all_done;
   56     int _current_nwords;
   57     int _current_ssentence_length;
   58     int _current_ssentence_origin;
   59     int _nwords;
   60     int _position;
   61     int _ssentence_origin;
   62 
   63     const QChar _space;
   64     const QString _text;
   65     const int _maximum_words;
   66     const int _minimum_words;
   67     const int _text_length;
   68 };
   69 
   70 #endif