Barcode Reader CLI
Integration
C++
C++
brcli-example.config
1#include <iostream>
2#include <string>
3#include <memory>
4
5std::string exec(const char* cmd) {
6 std::array<char, 128> buffer;
7 std::string result;
8 std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
9 if (!pipe) {
10 return "popen() failed!";
11 }
12 while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
13 result += buffer.data();
14 }
15 return result;
16}
17
18int main(int argc, char *argv[]) {
19 std::string cargs[] = {
20 "./BarcodeReaderCLI",
21 "-type=code128",
22 "https://wabr.inliteresearch.com/SampleImages/1d.pdf",
23 "@./brcli-example.config"};// Additional options and sources in configuration file
24 for (int i = 0; i < sizeof(cargs)/sizeof(cargs[0]); i++)
25 cmd += cargs[i] + " ";
26 }
27 std::string out = exec(cmd.c_str());
28 std::cout << out << std::endl;
29 return 0;
30}