14 #ifndef __INCLUDED__SCOPIRA_TOOL_TRAITS_H__ 15 #define __INCLUDED__SCOPIRA_TOOL_TRAITS_H__ 19 #include <scopira/tool/flow.h> 20 #include <scopira/tool/util.h> 21 #include <scopira/tool/platform.h> 47 template <class EE> class
flowtraits_g<std::vector<EE> >;
64 static bool load_collection(
itflow_i &in, COL &v) {
65 typename COL::iterator ii, endii;
71 v.resize(static_cast<size_t>(sz));
73 for (ii=v.begin(); ii != endii; ++ii)
81 static void save_collection(
otflow_i &out,
const COL &v) {
82 typename COL::const_iterator ii, endii;
90 for (ii=v.begin(); ii !=endii; ++ii)
103 static bool load(
itflow_i &in, T & outv) {
return outv.load(in); }
104 static void save(
otflow_i &out,
const T &v) { v.save(out); }
105 static void to_string(
const T &v, std::string &out) { out =
"binary"; }
106 static bool from_string(std::string &s, T &out) {
return false; }
117 static bool from_string(std::string &s,
bool &out) {
int i;
bool b =
tool::string_to_int(s,i); out= i!=0;
return b; }
125 static bool load(
itflow_i &in,
unsigned char & outv) {
return in.
read_byte(outv)>0; }
127 static void to_string(
const unsigned char &v, std::string &out) {
tool::int_to_string(v,out); }
128 static bool from_string(std::string &s,
unsigned char &out) {
int i;
bool b =
tool::string_to_int(s,i); out=
static_cast<unsigned char>(i);
return b; }
139 static bool from_string(std::string &s,
char &out) {
int i;
bool b =
tool::string_to_int(s,i); out=
static_cast<char>(i);
return b; }
147 static bool load(
itflow_i &in,
short & outv) {
bool b;
int ii; b = in.
read_int(ii); outv = ii;
return b; }
150 static bool from_string(std::string &s,
short &out) {
int i;
bool b =
tool::string_to_int(s,i); out=
static_cast<short>(i);
return b; }
197 static bool from_string(std::string &s,
float &out) {
double i;
bool b =
tool::string_to_double(s,i); out=
static_cast<float>(i);
return b; }
206 static void save(
otflow_i &out,
const double &v) { out.write_double(v); }
219 static void to_string(
const std::string &v, std::string &out) { out = v; }
220 static bool from_string(std::string &s, std::string &out) { out = s;
return true; }
229 static bool load(
itflow_i &in, std::vector<EE> & outv) {
return load_collection(in, outv); }
230 static void save(
otflow_i &out,
const std::vector<EE> &v) { save_collection(out, v); }
231 static void to_string(
const std::vector<EE> &v, std::string &out) { out =
"std::vector<EE>"; }
232 static bool from_string(std::string &s, std::vector<EE> &out) {
return false; }
Definition: archiveflow.h:20