1#include "main.h"
2#include "string_utils.h"
3#include <algorithm>
4#include <cctype>
5#include <sstream>
6
7
8// Helper function to split a string by a delimiter
9std::vector<std::string> splitString(const std::string& str, char delimiter) {
10 std::vector<std::string> tokens;
11 std::string token;
12 std::istringstream tokenStream(str);
13 while (std::getline(tokenStream, token, delimiter)) {
14 // Optionally trim whitespace from each token
15 token.erase(token.find_last_not_of(" \n\r\t")+1);
16 token.erase(0, token.find_first_not_of(" \n\r\t"));
17 tokens.push_back(token);
18 }
19 return tokens;
20}
21
22// Helper function to check if a string represents a valid integer
23bool isInteger(const std::string& s) {
24 if (s.empty()) return false;
25 return std::all_of(s.begin(), s.end(), ::isdigit);
26}