58 lines
No EOL
1.4 KiB
C++
58 lines
No EOL
1.4 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <optional>
|
|
#include <variant>
|
|
|
|
// Declaraciones de estructuras
|
|
|
|
namespace proto {
|
|
struct FieldComment {
|
|
size_t offset;
|
|
uint32_t xor_const;
|
|
};
|
|
|
|
struct Field {
|
|
std::string kind;
|
|
std::string name;
|
|
uint32_t number;
|
|
std::optional<FieldComment> comment;
|
|
};
|
|
|
|
struct Oneof {
|
|
std::string name;
|
|
std::vector<Field> fields;
|
|
};
|
|
|
|
struct Enum {
|
|
std::string name;
|
|
std::vector<std::pair<std::string, int32_t>> variants;
|
|
};
|
|
|
|
struct Message {
|
|
uint16_t cmd_id;
|
|
std::string name;
|
|
std::vector<Field> fields;
|
|
std::vector<Oneof> oneofs;
|
|
};
|
|
|
|
using ProtoItem = std::variant<Message, Enum>;
|
|
struct ProtoFile {
|
|
std::string syntax;
|
|
std::vector<std::string> imports;
|
|
std::vector<ProtoItem> items;
|
|
};
|
|
|
|
// Declaración de operadores de salida
|
|
|
|
std::ostream& operator<<(std::ostream& os, const FieldComment& c);
|
|
std::ostream& operator<<(std::ostream& os, const Field& f);
|
|
std::ostream& operator<<(std::ostream& os, const Oneof& o);
|
|
std::ostream& operator<<(std::ostream& os, const Enum& e);
|
|
std::ostream& operator<<(std::ostream& os, const Message& m);
|
|
std::ostream& operator<<(std::ostream& os, const ProtoItem& item);
|
|
std::ostream& operator<<(std::ostream& os, const ProtoFile& pf);
|
|
} |