#ifndef BASE_TEST_TEST_PROTO_LOADER_H_
#define BASE_TEST_TEST_PROTO_LOADER_H_
#include <memory>
#include <string>
#include <string_view>
#include "base/files/file_path.h"
namespace base {
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(PROTO_TEST_IMPLEMENTATION)
#define PROTO_TEST_EXPORT __declspec(dllexport)
#else
#define PROTO_TEST_EXPORT __declspec(dllimport)
#endif
#else
#define PROTO_TEST_EXPORT __attribute__((visibility("default")))
#endif
#else
#define PROTO_TEST_EXPORT
#endif
class PROTO_TEST_EXPORT TestProtoSetLoader {
public:
explicit TestProtoSetLoader(const base::FilePath& descriptor_path);
explicit TestProtoSetLoader(std::string_view descriptor_binary_proto);
~TestProtoSetLoader();
TestProtoSetLoader(const TestProtoSetLoader&) = delete;
TestProtoSetLoader& operator=(const TestProtoSetLoader&) = delete;
std::string ParseFromText(std::string_view type_name,
const std::string& proto_text) const;
std::string PrintToText(std::string_view type_name,
const std::string& message) const;
private:
class State;
std::unique_ptr<State> state_;
};
class PROTO_TEST_EXPORT TestProtoLoader {
public:
TestProtoLoader(const base::FilePath& descriptor_path,
std::string_view type_name);
TestProtoLoader(std::string_view descriptor_binary_proto,
std::string_view type_name);
~TestProtoLoader();
TestProtoLoader(const TestProtoLoader&) = delete;
TestProtoLoader& operator=(const TestProtoLoader&) = delete;
void ParseFromText(const std::string& proto_text, std::string& message) const;
void PrintToText(const std::string& message, std::string& proto_text) const;
private:
TestProtoSetLoader set_loader_;
std::string type_name_;
};
}
#endif