Shehryar Iqbal

Greenhorn
+ Follow
since Sep 30, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shehryar Iqbal

I'm trying to convert Java class object implemented as Parcelable to native c++ Parcelable Array. I have below example that does the native Parcelable to java Parcelable I wanted to do vice versa.

template<class T, class BASE>
void JNIParcel::writeParcelableArray(shared_ptr<vector<shared_ptr<BASE>>> ptr) {
   vector<shared_ptr<BASE>> *array = ptr.get();
   int arrSize = array->size();
   jobjectArray jArray = mEnv->NewObjectArray(arrSize, clazz_Parcelable, jstring());
   typename vector<shared_ptr<BASE>>::iterator it = array->begin();
   int i = 0;
   while(it != array->end()){
       T* t = static_cast<T*>(&*it->get());
       mEnv->SetObjectArrayElement(jArray, i, t->toJParcelable(mEnv));
       i++;
       ++it;
   }
   mEnv->CallVoidMethod(obj, Parcel_writeTypedArray, jArray, 0);
   mEnv->DeleteLocalRef(jArray);
}
2 years ago