Loading...
Searching...
No Matches
string.hpp
Go to the documentation of this file.
#pragma once
#include <jni/object.hpp>
#include <jni/array.hpp>
#include <jni/make.hpp>
#include <jni/npe.hpp>
#include <jni/string_conversion.hpp>
namespace jni
{
using String = Object<StringTag>;
inline std::u16string MakeAnything(ThingToMake<std::u16string>, JNIEnv& env, const String& string)
{
NullCheck(env, string.get());
std::u16string result(jni::GetStringLength(env, *string), char16_t());
jni::GetStringRegion(env, *string, 0, result);
return result;
}
inline std::string MakeAnything(ThingToMake<std::string>, JNIEnv& env, const String& string)
{
return convertUTF16ToUTF8(Make<std::u16string>(env, string));
}
inline Local<String> MakeAnything(ThingToMake<String>, JNIEnv& env, const std::u16string& string)
{
return Local<String>(env, &NewString(env, string));
}
inline Local<String> MakeAnything(ThingToMake<String>, JNIEnv& env, const std::string& string)
{
return Make<String>(env, convertUTF8ToUTF16(string));
}
}
array.hpp
jni::Object
Definition object.hpp:45
make.hpp
jni
Definition advanced_ownership.hpp:6
jni::MakeAnything
std::vector< T > MakeAnything(ThingToMake< std::vector< T > >, JNIEnv &env, const Array< T > &array)
Definition array.hpp:114
jni::NewString
jstring & NewString(JNIEnv &env, const char16_t *chars, jsize len)
Definition functions.hpp:364
jni::GetStringLength
jsize GetStringLength(JNIEnv &env, jstring &string)
Definition functions.hpp:377
jni::String
Object< StringTag > String
Definition string.hpp:11
jni::NullCheck
void NullCheck(JNIEnv &env, T *ptr, const char *message=nullptr)
Definition npe.hpp:13
jni::GetStringRegion
void GetStringRegion(JNIEnv &env, jstring &string, jsize start, jsize len, char16_t *buf)
Definition functions.hpp:423
jni::Make
auto Make(P &&... p)
Definition make.hpp:8
jni::Local
Unique< T, DefaultRefDeleter<&JNIEnv::DeleteLocalRef > > Local
Definition unique.hpp:110
jni::convertUTF16ToUTF8
std::string convertUTF16ToUTF8(const std::u16string &string)
Definition string_conversion.hpp:17
jni::convertUTF8ToUTF16
std::u16string convertUTF8ToUTF16(const std::string &string)
Definition string_conversion.hpp:12
npe.hpp
object.hpp
string_conversion.hpp
jni::ThingToMake
Definition make.hpp:5