Compare commits

11 Commits

Author SHA1 Message Date
xp986
5ce92848ce Added binary of latest build. 2026-01-11 05:06:21 -06:00
xp986
9b9c0fbd53 Changed token detection to case-insensitive. Fixes issue with printing
whole report if no gyros are sold
2026-01-11 05:02:21 -06:00
xp986
448d9c2c5d Removed unncessary files 2025-10-09 10:20:24 -05:00
xp986
b93cf0bc1b Merge remote-tracking branch 'ReportTruncate-Robinson' into robinson 2025-10-09 10:08:58 -05:00
xp986
70c9e35ae4 Missed a reference to BBGYRO 2025-10-09 01:31:27 -05:00
xp986
55ac790b43 Switch to alameda code, with search for BBGYRS instead of BBGYRO 2025-10-09 01:21:30 -05:00
xp986
2647432b04 Fixed line endings. 2025-10-09 00:30:45 -05:00
xp986
28f6c6d46c Removed adding newlines to non-daily reports. 2025-10-09 00:18:55 -05:00
ee5368cf19 Initial commit 2025-10-08 23:53:59 -05:00
xp986
c966d048b6 Initial commit with working version. 2025-10-08 23:44:36 -05:00
f8aeb47a77 Initial commit 2025-10-08 23:29:54 -05:00
4 changed files with 209 additions and 163 deletions

18
LICENSE Normal file
View File

@@ -0,0 +1,18 @@
MIT License
Copyright (c) 2025 xp986
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# ReportTruncate-Robinson
Truncates the daily report from the BonAppetit system. Modifications for the Robinson store.

View File

@@ -4,6 +4,7 @@
#include <vector>
#include <regex>
#include <algorithm>
#include <cctype>
static const std::regex number_regex_full(R"(\d+)");
static const std::regex number_regex_1to3(R"(\b\d{1,3}\b)");
@@ -18,7 +19,7 @@ bool find_first_number_in_line(const std::string& s, int& out, const std::regex&
return false;
}
// Check if a line contains exactly 24 consecutive '?'
// Check if a line contains exactly 24 consecutive '<EFBFBD>'
bool has_exactly_24_A(const std::string& s) {
int count = 0;
for (size_t i = 0; i <= s.size(); ++i) {
@@ -39,13 +40,14 @@ int main(int argc, char* argv[]) {
return 1;
}
std::ifstream infile(argv[1]);
// Read entire file into memory as lines
std::ifstream infile(argv[1], std::ios::binary);
if (!infile) {
std::cerr << "Error opening input file.\n";
return 1;
}
std::ofstream outfile(argv[2]);
std::ofstream outfile(argv[2], std::ios::binary);
if (!outfile) {
std::cerr << "Error opening output file.\n";
return 1;
@@ -54,9 +56,30 @@ int main(int argc, char* argv[]) {
std::vector<std::string> lines;
std::string line;
while (std::getline(infile, line)) {
if (!infile.eof()) line += '\n'; // preserve original line endings
lines.push_back(line);
}
// Detect if document should be modified
bool has_bbgyro = false;
bool has_subs = false;
for (const auto& l : lines) {
std::string lower = l;
std::transform(lower.begin(), lower.end(), lower.begin(),
[](unsigned char c) { return std::tolower(c); });
if (!has_bbgyro && lower.find("bbgyrs") != std::string::npos) has_bbgyro = true;
if (!has_subs && lower.find("subs") != std::string::npos) has_subs = true;
if (has_bbgyro || has_subs) break;
}
// If neither BBGYRO nor SUBS appears, pass file through unmodified
if (!has_bbgyro && !has_subs) {
infile.clear();
infile.seekg(0, std::ios::beg);
outfile << infile.rdbuf(); // exact byte-for-byte copy
return 0;
}
const std::string marker = "F.L.C.M. %";
// === 1) Find marker index ===
@@ -71,7 +94,10 @@ int main(int argc, char* argv[]) {
}
if (!marker_found) {
for (const auto& l : lines) outfile << l << '\n';
// Marker not found, write original file unchanged
infile.clear();
infile.seekg(0, std::ios::beg);
outfile << infile.rdbuf();
return 0;
}
@@ -117,7 +143,10 @@ int main(int argc, char* argv[]) {
int subs_count = 0;
size_t subs_index = std::string::npos;
for (size_t i = 0; i < lines.size(); ++i) {
if (lines[i].find("SUBS") != std::string::npos) {
std::string lower = lines[i];
std::transform(lower.begin(), lower.end(), lower.begin(),
[](unsigned char c) { return std::tolower(c); });
if (lower.find("subs") != std::string::npos) {
subs_count++;
if (subs_count == 2) {
subs_index = i;
@@ -142,18 +171,14 @@ int main(int argc, char* argv[]) {
size_t ff_pos = l.find('\f');
if (!inserted && ff_pos != std::string::npos) {
std::string modified = l.substr(0, ff_pos) + insert_line + l.substr(ff_pos);
outfile << modified << '\n';
outfile << modified;
inserted = true;
}
else {
outfile << l << '\n';
outfile << l;
}
}
if (!inserted) {
outfile << insert_line << '\n';
}
if (inserted) {
// === 6) Append a form feed to the very end of the truncated document ===
outfile << '\f';

BIN
ReportTruncate-Robinson.exe Executable file

Binary file not shown.