mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
added string serialization
This commit is contained in:
19
cereal.hpp
19
cereal.hpp
@@ -3,6 +3,7 @@
|
||||
#include <iostream>
|
||||
#include <type_traits>
|
||||
#include "traits.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
@@ -131,4 +132,22 @@ namespace cereal
|
||||
std::cout << "Serializing NVP: " << t.name << " " << t.value << std::endl;
|
||||
ar & t.value;
|
||||
}
|
||||
|
||||
//! Serialization for basic_string types to binary
|
||||
template<class CharT, class Traits, class Alloc>
|
||||
void save(BinaryOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
|
||||
{
|
||||
// Save number of chars + the data
|
||||
ar & str.size();
|
||||
ar.save_binary(str.data(), str.size() * sizeof(CharT));
|
||||
|
||||
std::cout << "Saving string: " << str << std::endl;
|
||||
}
|
||||
|
||||
//! Serialization for basic_string types to binary
|
||||
template<class CharT, class Traits, class Alloc>
|
||||
void load(BinaryOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> & str)
|
||||
{
|
||||
std::cout << "Loading string: " << str << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user