Dependents:   communication

Committer:
inst
Date:
Thu Mar 31 04:42:55 2016 +0000
Revision:
0:f398994b70f5

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
inst 0:f398994b70f5 1 #ifndef SIMPLE_MAP_SERIALIZER_HPP
inst 0:f398994b70f5 2 #define SIMPLE_MAP_SERIALIZER_HPP
inst 0:f398994b70f5 3
inst 0:f398994b70f5 4 #include <string>
inst 0:f398994b70f5 5 #include <map>
inst 0:f398994b70f5 6 #include "ValueToString.hpp"
inst 0:f398994b70f5 7
inst 0:f398994b70f5 8 namespace SimpleMapSerialization{
inst 0:f398994b70f5 9 template <class T,class U>
inst 0:f398994b70f5 10 std::string simpleMapSerializer(char delim,const std::map<T,U>& map)
inst 0:f398994b70f5 11 {
inst 0:f398994b70f5 12 std::string s;
inst 0:f398994b70f5 13 for (typename std::map<T,U>::iterator mapIte = map.begin(); mapIte != map.end(); mapIte++) {
inst 0:f398994b70f5 14 T key = mapIte->first;
inst 0:f398994b70f5 15 U val = mapIte->second;
inst 0:f398994b70f5 16 std::string sKey = ConvertData::ValueToString(key) + delim;
inst 0:f398994b70f5 17 std::string sVal = ConvertData::ValueToString(val) + delim;
inst 0:f398994b70f5 18 s += sKey + sVal;
inst 0:f398994b70f5 19 }
inst 0:f398994b70f5 20 s.resize(s.size() - 1);
inst 0:f398994b70f5 21 return s;
inst 0:f398994b70f5 22 }
inst 0:f398994b70f5 23 }
inst 0:f398994b70f5 24
inst 0:f398994b70f5 25 #endif //SIMPLE_MAP_SERIALIZER_HPP