LCOV - code coverage report
Current view: top level - snapwebsites - qdomxpath.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 93 0.0 %
Date: 2019-12-15 17:13:15 Functions: 0 61 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Snap Websites Servers -- generate a DOM from the output of an XML Query
       2             : // Copyright (c) 2013-2019  Made to Order Software Corp.  All Rights Reserved
       3             : //
       4             : // This program is free software; you can redistribute it and/or modify
       5             : // it under the terms of the GNU General Public License as published by
       6             : // the Free Software Foundation; either version 2 of the License, or
       7             : // (at your option) any later version.
       8             : //
       9             : // This program is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             : // GNU General Public License for more details.
      13             : //
      14             : // You should have received a copy of the GNU General Public License
      15             : // along with this program; if not, write to the Free Software
      16             : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
      17             : #ifndef _QXMLXPATH_H
      18             : #define _QXMLXPATH_H
      19             : 
      20             : #include <stdexcept>
      21             : 
      22             : #pragma GCC diagnostic push
      23             : #pragma GCC diagnostic ignored "-Wold-style-cast"
      24             : #include <QDomNode>
      25             : #include <QString>
      26             : #include <QMap>
      27             : #include <QVector>
      28             : #pragma GCC diagnostic pop
      29             : 
      30             : 
      31           0 : class QDomXPathException : public std::runtime_error
      32             : {
      33             : public:
      34           0 :     QDomXPathException(char const * err)
      35           0 :         : runtime_error(err)
      36             :     {
      37           0 :     }
      38             : 
      39             :     QDomXPathException(std::string const & err)
      40             :         : runtime_error(err)
      41             :     {
      42             :     }
      43             : 
      44           0 :     QDomXPathException(QString const & err)
      45           0 :         : runtime_error(err.toUtf8().data())
      46             :     {
      47           0 :     }
      48             : };
      49             : 
      50           0 : class QDomXPathException_InternalError : public QDomXPathException
      51             : {
      52             : public:
      53           0 :     QDomXPathException_InternalError(char const * err)
      54           0 :         : QDomXPathException(err)
      55             :     {
      56           0 :     }
      57             : 
      58             :     QDomXPathException_InternalError(std::string const & err)
      59             :         : QDomXPathException(err)
      60             :     {
      61             :     }
      62             : 
      63           0 :     QDomXPathException_InternalError(QString const & err)
      64           0 :         : QDomXPathException(err)
      65             :     {
      66           0 :     }
      67             : };
      68             : 
      69           0 : class QDomXPathException_UndefinedInstructionError : public QDomXPathException
      70             : {
      71             : public:
      72             :     QDomXPathException_UndefinedInstructionError(char const * err)
      73             :         : QDomXPathException(err)
      74             :     {
      75             :     }
      76             : 
      77             :     QDomXPathException_UndefinedInstructionError(std::string const & err)
      78             :         : QDomXPathException(err)
      79             :     {
      80             :     }
      81             : 
      82           0 :     QDomXPathException_UndefinedInstructionError(QString const & err)
      83           0 :         : QDomXPathException(err)
      84             :     {
      85           0 :     }
      86             : };
      87             : 
      88           0 : class QDomXPathException_UnknownFunctionError : public QDomXPathException
      89             : {
      90             : public:
      91             :     QDomXPathException_UnknownFunctionError(char const * err)
      92             :         : QDomXPathException(err)
      93             :     {
      94             :     }
      95             : 
      96             :     QDomXPathException_UnknownFunctionError(std::string const & err)
      97             :         : QDomXPathException(err)
      98             :     {
      99             :     }
     100             : 
     101           0 :     QDomXPathException_UnknownFunctionError(QString const & err)
     102           0 :         : QDomXPathException(err)
     103             :     {
     104           0 :     }
     105             : };
     106             : 
     107           0 : class QDomXPathException_InvalidMagic : public QDomXPathException
     108             : {
     109             : public:
     110           0 :     QDomXPathException_InvalidMagic(char const * err)
     111           0 :         : QDomXPathException(err)
     112             :     {
     113           0 :     }
     114             : 
     115             :     QDomXPathException_InvalidMagic(std::string const & err)
     116             :         : QDomXPathException(err)
     117             :     {
     118             :     }
     119             : 
     120             :     QDomXPathException_InvalidMagic(QString const & err)
     121             :         : QDomXPathException(err)
     122             :     {
     123             :     }
     124             : };
     125             : 
     126           0 : class QDomXPathException_InvalidError : public QDomXPathException
     127             : {
     128             : public:
     129           0 :     QDomXPathException_InvalidError(char const * err)
     130           0 :         : QDomXPathException(err)
     131             :     {
     132           0 :     }
     133             : 
     134             :     QDomXPathException_InvalidError(std::string const & err)
     135             :         : QDomXPathException(err)
     136             :     {
     137             :     }
     138             : 
     139             :     QDomXPathException_InvalidError(QString const & err)
     140             :         : QDomXPathException(err)
     141             :     {
     142             :     }
     143             : };
     144             : 
     145           0 : class QDomXPathException_InvalidCharacter : public QDomXPathException
     146             : {
     147             : public:
     148           0 :     QDomXPathException_InvalidCharacter(char const * err)
     149           0 :         : QDomXPathException(err)
     150             :     {
     151           0 :     }
     152             : 
     153             :     QDomXPathException_InvalidCharacter(std::string const & err)
     154             :         : QDomXPathException(err)
     155             :     {
     156             :     }
     157             : 
     158           0 :     QDomXPathException_InvalidCharacter(QString const & err)
     159           0 :         : QDomXPathException(err)
     160             :     {
     161           0 :     }
     162             : };
     163             : 
     164           0 : class QDomXPathException_InvalidString : public QDomXPathException
     165             : {
     166             : public:
     167           0 :     QDomXPathException_InvalidString(char const * err)
     168           0 :         : QDomXPathException(err)
     169             :     {
     170           0 :     }
     171             : 
     172             :     QDomXPathException_InvalidString(std::string const & err)
     173             :         : QDomXPathException(err)
     174             :     {
     175             :     }
     176             : 
     177             :     QDomXPathException_InvalidString(QString const & err)
     178             :         : QDomXPathException(err)
     179             :     {
     180             :     }
     181             : };
     182             : 
     183           0 : class QDomXPathException_TooManyUnget : public QDomXPathException
     184             : {
     185             : public:
     186           0 :     QDomXPathException_TooManyUnget(char const * err)
     187           0 :         : QDomXPathException(err)
     188             :     {
     189           0 :     }
     190             : 
     191             :     QDomXPathException_TooManyUnget(std::string const & err)
     192             :         : QDomXPathException(err)
     193             :     {
     194             :     }
     195             : 
     196             :     QDomXPathException_TooManyUnget(QString const & err)
     197             :         : QDomXPathException(err)
     198             :     {
     199             :     }
     200             : };
     201             : 
     202           0 : class QDomXPathException_SyntaxError : public QDomXPathException
     203             : {
     204             : public:
     205           0 :     QDomXPathException_SyntaxError(char const * err)
     206           0 :         : QDomXPathException(err)
     207             :     {
     208           0 :     }
     209             : 
     210             :     QDomXPathException_SyntaxError(std::string const & err)
     211             :         : QDomXPathException(err)
     212             :     {
     213             :     }
     214             : 
     215           0 :     QDomXPathException_SyntaxError(QString const & err)
     216           0 :         : QDomXPathException(err)
     217             :     {
     218           0 :     }
     219             : };
     220             : 
     221           0 : class QDomXPathException_ExecutionTime : public QDomXPathException
     222             : {
     223             : public:
     224           0 :     QDomXPathException_ExecutionTime(char const * err)
     225           0 :         : QDomXPathException(err)
     226             :     {
     227           0 :     }
     228             : 
     229             :     QDomXPathException_ExecutionTime(std::string const & err)
     230             :         : QDomXPathException(err)
     231             :     {
     232             :     }
     233             : 
     234           0 :     QDomXPathException_ExecutionTime(QString const & err)
     235           0 :         : QDomXPathException(err)
     236             :     {
     237           0 :     }
     238             : };
     239             : 
     240           0 : class QDomXPathException_NotImplemented : public QDomXPathException_ExecutionTime
     241             : {
     242             : public:
     243           0 :     QDomXPathException_NotImplemented(char const * err)
     244           0 :         : QDomXPathException_ExecutionTime(err)
     245             :     {
     246           0 :     }
     247             : 
     248             :     QDomXPathException_NotImplemented(std::string const & err)
     249             :         : QDomXPathException_ExecutionTime(err)
     250             :     {
     251             :     }
     252             : 
     253           0 :     QDomXPathException_NotImplemented(QString const & err)
     254           0 :         : QDomXPathException_ExecutionTime(err)
     255             :     {
     256           0 :     }
     257             : };
     258             : 
     259           0 : class QDomXPathException_OutOfRange : public QDomXPathException_ExecutionTime
     260             : {
     261             : public:
     262           0 :     QDomXPathException_OutOfRange(char const * err)
     263           0 :         : QDomXPathException_ExecutionTime(err)
     264             :     {
     265           0 :     }
     266             : 
     267             :     QDomXPathException_OutOfRange(std::string const & err)
     268             :         : QDomXPathException_ExecutionTime(err)
     269             :     {
     270             :     }
     271             : 
     272             :     QDomXPathException_OutOfRange(QString const & err)
     273             :         : QDomXPathException_ExecutionTime(err)
     274             :     {
     275             :     }
     276             : };
     277             : 
     278           0 : class QDomXPathException_EmptyStack : public QDomXPathException_ExecutionTime
     279             : {
     280             : public:
     281           0 :     QDomXPathException_EmptyStack(char const * err)
     282           0 :         : QDomXPathException_ExecutionTime(err)
     283             :     {
     284           0 :     }
     285             : 
     286             :     QDomXPathException_EmptyStack(std::string const & err)
     287             :         : QDomXPathException_ExecutionTime(err)
     288             :     {
     289             :     }
     290             : 
     291             :     QDomXPathException_EmptyStack(QString const & err)
     292             :         : QDomXPathException_ExecutionTime(err)
     293             :     {
     294             :     }
     295             : };
     296             : 
     297           0 : class QDomXPathException_EmptyContext : public QDomXPathException_ExecutionTime
     298             : {
     299             : public:
     300           0 :     QDomXPathException_EmptyContext(char const * err)
     301           0 :         : QDomXPathException_ExecutionTime(err)
     302             :     {
     303           0 :     }
     304             : 
     305             :     QDomXPathException_EmptyContext(std::string const & err)
     306             :         : QDomXPathException_ExecutionTime(err)
     307             :     {
     308             :     }
     309             : 
     310             :     QDomXPathException_EmptyContext(QString const & err)
     311             :         : QDomXPathException_ExecutionTime(err)
     312             :     {
     313             :     }
     314             : };
     315             : 
     316           0 : class QDomXPathException_WrongType : public QDomXPathException_ExecutionTime
     317             : {
     318             : public:
     319           0 :     QDomXPathException_WrongType(char const * err)
     320           0 :         : QDomXPathException_ExecutionTime(err)
     321             :     {
     322           0 :     }
     323             : 
     324             :     QDomXPathException_WrongType(std::string const & err)
     325             :         : QDomXPathException_ExecutionTime(err)
     326             :     {
     327             :     }
     328             : 
     329           0 :     QDomXPathException_WrongType(QString const & err)
     330           0 :         : QDomXPathException_ExecutionTime(err)
     331             :     {
     332           0 :     }
     333             : };
     334             : 
     335           0 : class QDomXPathException_UndefinedVariable : public QDomXPathException_ExecutionTime
     336             : {
     337             : public:
     338             :     QDomXPathException_UndefinedVariable(char const * err)
     339             :         : QDomXPathException_ExecutionTime(err)
     340             :     {
     341             :     }
     342             : 
     343             :     QDomXPathException_UndefinedVariable(std::string const & err)
     344             :         : QDomXPathException_ExecutionTime(err)
     345             :     {
     346             :     }
     347             : 
     348           0 :     QDomXPathException_UndefinedVariable(QString const & err)
     349           0 :         : QDomXPathException_ExecutionTime(err)
     350             :     {
     351           0 :     }
     352             : };
     353             : 
     354           0 : class QDomXPathException_DivisionByZero : public QDomXPathException_ExecutionTime
     355             : {
     356             : public:
     357           0 :     QDomXPathException_DivisionByZero(char const * err)
     358           0 :         : QDomXPathException_ExecutionTime(err)
     359             :     {
     360           0 :     }
     361             : 
     362             :     QDomXPathException_DivisionByZero(std::string const & err)
     363             :         : QDomXPathException_ExecutionTime(err)
     364             :     {
     365             :     }
     366             : 
     367             :     QDomXPathException_DivisionByZero(QString const & err)
     368             :         : QDomXPathException_ExecutionTime(err)
     369             :     {
     370             :     }
     371             : };
     372             : 
     373             : 
     374             : 
     375             : #pragma GCC diagnostic push
     376             : #pragma GCC diagnostic ignored "-Weffc++"
     377             : class QDomXPath
     378             : {
     379             : public:
     380             :     typedef QVector<QDomNode>       node_vector_t;
     381             :     typedef QMap<QString, QString>  bind_vector_t;
     382             :     typedef uint8_t                 instruction_t;
     383             :     typedef QVector<instruction_t>  program_t;
     384             : 
     385             :     static char const *             MAGIC;
     386             :     static instruction_t const      VERSION_MAJOR = 1;
     387             :     static instruction_t const      VERSION_MINOR = 0;
     388             : 
     389             :                                     QDomXPath();
     390             :                                     ~QDomXPath();
     391             : 
     392             :     bool                            setXPath(QString const & xpath, bool show_commands = false);
     393             :     QString                         getXPath() const;
     394             :     void                            setProgram(program_t const & program, bool show_commands = false);
     395             :     program_t const&                getProgram() const;
     396             : 
     397             :     void                            bindVariable(QString const & name, QString const & value);
     398             :     bool                            hasVariable(QString const & name);
     399             :     QString                         getVariable(QString const & name);
     400             : 
     401             :     node_vector_t                   apply(QDomNode node) const;
     402             :     node_vector_t                   apply(node_vector_t node) const;
     403             :     void                            disassemble() const;
     404             : 
     405             : private:
     406             :     class QDomXPathImpl;
     407             :     friend class QDomXPathImpl;
     408             : 
     409             :     QString                         f_xpath = QString();
     410             :     QDomXPathImpl *                 f_impl = nullptr;
     411             :     bind_vector_t                   f_variables = bind_vector_t();
     412             : };
     413             : #pragma GCC diagnostic pop
     414             : 
     415             : #endif
     416             : // _QXMLXPATH_H
     417             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13