AnalysisSystemForRadionucli.../CplusToJava.h
2024-06-04 15:25:02 +08:00

45 lines
1.7 KiB
C++

#pragma once
#include "jni.h"
#include <QVector>
#include "armadillo"
//变量名与java中sig对应
#define SIG_STRING "Ljava/lang/String;"
#define SIG_LIST "Ljava/util/List;"
#define SIG_DOUBLE "D"
#define SIG_INT "I"
#define SIG_LONG "J"
#define SIG_SHORT "S"
class CplusToJava
{
public:
static jobjectArray GetjobjectArray(JNIEnv* env, jclass jcls, jobject jstruct, std::string var);
//将QVector<double>转换为jobjectArray
static jobjectArray QVectorD2jobjectArray(QVector<double> vec, JNIEnv* env);
//将QVector<QString>转换为jobjectArray
static jobjectArray QVectorQS2jobjectArray(QVector<QString> vec, JNIEnv* env);
//将QVector<long>转换为jobjectArray
static jobjectArray QVectorL2jobjectArray(QVector<long> vec, JNIEnv* env);
//将QVector<int>转换为jobjectArray
static jobjectArray QVectorI2jobjectArray(QVector<int> vec, JNIEnv* env);
//将QVector<short>转换为jobjectArray
static jobjectArray QVectorS2jobjectArray(QVector<short> vec, JNIEnv* env);
//生成jobject
static jobject Createjobject(JNIEnv* env, jint esize, jobjectArray array);
//jobject转换为jobjectArray
static jobjectArray jobject2jobjectArray(JNIEnv* env, jobject array);
//将jobjectArray转换为QVector<double>
static QVector<double> jobjectArray2QVectorD(JNIEnv* env, jobjectArray listValue);
//将jstring转换为QString
static QString jstring2QString(JNIEnv* env, jstring jstr);
//将jobjectArray转换为vector<double>
static std::vector<double> jobjectArray2vectorD(JNIEnv* env, jobjectArray listValue);
//将vector<double>转换为jobjectArray
static jobjectArray VectorD2jobjectArray(std::vector<double> vec, JNIEnv* env);
//将uvec转为jobjectArray
static jobjectArray uvec2jobjectArray(arma::uvec vec, JNIEnv* env);
};