summaryrefslogtreecommitdiff
path: root/c++
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2023-11-09 17:02:40 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2023-11-09 17:02:40 +0100
commitf40fe73cbd8f61be11721babb1e3615326466041 (patch)
tree7fdbc7a66c52215a35081dbbbcb5955916dc5593 /c++
parentd206499057ceaf6927be4fbc3f54e25dacd83034 (diff)
codec-netcdf: Changed to memory parsing
Diffstat (limited to 'c++')
-rw-r--r--c++/codec-netcdf/netcdf.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/c++/codec-netcdf/netcdf.h b/c++/codec-netcdf/netcdf.h
index c99217e..72e7614 100644
--- a/c++/codec-netcdf/netcdf.h
+++ b/c++/codec-netcdf/netcdf.h
@@ -5,6 +5,7 @@
#include <forstio/codec/data.h>
#include <netcdf.h>
+#include <netcdf_mem.h>
namespace saw {
namespace encode {
@@ -20,22 +21,23 @@ struct Netcdf {};
template<typename Schema>
class data<Schema, encode::Netcdf> {
private:
- std::string path_;
+ std::vector<uint8_t> buff_;
public:
- data(const std::string& path):
- path_{path}
+ data(std::vector<uint8_t> buff):
+ buff_{std::move(buff)}
{}
- data(std::string&& path):
- path_{std::move(path)}
+ template<size_t N>
+ data(const std::array<uint8_t, N>& arr):
+ buff_{arr.begin(), arr.end()}
{}
- std::string_view get_path_view() {
- return path_;
+ std::vector<uint8_t>& get_data() {
+ return buff_;
}
- const std::string& get_path() const {
- return path_;
+ const std::vector<uint8_t>& get_data() const {
+ return buff_;
}
};
@@ -77,7 +79,7 @@ public:
int ncid{};
int rc{};
- rc = nc_open(from_decode.get_path().c_str(), NC_NOWRITE, &ncid);
+ rc = nc_open_mem("forstio_internal_memory", NC_NOWRITE, from_decode.get_data().size(), &from_decode.get_data()[0], &ncid);
if(rc != NC_NOERR){
// Don't know how to get the error, so fail critically.
return make_error<err::critical>();