| 1 | /* |
| 2 | The software in this package is distributed under the GNU General |
| 3 | Public License version 2 (with a special exception described below). |
| 4 | |
| 5 | A copy of GNU General Public License (GPL) is included in this distribution, |
| 6 | in the file COPYING.GPL. |
| 7 | |
| 8 | As a special exception, if other files instantiate templates or use macros |
| 9 | or inline functions from this file, or you compile this file and link it |
| 10 | with other works to produce a work based on this file, this file |
| 11 | does not by itself cause the resulting work to be covered |
| 12 | by the GNU General Public License. |
| 13 | |
| 14 | However the source code for this file must still be made available |
| 15 | in accordance with section (3) of the GNU General Public License. |
| 16 | |
| 17 | This exception does not invalidate any other reasons why a work based |
| 18 | on this file might be covered by the GNU General Public License. |
| 19 | */ |
| 20 | /*************************************************************************** |
| 21 | * Copyright (C) 2006 by Intra2net AG * |
| 22 | * * |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | #ifndef __LOGREAD_HXX |
| 26 | #define __LOGREAD_HXX |
| 27 | |
| 28 | #include <string> |
| 29 | |
| 30 | /** |
| 31 | Log file reader class. |
| 32 | |
| 33 | Works on complete and incomplete lines. |
| 34 | Devire from this class and implement your |
| 35 | own processLine() / processUnfinishedLine() function. |
| 36 | */ |
| 37 | class logread |
| 38 | { |
| 39 | public: |
| 40 | logread(std::string filename, bool _goto_end=false); |
| 41 | void read(); |
| 42 | |
| 43 | protected: |
| 44 | std::string line; |
| 45 | |
| 46 | virtual void processUnfinishedLine() {}; |
| 47 | virtual void processLine() {}; |
| 48 | |
| 49 | private: |
| 50 | // Internal implementation |
| 51 | void reset(); |
| 52 | void goto_end(); |
| 53 | |
| 54 | bool check_changed(); |
| 55 | bool process(); |
| 56 | |
| 57 | std::string getLogChanges(); |
| 58 | void extractSingeLine (std::string &input); |
| 59 | |
| 60 | std::string filename; |
| 61 | int logsize; |
| 62 | int logsize_old; |
| 63 | |
| 64 | bool line_complete; |
| 65 | }; |
| 66 | |
| 67 | #endif |