Decouple parser from CommitRequest
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "commit_request.hpp"
|
||||
#include "json_commit_request_parser.hpp"
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
@@ -361,19 +362,19 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Parse the commit request
|
||||
CommitRequest commit_request;
|
||||
JsonCommitRequestParser parser;
|
||||
|
||||
// Make a mutable copy for parsing (weaseljson requires mutable data)
|
||||
std::vector<char> mutable_json(json_content.begin(), json_content.end());
|
||||
mutable_json.push_back('\0'); // Null terminate for safety
|
||||
|
||||
bool parse_success =
|
||||
commit_request.parse_json(mutable_json.data(), mutable_json.size() - 1);
|
||||
bool parse_success = parser.parse(commit_request, mutable_json.data(),
|
||||
mutable_json.size() - 1);
|
||||
|
||||
if (!parse_success || !commit_request.is_parse_complete()) {
|
||||
if (!parse_success) {
|
||||
std::cerr << "Error: Failed to parse JSON" << std::endl;
|
||||
if (commit_request.has_parse_error()) {
|
||||
std::cerr << "Parse error: " << commit_request.get_parse_error()
|
||||
<< std::endl;
|
||||
if (parser.has_parse_error()) {
|
||||
std::cerr << "Parse error: " << parser.get_parse_error() << std::endl;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user