14 template<
class Stream>
bool IsReading(
const Stream&) {
15 return typeid(Stream) ==
typeid(std::ifstream);
19 static inline void SerializeT(std::ifstream& s, std::string& t) {
23 static inline void SerializeT(std::ofstream& s,
const std::string& t) {
28 static inline void SerializeT(std::ifstream& s,
bool& t) {
30 if (!std::getline(s, linein))
33 uint32_t value = std::stoi(linein);
37 void inline SerializeT(std::ofstream& s,
bool t) {
39 s <<
"1" << std::endl;
42 s <<
"0" << std::endl;
47 template<
typename T>
void SerializeT(std::ifstream& s, T& t) {
49 if (!std::getline(s, linein))
52 uint32_t value = std::stoi(linein);
53 t =
static_cast<T
>(value);
56 template<
typename T>
void SerializeT(std::ofstream& s, T t) {
57 s << std::to_string(static_cast<uint32_t>(t)) << std::endl;
60 static inline void SerializeT(std::ofstream& data_file,
const std::set<uint32_t>& s) {
61 data_file << std::to_string(s.size()) << std::endl;
62 for (std::set<uint32_t>::const_iterator it = s.begin(); it != s.end(); ++it) {
64 data_file << std::to_string(value) << std::endl;
68 static inline void SerializeT(std::ifstream& data_file, std::set<uint32_t>& s) {
69 uint32_t set_size = 0;
70 SerializeT<uint32_t>(data_file, set_size);
71 for (uint32_t i = 0; i < set_size; ++i) {
73 SerializeT<uint32_t>(data_file, value);
Definition: sc2_action.h:9