eminem
Parse Matrix Market files in C++
Loading...
Searching...
No Matches
from_text.hpp
Go to the documentation of this file.
1#ifndef EMINEM_FROM_TEXT_HPP
2#define EMINEM_FROM_TEXT_HPP
3
4#include <memory>
5#include <cstddef>
6
7#include "Parser.hpp"
8#include "byteme/PerByte.hpp"
11
17namespace eminem {
18
26 std::size_t buffer_size = 65536;
27
31 int num_threads = 1;
32
37 std::size_t block_size = 65536;
38};
39
48template<typename Index_ = unsigned long long>
50 ParserOptions popt;
51 popt.num_threads = options.num_threads;
52 popt.block_size = options.block_size;
53
55 topt.buffer_size = options.buffer_size;
56 auto reader = std::make_unique<byteme::RawFileReader>(path, topt);
57 auto pb = std::make_unique<byteme::PerByteSerial<char> >(std::move(reader));
58 return Parser<std::unique_ptr<byteme::PerByteSerial<char> >, Index_>(std::move(pb), popt);
59}
60
68 int num_threads = 1;
69
74 std::size_t block_size = 65536;
75};
76
86template<typename Index_ = unsigned long long>
87Parser<std::unique_ptr<byteme::PerByteSerial<char> >, Index_> parse_text_buffer(const unsigned char* buffer, std::size_t len, const ParseTextBufferOptions& options) {
88 ParserOptions popt;
89 popt.num_threads = options.num_threads;
90 popt.block_size = options.block_size;
91
92 auto reader = std::make_unique<byteme::RawBufferReader>(buffer, len);
93 auto pb = std::make_unique<byteme::PerByteSerial<char> >(std::move(reader));
94 return Parser<std::unique_ptr<byteme::PerByteSerial<char> >, Index_>(std::move(pb), popt);
95}
96
97}
98
99#endif
Parse a matrix from a Matrix Market file.
Parse a matrix from a Matrix Market file.
Definition Parser.hpp:275
Classes and methods for parsing Matrix Market files.
Parser< std::unique_ptr< byteme::PerByteSerial< char > >, Index_ > parse_text_file(const char *path, const ParseTextFileOptions &options)
Definition from_text.hpp:49
Parser< std::unique_ptr< byteme::PerByteSerial< char > >, Index_ > parse_text_buffer(const unsigned char *buffer, std::size_t len, const ParseTextBufferOptions &options)
Definition from_text.hpp:87
Options for parse_text_buffer().
Definition from_text.hpp:64
int num_threads
Definition from_text.hpp:68
std::size_t block_size
Definition from_text.hpp:74
Options for parse_text_file().
Definition from_text.hpp:22
std::size_t block_size
Definition from_text.hpp:37
int num_threads
Definition from_text.hpp:31
std::size_t buffer_size
Definition from_text.hpp:26
Options for the Parser constructor.
Definition Parser.hpp:32
std::size_t block_size
Definition Parser.hpp:43
int num_threads
Definition Parser.hpp:36