harbor run -t openthoughts/tasktrove-mix-h2-language-proportional-mix-h2-lang-proportional-3167harbor download openthoughts/tasktrove-mix-h2-language-proportional-mix-h2-lang-proportional-3167You need to implement a C++ class called Procedure that validates JSON-RPC procedure parameters and handles their specifications. The procedure should be able to:
Parameter Validation:
ValidateNamedParameters that checks if the provided JSON parameters match the expected types defined during the creation of the Procedure object.Error Handling:
JsonRpcException class to manage exceptions related to JSON-RPC operations. It should provide:
GetCode() that returns the error code.GetMessage() that returns the error message.GetData() method.Specification Parsing:
SpecificationParser class to parse procedure specifications from a JSON string and a file. You must ensure that:
Procedure objects is returned.JsonRpcException is thrown with the appropriate error code.Specification Writing:
SpecificationWriter class that can take a vector of Procedure objects and generate a corresponding JSON representation.Parameter Types:
Procedure constructor should accept a list of parameter names and corresponding expected JSON types. Supported types include JSON_BOOLEAN, JSON_STRING, JSON_INTEGER, JSON_ARRAY, JSON_OBJECT, JSON_REAL, and JSON_NUMERIC.Exception Handling:
test_exception. The various exception constructors should be able to format messages correctly and provide relevant error codes.File Path Handling:
SpecificationWriter should check for valid file paths and return false when paths are invalid.Testing:
test_common.cpp file pass successfully. The tests cover parameter validation, exception handling, specification parsing, and writing.File Structure:
Procedure, JsonRpcException, SpecificationParser, and SpecificationWriter classes in the /app/ directory.Ensure your implementation is well-commented, follows good coding practices, and adequately handles edge cases to maintain robust error checking throughout the functionality.