glideapps / quicktype

Generate types and converters from JSON, Schema, and GraphQL

Home Page:https://app.quicktype.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing includes in generated C++ codes.

black-desk opened this issue · comments

I use quicktype to generate c++ classes from the OCI runtime spec. And I got some types that cannot be compiled without include Generators.hpp.

for examples

#pragma once

#include <optional>
#include <nlohmann/json.hpp>
#include "ocppi/runtime/config/types/helper.hpp"

namespace ocppi {
namespace runtime {
namespace config {
namespace types {
struct BlockIODeviceThrottle;
struct BlockIODeviceWeight;
}
}
}
}

namespace ocppi {
namespace runtime {
namespace config {
namespace types {
using nlohmann::json;

struct BlockIO {
std::optional<int64_t> leafWeight;
std::optional<std::vector<BlockIODeviceThrottle>> throttleReadBpsDevice;
std::optional<std::vector<BlockIODeviceThrottle>> throttleReadIOPSDevice;
std::optional<std::vector<BlockIODeviceThrottle>> throttleWriteBpsDevice;
std::optional<std::vector<BlockIODeviceThrottle>> throttleWriteIOPSDevice;
std::optional<int64_t> weight;
std::optional<std::vector<BlockIODeviceWeight>> weightDevice;
};
}
}
}
}

It seems that types in vector and map should be not only forward declared but should be included.

https://stackoverflow.com/questions/37346/why-cant-a-forward-declaration-be-used-for-a-stdvector