SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
store.hpp
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: CC0-1.0
4
5#include <fstream>
6#include <vector>
7
9#include <cereal/archives/binary.hpp> // includes the cereal::BinaryOutputArchive
12#include <cereal/types/vector.hpp> // includes cerealisation support for std::vector
14
16#include <seqan3/test/tmp_directory.hpp>
17
18// Written for std::vector, other types also work.
19void store(std::vector<int16_t> const & data, std::filesystem::path const & tmp_file)
20{
21 std::ofstream os(tmp_file, std::ios::binary); // Where output should be stored.
22 cereal::BinaryOutputArchive archive(os); // Create an output archive from the output stream.
23 archive(data); // Store data.
24}
25
26int main()
27{
28 // The following example is for a std::vector but any seqan3 data structure that is documented as serialisable
29 // could be used, e.g. seqan3::fm_index.
30 seqan3::test::tmp_directory tmp{};
31 auto tmp_file = tmp.path() / "data.out"; // This is a temporary file name, use any other filename.
32
33 std::vector<int16_t> vec{1, 2, 3, 4};
34 store(vec, tmp_file); // Calls store on a std::vector.
35
36 return 0;
37}
Provides seqan3::debug_stream and related types.
constexpr void store(void *mem_addr, simd_t const &simd_vec)
Store simd_t size bits of integral data into memory.
Definition algorithm.hpp:374
Hide me