Commit 28170238 authored by GUYOT DOMINIQUE's avatar GUYOT DOMINIQUE
Browse files

Initial def of struct parser

parent 2bf683a9
......@@ -7,22 +7,60 @@
#include <fcntl.h>
#include <unistd.h>
#include <string_view>
#include <iostream>
#include <vector>
using namespace::std;
int main(int argc, char** argv){
struct Parser{
vector<string_view> chunks;
Parser(char** argv){
struct stat sfd;
int fd;
size_t size;
size_t pos = 0;
size_t chunk_size;
char* mmfile;
int i;
fd = open(argv[1], O_RDONLY);
size = sfd.st_size;
mmfile = (char *)mmap(NULL, size, PROT_READ, MAP_PRIVATE | MAP_DENYWRITE, fd, 0);
string_view mapview(mmfile,size);
string_view sentinel(">");
string_view chunk;
while(pos < mapview.size()){
pos = mapview.find(sentinel, pos);
chunk_size = mapview.find(sentinel, pos + sentinel.size()) - pos;
chunk = mapview.substr(pos, chunk_size);
pos += chunk_size;
string_view get_chunk(size_t i){
int main(int argc, char** argv){
Parser* P = new Parser(argv);
cout << P->get_chunk(4);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment