LCOV - code coverage report
Current view: top level - src/lib - InlineJSONFormatter.h (source / functions) Hit Total Coverage
Test: mediawiki/php/wikidiff2 test coverage report Lines: 6 6 100.0 %
Date: 2023-07-04 10:20:16 Functions: 2 2 100.0 %

          Line data    Source code
       1             : 
       2             : #ifndef INLINEJSONFORMATTER_H
       3             : #define INLINEJSONFORMATTER_H
       4             : 
       5             : #include <stdio.h>
       6             : 
       7             : #include "Formatter.h"
       8             : 
       9             : namespace wikidiff2 {
      10             : 
      11             : class InlineJSONFormatter: public Formatter {
      12             : public:
      13             :     bool hasResults = false;
      14             : 
      15             : private:
      16             :     enum DiffType {Context, AddLine, DeleteLine, Change, MoveSource, MoveDestination};
      17             :     enum HighlightType {Add, Delete};
      18             :     enum LinkDirection {Down, Up};
      19             : 
      20             : public:
      21             :     const char * getName() override;
      22             : 
      23             :     void printFileHeader() override;
      24             :     void printFileFooter() override;
      25             :     void printAdd(const String& line, int leftLine, int rightLine, int offsetFrom,
      26             :         int offsetTo) override;
      27             :     void printDelete(const String& line, int leftLine, int rightLine, int offsetFrom,
      28             :         int offsetTo) override;
      29             : 
      30             :     void printWordDiff(
      31             :         const WordDiff & wordDiff,
      32             :         int leftLine, int rightLine,
      33             :         int offsetFrom, int offsetTo,
      34             :         bool printLeft = true, bool printRight = true,
      35             :         const String & srcAnchor = "", const String & dstAnchor = "",
      36             :         bool moveDirectionDownwards = false) override;
      37             : 
      38             :     void printBlockHeader(int leftLine, int rightLine) override;
      39             :     void printContext(const String& input, int leftLine, int rightLine, int offsetFrom,
      40             :         int offsetTo) override;
      41             : 
      42             : private:
      43             :     void printAddDelete(const String& line, DiffType diffType, const String& lineNumber,
      44             :         int offsetFrom, int offsetTo);
      45             : 
      46             :     void appendOffset(int offsetFrom, int offsetTo);
      47             : 
      48         206 :     void printEscapedJSON(const String & s) {
      49         206 :         printEscapedJSON(s.cbegin(), s.cend());
      50         206 :     }
      51             : 
      52       26721 :     void printEscapedJSON(const Word & word) {
      53       26721 :         printEscapedJSON(word.start, word.end);
      54       26721 :     }
      55             : 
      56             :     void printEscapedJSON(StringIterator start, StringIterator end);
      57             : };
      58             : 
      59             : } // namespace wikidiff2
      60             : 
      61             : #endif /* INLINEJSONFORMATTER_H */

Generated by: LCOV version 1.13