Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-02-09 14:36:00 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:33:38 +0300
commit6ae8b3c3cdac9cd3bfd5bd19375eb722509f93b1 (patch)
tree8d58d2b00ef01031846e9ea06c826148b294b13c /coding/read_write_utils.hpp
parent8e34c67e6b3a38f1e1dc5515584b499564617cb3 (diff)
Replace ReadRaw with ReadVectorOfPOD. Add tests.
Diffstat (limited to 'coding/read_write_utils.hpp')
-rw-r--r--coding/read_write_utils.hpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/coding/read_write_utils.hpp b/coding/read_write_utils.hpp
index e818809da3..b7bf10a14a 100644
--- a/coding/read_write_utils.hpp
+++ b/coding/read_write_utils.hpp
@@ -6,6 +6,7 @@
#include "../std/string.hpp"
#include "../std/vector.hpp"
+//#include "../std/type_traits.hpp"
namespace rw
@@ -86,27 +87,31 @@ namespace rw
}
template <class TSource, class TCont>
- void ReadRaw(TSource & src, TCont & v)
+ void ReadVectorOfPOD(TSource & src, TCont & v)
{
- STATIC_ASSERT(sizeof(typename TCont::value_type) == 1);
+ typedef typename TCont::value_type ValueT;
+ // Not every compiler support this.
+ //STATIC_ASSERT(boost::is_pod<ValueT>::value);
uint32_t const count = ReadVarUint<uint32_t>(src);
if (count > 0)
{
v.resize(count);
- src.Read(&v[0], count);
+ src.Read(&v[0], count * sizeof(ValueT));
}
}
template <class TSink, class TCont>
- void WriteRaw(TSink & sink, TCont const & v)
+ void WriteVectorOfPOD(TSink & sink, TCont const & v)
{
- STATIC_ASSERT(sizeof(typename TCont::value_type) == 1);
+ typedef typename TCont::value_type ValueT;
+ // Not every compiler support this.
+ //STATIC_ASSERT(boost::is_pod<ValueT>::value);
uint32_t const count = static_cast<uint32_t>(v.size());
WriteVarUint(sink, count);
if (count > 0)
- sink.Write(&v[0], count);
+ sink.Write(&v[0], count * sizeof(ValueT));
}
}