SeqAn3 3.1.0
The Modern C++ library for sequence analysis.
store.hpp
1#include <fstream>
2#include <vector>
3
5#include <cereal/archives/binary.hpp> // includes the cereal::BinaryOutputArchive
8#include <cereal/types/vector.hpp> // includes cerealisation support for std::vector
10
12#include <seqan3/test/tmp_filename.hpp>
13
14// Written for std::vector, other types also work.
15void store(std::vector<int16_t> const & data, seqan3::test::tmp_filename & tmp_file)
16{
17 std::ofstream os(tmp_file.get_path(), std::ios::binary); // Where output should be stored.
18 cereal::BinaryOutputArchive archive(os); // Create an output archive from the output stream.
19 archive(data); // Store data.
20}
21
22int main()
23{
24 // The following example is for a std::vector but any seqan3 data structure that is documented as serialisable
25 // could be used, e.g. seqan3::fm_index.
26 seqan3::test::tmp_filename tmp_file{"data.out"}; // This is a temporary file, use any other filename.
27
28 std::vector<int16_t> vec{1,2,3,4};
29 store(vec, tmp_file); // Calls store on a std::vector.
30
31 return 0;
32}
Provides seqan3::debug_stream and related types.