Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
raw_unpack_file.hpp
Go to the documentation of this file.
1#pragma once
2#include <fc/io/raw.hpp>
4#include <fc/filesystem.hpp>
6
7namespace fc
8{
9 namespace raw
10 {
11 template<typename T>
12 void unpack_file( const fc::path& filename, T& obj )
13 {
14 try {
15 fc::file_mapping fmap( filename.generic_string().c_str(), fc::read_only);
16 fc::mapped_region mapr( fmap, fc::read_only, 0, fc::file_size(filename) );
17 auto cs = (const char*)mapr.get_address();
18
20 fc::raw::unpack(ds,obj);
21 } FC_RETHROW_EXCEPTIONS( info, "unpacking file ${file}", ("file",filename) );
22 }
23 }
24}
size_t get_size() const
void * get_address() const
wraps boost::filesystem::path to provide platform independent path manipulation.
std::string generic_string() const
Defines exception's used by fc.
#define FC_RETHROW_EXCEPTIONS(LOG_LEVEL, FORMAT,...)
Catchs all exception's, std::exceptions, and ... and rethrows them after appending the provided log m...
void unpack(Stream &s, std::deque< T > &value)
Definition raw.hpp:540
void unpack_file(const fc::path &filename, T &obj)
namespace sysio::chain
Definition authority.cpp:3
@ read_only
uint64_t file_size(const path &p)
#define T(meth, val, expected)