Closed ns-wxin closed 2 years ago
This page (https://oatpp.io/docs/components/dto/) is somewhat helpful and I got it to work.
class FpDto : public oatpp::DTO {
DTO_INIT(FpDto, DTO)
...
DTO_FIELD(String, filename);
DTO_FIELD(List<Float32>, imageEmbedding);
DTO_FIELD(String, region);
// DTO_FIELD(String, imageEmbedding);
};
static void fillEmbedding(const oatpp::Object<FpDto> &fpDto, std::vector<float>& embedding) {
if (!embedding.empty()) {
auto embList = oatpp::List<oatpp::Float32>::createShared();
for (float val : embedding)
embList->push_back(val);
fpDto->imageEmbedding = embList;
}
}
Looks like I may be able to do
DTO_FIELD(List, value);
then I have a std::vector vec;
but I when do value->push_back(vec[i]), I got some SEGV error.
wonder if there's any example of saving and retrieving an array/vector of objects to/from MongoDB using this framework.
Thanks.