void serialize(output_archive & ar, const std::basic_string<Char, CharTraits, Allocator> & s, unsigned) { std::uint64_t size = s.size(); ar << size; save_binary(ar, s.data(), s.size() * sizeof(Char)); }
void save_bitwise(T const & t, boost::mpl::true_) { BOOST_STATIC_ASSERT_MSG(!boost::is_abstract<T>::value, "Can not bitwise serialize a class that is abstract"); if(disable_array_optimization()) { serialize(*this, const_cast<T &>(t), 0); } else { save_binary(&t, sizeof(t)); } }
void save_integral_impl(boost::int64_t l) { const std::size_t size = sizeof(boost::int64_t); char* cptr = reinterpret_cast<char *>(&l); #ifdef BOOST_BIG_ENDIAN if(endian_little()) reverse_bytes(size, cptr); #else if(endian_big()) reverse_bytes(size, cptr); #endif save_binary(cptr, size); }
bool load_kernels(bool experimental) { /* verify if device was initialized */ if(!device_initialized) { fprintf(stderr, "OpenCL: failed to initialize device.\n"); return false; } /* verify we have right opencl version */ if(!opencl_version_check()) return false; /* md5 hash to detect changes */ string kernel_path = path_get("kernel"); string kernel_md5 = path_files_md5_hash(kernel_path); string device_md5 = device_md5_hash(); /* try to use cache binary */ string clbin = string_printf("cycles_kernel_%s_%s.clbin", device_md5.c_str(), kernel_md5.c_str());; clbin = path_user_get(path_join("cache", clbin)); if(path_exists(clbin)) { /* if exists already, try use it */ if(!load_binary(kernel_path, clbin)) return false; } else { /* compile kernel */ if(!compile_kernel(kernel_path, kernel_md5)) return false; /* save binary for reuse */ save_binary(clbin); } /* find kernels */ ckPathTraceKernel = clCreateKernel(cpProgram, "kernel_ocl_path_trace", &ciErr); if(opencl_error(ciErr)) return false; ckFilmConvertKernel = clCreateKernel(cpProgram, "kernel_ocl_tonemap", &ciErr); if(opencl_error(ciErr)) return false; return true; }
void save_format(GraphType& g, const std::string& prefix, const std::string& format, bool gzip = true, size_t files_per_machine = 4) { if (prefix.length() == 0) return; if (format == "snap" || format == "tsv") { save(g, prefix, builtin_parsers::tsv_writer<GraphType>(), gzip, false, true, files_per_machine); } else if (format == "graphjrl") { save(g, prefix, builtin_parsers::graphjrl_writer<GraphType>(), gzip, true, true, files_per_machine); } else if (format == "bin") { save_binary(g, prefix); } // else if (format == "bintsv4") { // save_direct(prefix, gzip, &graph_type::save_bintsv4_to_stream); // } else { logstream(LOG_ERROR) << "Unrecognized Format \"" << format << "\"!" << std::endl; throw(std::string("Unrecognized Format \"" + format + "\"")); return; } } // end of save structure
// trap usage of invalid uninitialized boolean which would // otherwise crash on load. void save(const bool t){ BOOST_ASSERT(0 == static_cast<int>(t) || 1 == static_cast<int>(t)); save_binary(& t, sizeof(t)); }
// trap usage of invalid uninitialized boolean which would // otherwise crash on load. void save(const bool t) { int i = t; assert(0 == i || 1 == i); save_binary(& t, sizeof(t)); }
void serialize(output_archive & ar, std::basic_string<Char, CharTraits, Allocator> & s, unsigned) { ar << s.size(); //-V128 save_binary(ar, s.data(), s.size() * sizeof(Char)); }
void project_info::write(std::ostream& s) { s << name << std::endl; s << "rom=" << rom << std::endl; if(last_save != "") s << "last-save=" << last_save << std::endl; s << "directory=" << directory << std::endl; s << "prefix=" << prefix << std::endl; for(auto i : luascripts) s << "luascript=" << i << std::endl; s << "gametype=" << gametype << std::endl; s << "coreversion=" << coreversion << std::endl; if(gamename != "") s << "gamename=" << gamename << std::endl; s << "projectid=" << projectid << std::endl; s << "time=" << movie_rtc_second << ":" << movie_rtc_subsecond << std::endl; for(auto i : authors) s << "author=" << i.first << "|" << i.second << std::endl; for(unsigned i = 0; i < ROM_SLOT_COUNT; i++) { if(romimg_sha256[i] != "") { if(i) s << "slotsha" << static_cast<char>(96 + i) << "=" << romimg_sha256[i] << std::endl; else s << "romsha=" << romimg_sha256[i] << std::endl; } if(romxml_sha256[i] != "") { if(i) s << "slotxml" << static_cast<char>(96 + i) << "=" << romxml_sha256[i] << std::endl; else s << "romxml=" << romxml_sha256[i] << std::endl; } if(namehint[i] != "") { if(i) s << "slothint" << static_cast<char>(96 + i) << "=" << namehint[i] << std::endl; else s << "romhint=" << namehint[i] << std::endl; } if(roms[i] != "") { if(i) s << "slotrom" << static_cast<char>(96 + i) << "=" << roms[i] << std::endl; else s << "romrom=" << roms[i] << std::endl; } } for(auto i : settings) s << "setting." << i.first << "=" << i.second << std::endl; for(auto i : watches) s << "watch." << eq_escape(i.first) << "=" << i.second << std::endl; for(auto i : macros) s << "macro." + i.first << "=" << i.second.serialize() << std::endl; for(auto i : movie_sram) save_binary(s, "sram." + i.first, i.second); if(anchor_savestate.size()) save_binary(s, "anchor", anchor_savestate); for(auto& i : branches) { s << "branch" << i.first << "parent=" << i.second.pbid << std::endl; s << "branch" << i.first << "name=" << i.second.name << std::endl; } s << "branchcurrent=" << active_branch << std::endl; s << "branchnext=" << next_branch << std::endl; }
void save(char c) { save_binary(&c, sizeof(char)); }
void save(double d) { save_binary(&d, sizeof(double)); }
void save(float f) { save_binary(&f, sizeof(float)); }
void content_manager::save_content( const crap::string64& id, void* ptr, type_name type ) { u32 str_hash = string_to_hash<64>( id ); CRAP_ASSERT_DEBUG( _filelist.find( str_hash ) != _filelist.end(), "Object not known." ); save_binary( str_hash, ptr, type); }
save(const std::basic_string<SE, ST, SA> &s) { std::size_t l = static_cast<std::size_t>(s.size()); this->This()->save(l); save_binary(s.data(), l * sizeof(SE) / sizeof(char)); }
binary_out & operator <<(T const & value) { save_binary(value, sizeof(T)); return *this; }
void save(const T & t) { save_binary(& t, sizeof(T)); }
void save(bool b) { HPX_ASSERT(0 == static_cast<int>(b) || 1 == static_cast<int>(b)); save_binary(&b, sizeof(bool)); }