[Cppcms-users] What is the best practice to serialize vector of struct?
Brought to you by:
artyom-beilis
From: sergey l. <ccp...@gm...> - 2012-10-24 09:02:54
|
Hi All! What is the best practice to serialize vector of struct (std::vector<struct_name>)? Now I use ugly method to wrap main struct into struct container with std:vector member: struct page_container : public cppcms::serializable { struct page : public cppcms::serializable { std::string uuid; time_t insert_date; time_t update_date; void serialize(cppcms::archive &a) { a & uuid & insert_date & update_date; } }; std::vector<page> pages; void serialize(cppcms::archive &a) { a & pages; } }; page_container pages; if(!cache().fetch_data("pages", pages)) { get_pages(pages); cache().store_data("pages", pages); } Thanks in advance! |