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:
authorAlex Zolotarev <deathbaba@gmail.com>2010-12-05 19:24:16 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-22 22:33:57 +0300
commitd6e12b7ce4bcbf0ccd1c07eb25de143422913c34 (patch)
treea7e910c330ce4da9b4f2d8be76067adece2561c4 /indexer/features_vector.hpp
One Month In Minsk. Made in Belarus.
Diffstat (limited to 'indexer/features_vector.hpp')
-rw-r--r--indexer/features_vector.hpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/indexer/features_vector.hpp b/indexer/features_vector.hpp
new file mode 100644
index 0000000000..8000ea66fa
--- /dev/null
+++ b/indexer/features_vector.hpp
@@ -0,0 +1,53 @@
+#pragma once
+#include "../indexer/feature.hpp"
+#include "../coding/var_record_reader.hpp"
+#include "../base/base.hpp"
+#include "../std/bind.hpp"
+
+template <typename ReaderT>
+class FeaturesVector
+{
+public:
+ typedef ReaderT ReaderType;
+
+ explicit FeaturesVector(ReaderT const & reader) : m_RecordReader(reader, 256)
+ {
+ }
+
+ void Get(uint64_t pos, Feature & feature) const
+ {
+ vector<char> record;
+ uint32_t offset;
+ m_RecordReader.ReadRecord(pos, record, offset);
+ feature.Deserialize(record, offset);
+ }
+
+ template <class TDo> void ForEachOffset(TDo const & toDo) const
+ {
+ Feature f;
+ m_RecordReader.ForEachRecord(
+ bind<void>(toDo, bind(&FeaturesVector<ReaderT>::DeserializeFeature, this, _2, _3, &f), _1));
+ }
+
+ template <class TDo> void ForEach(TDo const & toDo) const
+ {
+ Feature f;
+ m_RecordReader.ForEachRecord(
+ bind<void>(toDo, bind(&FeaturesVector<ReaderT>::DeserializeFeature, this, _2, _3, &f)));
+ }
+
+ bool IsMyData(string const & fName) const
+ {
+ return m_RecordReader.IsEqual(fName);
+ }
+
+private:
+ Feature const & DeserializeFeature(char const * data, uint32_t size, Feature * pFeature) const
+ {
+ vector<char> data1(data, data + size);
+ pFeature->Deserialize(data1);
+ return *pFeature;
+ }
+
+ VarRecordReader<ReaderT, &VarRecordSizeReaderVarint> m_RecordReader;
+};