This repository has been archived on 2025-06-01. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
compLIB/server/include/messageBuilder.hpp
Konstantin Lampalzer 9b567b8c6c Protobuf prototype
2022-03-18 18:11:16 +01:00

28 lines
956 B
C++

#ifndef COMPLIB_SERVER_MESSAGECREATION_HPP
#define COMPLIB_SERVER_MESSAGECREATION_HPP
#include <CompLib.pb.h>
namespace MessageBuilder {
CompLib::Header *header(const std::string &message_type) {
auto header = new CompLib::Header();
header->set_message_type(message_type);
return header;
}
CompLib::Status *status(bool successful, const std::string &error_message) {
auto status = new CompLib::Status();
status->set_successful(successful);
status->set_error_message(error_message);
return status;
}
CompLib::GenericResponse *genericResponse(bool successful, const std::string &error_message) {
auto genericResponse = new CompLib::GenericResponse();
genericResponse->set_allocated_header(header(CompLib::GenericResponse::descriptor()->full_name()));
genericResponse->set_allocated_status(status(successful, error_message));
return genericResponse;
}
}
#endif //COMPLIB_SERVER_MESSAGECREATION_HPP