-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicgrep_exec.cpp
32 lines (27 loc) · 1.03 KB
/
icgrep_exec.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// For tests only
//
#include <stdio.h>
#include <vector>
#include <string>
#include <fstream>
#include <streambuf>
#include "icgrep_common.h"
using namespace buffer;
namespace fs = boost::filesystem;
int main (int argc, char **argv) {
bool res;
char * inputBool = argv[2];
const size_t lengthInputBool = strlen(inputBool);
buffer::AlignedBuffer<char> alignedBufferBool(lengthInputBool + 1);
alignedBufferBool.writeData(0, inputBool, lengthInputBool);
icgrep_grep(argv[1], &alignedBufferBool, &res);
printf("%d\n", res);
std::ifstream t(argv[3]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
char * inputLines = (char *) str.c_str();
const size_t lengthInputLines = str.length();
buffer::AlignedBuffer<char> alignedBufferLines(lengthInputLines + 1);
alignedBufferLines.writeData(0, inputLines, lengthInputLines);
std::vector<uint64_t> v = icgrep_greplines(argv[1], &alignedBufferLines, lengthInputLines + 1);
printf("size: %ld\n", v.size());
}