rds2cpp
C++ library for parsing RDS files
Loading...
Searching...
No Matches
write_rds.hpp
Go to the documentation of this file.
1#ifndef RDS2CPP_WRITE_RDS_HPP
2#define RDS2CPP_WRITE_RDS_HPP
3
4#include <vector>
5
6#include "RdsFile.hpp"
7#include "RObject.hpp"
8#include "utils_write.hpp"
9#include "write_object.hpp"
10#include "SharedWriteInfo.hpp"
11
12#include "byteme/GzipFileWriter.hpp"
13
20namespace rds2cpp {
21
30template<class Writer>
32 std::vector<unsigned char> buffer;
33 inject_string("X\n", 2, buffer);
35
36 buffer.push_back(0);
37 for (auto x : info.writer_version) {
38 buffer.push_back(x);
39 }
40
41 buffer.push_back(0);
42 for (auto x : info.reader_version) {
43 buffer.push_back(x);
44 }
45
46 size_t encoding_len = info.encoding.size();
49 writer.write(buffer.data(), buffer.size());
50
53
54 return;
55}
56
63inline void write_rds(const RdsFile& info, const char* path) {
64 byteme::GzipFileWriter writer(path);
66 return;
67}
68
75inline void write_rds(const RdsFile& info, std::string path) {
76 write_rds(info, path.c_str());
77 return;
78}
79
80
81}
82
83#endif
Representations of unserialized R objects.
Information about an RDS file.
Parse an RDS file in C++.
Definition StringEncoding.hpp:10
RdsFile parse_rds(Reader_ &reader)
Definition parse_rds.hpp:34
void write_rds(const RdsFile &info, Writer &writer)
Definition write_rds.hpp:31
Contents of the parsed RDS file.
Definition RdsFile.hpp:21
std::array< unsigned char, 3 > writer_version
Definition RdsFile.hpp:53
std::unique_ptr< RObject > object
Definition RdsFile.hpp:68
std::vector< Symbol > symbols
Definition RdsFile.hpp:80
std::vector< ExternalPointer > external_pointers
Definition RdsFile.hpp:86
std::string encoding
Definition RdsFile.hpp:63
uint32_t format_version
Definition RdsFile.hpp:48
std::vector< Environment > environments
Definition RdsFile.hpp:74
std::array< unsigned char, 3 > reader_version
Definition RdsFile.hpp:58