Utils.h

// Utils.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2019

#pragma once

#include "cxJava.h"
#include "Ceda/cxUtils/xstring.h"
#include <jni.h>

class cxJava_API JavaStringToUtf8
{
public:
    JavaStringToUtf8(JNIEnv *env, jstring javaString);
    ~JavaStringToUtf8();
    operator const char*() { return utf8String_; }
private:
    JNIEnv* env_;
    jstring javaString_;
    const char* utf8String_;
};

cxJava_API void JavaStringToString8(ceda::string8& dst, JNIEnv *env, jstring src);
cxJava_API void SwallowCppExceptionAndThrowJava(JNIEnv * env);