Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.87 KB

README.md

File metadata and controls

52 lines (35 loc) · 1.87 KB

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