Skip to content

wsjcpp/wsjcpp-diff-text

Repository files navigation

wsjcpp-diff-text

Build Status Github Stars Github Stars Github Forks Total alerts Language grade: C/C++

Algorithm for like a diff texts

Integrate to your project

wsjcpp install "https://github.com/wsjcpp/wsjcpp-diff-text:master"

Or copy files to project:

  • src.wsjcpp/wsjcpp_core/wsjcpp_core.h
  • src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp
  • src/wsjcpp_diff_text.h
  • src/wsjcpp_diff_text.cpp

Examples

#include <wsjcpp_core.h>
#include <wsjcpp_diff_text.h>

... 

std::string sFileContent1;
std::string sFileContent2;
WsjcppCore::readTextFile("data/file1.txt", sFileContent1);
WsjcppCore::readTextFile("data/file1.txt", sFileContent2);

std::vector<WsjcppDiffTextRow> vResult;
WsjcppDiffText::compare(sFileContent1, sFileContent2, vResult);
for (int i = 0; i < vResult.size(); i++) {
    std::cout << 
        vResult[i].getKey() << " => line (" << vResult[i].getNumberOfLine() << "): " 
        << vResult[i].getLine() << std::endl;
}

example output:

!del => line (1): 22222
!add => line (6): 71111
!add => line (10): 11111

Releases

No releases published

Packages

No packages published