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:
authorVladiMihaylenko <vxmihaylenko@gmail.com>2017-10-23 14:30:37 +0300
committerr.kuznetsov <r.kuznetsov@corp.mail.ru>2017-11-09 13:20:32 +0300
commitd4fe66cb4b332e125bcb31e61e49aa319cb637aa (patch)
treeed1882768323e3b588e3cfa5977b69c44257eeff /indexer/ftraits.hpp
parent568c2f21e16408941273613207ba247e16f2dae4 (diff)
Using optionals in ftraits
Diffstat (limited to 'indexer/ftraits.hpp')
-rw-r--r--indexer/ftraits.hpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/indexer/ftraits.hpp b/indexer/ftraits.hpp
index 6a301c5a9f..83e4c73ccb 100644
--- a/indexer/ftraits.hpp
+++ b/indexer/ftraits.hpp
@@ -17,32 +17,32 @@
#include <string>
#include <utility>
+#include <boost/optional.hpp>
+
namespace ftraits
{
template <typename Base, typename Value>
class TraitsBase
{
public:
- static bool GetValue(feature::TypesHolder const & types, Value & value)
+ static boost::optional<Value> GetValue(feature::TypesHolder const & types)
{
auto const & instance = Instance();
auto const it = Find(types);
if (!instance.m_matcher.IsValid(it))
- return false;
+ return boost::none;
- value = it->second;
- return true;
+ return it->second;
}
- static bool GetType(feature::TypesHolder const & types, uint32_t & type)
+ static boost::optional<uint32_t> GetType(feature::TypesHolder const & types)
{
auto const & instance = Instance();
auto const it = Find(types);
if (!instance.m_matcher.IsValid(it))
- return false;
+ return boost::none;
- type = it->first;
- return true;
+ return it->first;
}
private:
@@ -165,29 +165,30 @@ public:
static bool IsUGCAvailable(feature::TypesHolder const & types)
{
- UGCItem item;
- return GetValue(types, item) ? IsUGCAvailable(item.m_mask) : false;
+ auto const opt = GetValue(types);
+ return opt ? IsUGCAvailable(opt->m_mask) : false;
}
static bool IsRatingAvailable(feature::TypesHolder const & types)
{
- UGCItem item;
- return GetValue(types, item) ? IsRatingAvailable(item.m_mask) : false;
+ auto const opt = GetValue(types);
+ return opt ? IsRatingAvailable(opt->m_mask) : false;
}
static bool IsReviewsAvailable(feature::TypesHolder const & types)
{
- UGCItem item;
- return GetValue(types, item) ? IsReviewsAvailable(item.m_mask) : false;
+ auto const opt = GetValue(types);
+ return opt ? IsReviewsAvailable(opt->m_mask) : false;
}
static bool IsDetailsAvailable(feature::TypesHolder const & types)
{
- UGCItem item;
- return GetValue(types, item) ? IsDetailsAvailable(item.m_mask) : false;
+ auto const opt = GetValue(types);
+ return opt ? IsDetailsAvailable(opt->m_mask) : false;
}
static UGCRatingCategories GetCategories(feature::TypesHolder const & types)
{
- UGCItem item;
- GetValue(types, item);
- return item.m_categories;
+ auto const opt = GetValue(types);
+ if (opt)
+ return opt->m_categories;
+ return {};
}
};