mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Shared: Include cleanup
This commit is contained in:
@@ -16,10 +16,10 @@
|
||||
*/
|
||||
|
||||
#include "ProtobufJSON.h"
|
||||
#include "StringFormat.h"
|
||||
#include "Common.h"
|
||||
#include "Errors.h"
|
||||
#include "Log.h"
|
||||
#include "StringFormat.h"
|
||||
#include <google/protobuf/message.h>
|
||||
#include <rapidjson/writer.h>
|
||||
#include <rapidjson/reader.h>
|
||||
#include <rapidjson/stringbuffer.h>
|
||||
@@ -186,7 +186,7 @@ void Serializer::WriteRepeatedMessageField(google::protobuf::Message const& valu
|
||||
class Deserializer : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>, Deserializer>
|
||||
{
|
||||
public:
|
||||
bool ReadMessage(std::string json, google::protobuf::Message* message);
|
||||
bool ReadMessage(std::string const& json, google::protobuf::Message* message);
|
||||
|
||||
bool Key(const Ch* str, rapidjson::SizeType length, bool copy);
|
||||
bool Null();
|
||||
@@ -213,7 +213,7 @@ private:
|
||||
std::vector<std::string> _errors;
|
||||
};
|
||||
|
||||
bool Deserializer::ReadMessage(std::string json, google::protobuf::Message* message)
|
||||
bool Deserializer::ReadMessage(std::string const& json, google::protobuf::Message* message)
|
||||
{
|
||||
rapidjson::StringStream ss(json.c_str());
|
||||
|
||||
@@ -443,10 +443,10 @@ std::string JSON::Serialize(google::protobuf::Message const& message)
|
||||
return serializer.GetString();
|
||||
}
|
||||
|
||||
bool JSON::Deserialize(std::string json, google::protobuf::Message* message)
|
||||
bool JSON::Deserialize(std::string const& json, google::protobuf::Message* message)
|
||||
{
|
||||
Deserializer deserializer;
|
||||
if (!deserializer.ReadMessage(std::forward<std::string>(json), message))
|
||||
if (!deserializer.ReadMessage(json, message))
|
||||
{
|
||||
for (std::size_t i = 0; i < deserializer.GetErrors().size(); ++i)
|
||||
TC_LOG_ERROR("json", "%s", deserializer.GetErrors()[i].c_str());
|
||||
|
||||
@@ -19,13 +19,20 @@
|
||||
#define ProtobufJSON_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include <google/protobuf/message.h>
|
||||
#include <string>
|
||||
|
||||
namespace google
|
||||
{
|
||||
namespace protobuf
|
||||
{
|
||||
class Message;
|
||||
}
|
||||
}
|
||||
|
||||
namespace JSON
|
||||
{
|
||||
TC_SHARED_API std::string Serialize(google::protobuf::Message const& message);
|
||||
TC_SHARED_API bool Deserialize(std::string json, google::protobuf::Message* message);
|
||||
TC_SHARED_API bool Deserialize(std::string const& json, google::protobuf::Message* message);
|
||||
}
|
||||
|
||||
#endif // ProtobufJSON_h__
|
||||
|
||||
Reference in New Issue
Block a user