Barcode Reader CLI
Integration
C++
C++
brcli-example.config
#include <iostream> #include <string> #include <memory> std::string exec(const char* cmd) { std::array<char, 128> buffer; std::string result; std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose); if (!pipe) { return "popen() failed!"; } while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { result += buffer.data(); } return result; } int main(int argc, char *argv[]) { std::string cargs[] = { "./BarcodeReaderCLI", "-type=code128", "https://wabr.inliteresearch.com/SampleImages/1d.pdf", "@./brcli-example.config"};// Additional options and sources in configuration file for (int i = 0; i < sizeof(cargs)/sizeof(cargs[0]); i++) cmd += cargs[i] + " "; } std::string out = exec(cmd.c_str()); std::cout << out << std::endl; return 0; }