ZT_jniarray.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // Created by Grant Limberg on 10/21/20.
  3. //
  4. #ifndef ZEROTIERANDROID_ZT_JNIARRAY_H
  5. #define ZEROTIERANDROID_ZT_JNIARRAY_H
  6. #include <jni.h>
  7. #include <vector>
  8. #include <string>
  9. extern jclass java_util_ArrayList;
  10. extern jmethodID java_util_ArrayList_;
  11. extern jmethodID java_util_ArrayList_size;
  12. extern jmethodID java_util_ArrayList_get;
  13. extern jmethodID java_util_ArrayList_add;
  14. void InitListJNI(JNIEnv* env);
  15. class ListJNI {
  16. public:
  17. // Get the java class id of java.util.List.
  18. static jclass getListClass(JNIEnv* env);
  19. // Get the java class id of java.util.ArrayList.
  20. static jclass getArrayListClass(JNIEnv* env);
  21. // Get the java class id of java.util.Iterator.
  22. static jclass getIteratorClass(JNIEnv* env);
  23. // Get the java method id of java.util.List.iterator().
  24. static jmethodID getIteratorMethod(JNIEnv* env);
  25. // Get the java method id of java.util.Iterator.hasNext().
  26. static jmethodID getHasNextMethod(JNIEnv* env);
  27. // Get the java method id of java.util.Iterator.next().
  28. static jmethodID getNextMethod(JNIEnv* env);
  29. // Get the java method id of arrayList constructor.
  30. static jmethodID getArrayListConstructorMethodId(JNIEnv* env, jclass jclazz);
  31. // Get the java method id of java.util.List.add().
  32. static jmethodID getListAddMethodId(JNIEnv* env);
  33. };
  34. class ByteJNI {
  35. public:
  36. // Get the java class id of java.lang.Byte.
  37. static jclass getByteClass(JNIEnv* env);
  38. // Get the java method id of java.lang.Byte.byteValue.
  39. static jmethodID getByteValueMethod(JNIEnv* env);
  40. };
  41. jobject cppToJava(JNIEnv* env, std::vector<std::string> vector);
  42. std::vector<std::string> javaToCpp(JNIEnv* env, jobject arrayList);
  43. #endif //ZEROTIERANDROID_ZT_JNIARRAY_H