jobject convert(JNIEnv* env, const OfferID& offerId) { string data; offerId.SerializeToString(&data); // byte[] data = ..; jbyteArray jdata = env->NewByteArray(data.size()); env->SetByteArrayRegion(jdata, 0, data.size(), (jbyte*) data.data()); // OfferID offerId = OfferID.parseFrom(data); jclass clazz = FindMesosClass(env, "org/apache/mesos/Protos$OfferID"); jmethodID parseFrom = env->GetStaticMethodID(clazz, "parseFrom", "([B)Lorg/apache/mesos/Protos$OfferID;"); jobject jofferId = env->CallStaticObjectMethod(clazz, parseFrom, jdata); return jofferId; }
inline bool operator<(const OfferID& left, const OfferID& right) { return left.value() < right.value(); }
inline bool operator==(const OfferID& left, const std::string& right) { return left.value() == right; }
inline std::size_t hash_value(const OfferID& offerId) { size_t seed = 0; boost::hash_combine(seed, offerId.value()); return seed; }