当前位置: 首页 > news >正文

成年做羞羞的视频网站网站seo基础优化

成年做羞羞的视频网站,网站seo基础优化,网站建设陆金手指谷哥4,东莞网站建设公司基于JNI 实现 嵌套 List 类型参数解析 背景分析解决 背景 在前面两篇文章中,我们总结了Java 调用 C/C SDK 的几种方案,分享了JNI在实践过程中的一些踩坑点,而在这篇文章将继续分享针对Java List类型及其嵌套类型,我们的JNI如何接…

基于JNI 实现 嵌套 List 类型参数解析

    • 背景
    • 分析
    • 解决

背景

在前面两篇文章中,我们总结了Java 调用 C/C++ SDK 的几种方案,分享了JNI在实践过程中的一些踩坑点,而在这篇文章将继续分享针对Java List类型及其嵌套类型,我们的JNI如何接收。

分析

如下,是我的的SDK的结构体定义:

struct CustomParam{std::string key;std::vector<std::string> values;
};

SDK的请求体入参定义如下:

struct Request
{std::string ref_text;std::vector<CustomParam> word_list; Request& operator=(const Request &other){ref_text = other.ref_text;word_list = other.word_list;return *this;}
};

解决

● 根据上面的SDK结构体的相关定义,我们在Java层可以有如下的 类型定义:

public class CustomParam {String key = "";List<String> values = new ArrayList<>();public String getKey() {return key;}public void setWord(String key) {this.key = key;}public List<String> getValues() {return values;}public void setValues(List<String> values) {this.values = values;}
}

● 关于native的方法申明如下:

public class CustomParamNative {public static native int starts(ArrayList<Object> customParam);}

● 根据native方法生成 头部文件

javac -encoding utf8 -h . XXX.java

● 如下为生成的native方法的头部文件

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_study_core_jni_CustomParamNative */#ifndef _Included_com_study_core_jni_CustomParamNative
#define _Included_com_study_core_jni_CustomParamNative
#ifdef __cplusplus
extern "C" {
#endif/** Class:     com_study_core_jni_CustomParamNative* Method:    starts* Signature: (JLjava/lang/String;Ljava/lang/String;F)I*/
JNIEXPORT jint JNICALL Java_com_study_core_jni_CustomParamNative_starts(JNIEnv *, jclass, jlong, jstring, jstring, jfloat);#ifdef __cplusplus
}
#endif
#endif

● 头部文件的具体实现

#include "com_study_core_jni_CustomParamNative.h"
#include <vector>
#undef __request
#define __request Request#include "stdio.h"
#include "stdlib.h"JNIEXPORT jint JNICALL Java_com_study_core_jni_CustomParamNative_starts(JNIEnv *env, jclass obj, jstring jni_ref, jobject customParamList)
{__request request;CopyString(env, thread->text_buff, jni_ref);request.ref_text = thread->text_buff.data();CopyString(env, thread->text_buff, jni_utt);request.audio_id = thread->text_buff.data();if (customParamList != NULL){// 获取ArrayList类和对应的方法IDjclass arrayListClass = env->FindClass("java/util/ArrayList");jmethodID getMethodID = env->GetMethodID(arrayListClass, "get", "(I)Ljava/lang/Object;");jmethodID sizeMethodID = env->GetMethodID(arrayListClass, "size", "()I");// 获取CustomParam类和对应的字段IDjclass customParamClass = env->FindClass("com/seewo/study/core/bo/CustomParam");jfieldID wordFieldID = env->GetFieldID(customParamClass, "key", "Ljava/lang/String;");jfieldID valuesFieldID = env->GetFieldID(customParamClass, "values", "Ljava/util/List;");// 获取ArrayList的大小jint size = env->CallIntMethod(customParamList, sizeMethodID);printf("size = %d\n", size);// 遍历ArrayList并解析CustomParam对象for (int i = 0; i < size; i++){// 获取CustomParam对象jobject customParamObj = env->CallObjectMethod(customParamList, getMethodID, i);// 获取key字段的值jstring wordString = (jstring)env->GetObjectField(customParamObj, wordFieldID);printf("字符 = %c\n", wordString);jboolean is_copy;const char *word = env->GetStringUTFChars(wordString, &is_copy);printf("字符 = %c\n", word);// 将word和values赋值给C++结构体// 创建CustomParam结构体对象CustomParam customParam;// 将word字段的值赋值给C++结构体customParam.word = word;// 获取values字段的值jobject valuesList = env->GetObjectField(customParamObj, valuesFieldID);jclass listClass = env->FindClass("java/util/List");jmethodID toArrayMethodID = env->GetMethodID(listClass, "toArray", "()[Ljava/lang/Object;");jobjectArray valuesArray = (jobjectArray)env->CallObjectMethod(valuesList, toArrayMethodID);jsize size = env->GetArrayLength(valuesArray);std::vector<std::string> values;for (int j = 0; j < size; j++){jstring valuesString = (jstring)env->GetObjectArrayElement(valuesArray, j);const char *pron = env->GetStringUTFChars(valuesString, &is_copy);values.push_back(pron);env->ReleaseStringUTFChars(valuesString, pron);env->DeleteLocalRef(valuesString);}customParam.values = values;request.word_list.push_back(customParam);// 释放资源env->DeleteLocalRef(customParamObj);env->ReleaseStringUTFChars(wordString, word);env->DeleteLocalRef(wordString);env->DeleteLocalRef(valuesList);env->DeleteLocalRef(valuesArray);}// 释放资源env->DeleteLocalRef(arrayListClass);env->DeleteLocalRef(customParamClass);return ThreadHandleStarts<__request>(request);}}
http://www.hkea.cn/news/818089/

相关文章:

  • 泉州网站建设工作室谷歌seo价格
  • 国建设委员会网站百度推广一天烧几千
  • 做网站 花园路国贸营销推广方案包括哪些内容
  • 做商城网站哪里买口碑营销属于什么营销
  • 鞋子 东莞网站建设真正的免费建站在这里
  • 网站上微信的链接怎么做项目平台
  • 做网站后有人抢注关键词网络营销方案策划论文
  • 苏州网站建设网站seo优化的方法
  • 设计网装修seo顾问服
  • 网站ip拦截免费网站搭建平台
  • 深圳企业网站建设公司快速申请免费个人网站
  • 唯品会 一家专门做特卖的网站沈阳seo按天计费
  • 聊城手机网站建设郑州seo服务技术
  • 个人定做衣服店江门seo推广公司
  • 网站开发与网站建设山东济南seo整站优化费用
  • 香港疫情最新消息今天深圳seo教程
  • 维护一个网站难吗免费发布外链
  • 南安市网站建设成都今天重大新闻事件
  • 网站后台补丁如何做软文有哪几种类型
  • 网站建设的费用包括哪些内容资讯门户类网站有哪些
  • 一站式服务图片制作网页的基本步骤
  • 个人网站建设网站网络网站推广
  • asp做的药店网站模板北京百度快照推广公司
  • 网站建设泉州效率网络seo的优化策略有哪些
  • 页网站无锡网站制作推广
  • 一流的龙岗网站建设目前最靠谱的推广平台
  • 企业营销型网站费用短视频推广引流
  • 化妆品可做的团购网站有哪些seo研究中心南宁线下
  • 网站空间域名是什么做电商必备的几个软件
  • 软件公司运营是做什么的seo公司运营