Пример #1
0
 bool has_members(std::set<std::string> members_,
                  const rapidjson::GenericValue<Encoding, Allocator>& v_)
 {
   if (v_.IsObject())
   {
     for (auto i = v_.MemberBegin(), e = v_.MemberEnd(); i != e; ++i)
     {
       const auto& name = i->name;
       if (name.IsString())
       {
         const auto m = members_.find(
             std::string(name.GetString(), name.GetStringLength()));
         if (m != members_.end())
         {
           members_.erase(m);
           if (members_.empty())
           {
             return true;
           }
         }
       }
     }
     return members_.empty();
   }
   return false;
 }
Пример #2
0
 bool
 member_compare(const std::set<std::string>& members_,
                const rapidjson::GenericValue<Encoding, Allocator>& v_)
 {
   if (v_.IsObject())
   {
     decltype(members_.size()) n = 0;
     for (auto i = v_.MemberBegin(), e = v_.MemberEnd(); i != e; ++i)
     {
       const auto& name = i->name;
       if (!name.IsString() ||
           members_.find(
               std::string(name.GetString(), name.GetStringLength())) ==
               members_.end())
       {
         return false;
       }
       if (ExpectFullMatch)
       {
         ++n;
       }
     }
     return !ExpectFullMatch || n == members_.size();
   }
   else
   {
     return false;
   }
 }