diff options
Diffstat (limited to 'c++/codec-netcdf/netcdf.h')
-rw-r--r-- | c++/codec-netcdf/netcdf.h | 22 |
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>(); |