Skip to content

Instantly share code, notes, and snippets.

@LiewJunTung
Last active June 18, 2018 13:13
Show Gist options
  • Save LiewJunTung/5f903526d96c60e6a769f226b9dd5609 to your computer and use it in GitHub Desktop.
Save LiewJunTung/5f903526d96c60e6a769f226b9dd5609 to your computer and use it in GitHub Desktop.
struct String
{
using CppType = std::string;
using JniType = jstring;
using Boxed = String;
static CppType toCpp(JNIEnv* jniEnv, JniType j)
{
assert(j != nullptr);
return jniUTF8FromString(jniEnv, j);
}
static LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c)
{
return {jniEnv, jniStringFromUTF8(jniEnv, c)};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment