From 89deb48c319a2ba5cec08d2229ac155ef2884f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=AD=A6=E5=88=A9?= Date: Mon, 16 May 2022 08:54:36 +0000 Subject: [PATCH] =?UTF-8?q?TLD=5Farray=5Fappend=E6=94=AF=E6=8C=81=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=95=B0=E7=BB=84=E5=88=B0rapidjson?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/tsg_send_log.h | 3 +++ src/tsg_send_log.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/inc/tsg_send_log.h b/inc/tsg_send_log.h index b9703a0..e0f3abf 100644 --- a/inc/tsg_send_log.h +++ b/inc/tsg_send_log.h @@ -38,6 +38,9 @@ int TLD_append(struct TLD_handle_t *handle, char *key, void *value, TLD_TYPE typ int TLD_append_streaminfo(struct tsg_log_instance_t *instance, struct TLD_handle_t *handle, struct streaminfo *a_stream); int TLD_cancel(struct TLD_handle_t *handle); struct TLD_handle_t *TLD_duplicate(struct TLD_handle_t *handle); +//type only TLD_TYPE_LONG/TLD_TYPE_STRING +int TLD_array_append(struct TLD_handle_t *handle, char *key, void **array, int array_num, TLD_TYPE type); + int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handle, tsg_log_t *log_msg, int thread_id); diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp index 9e5b0c6..59ad2e1 100644 --- a/src/tsg_send_log.cpp +++ b/src/tsg_send_log.cpp @@ -966,6 +966,40 @@ int TLD_append(struct TLD_handle_t *handle, char *key, void *value, TLD_TYPE typ return 0; } +int TLD_array_append(struct TLD_handle_t *handle, char *key, void **array, int array_num, TLD_TYPE type) +{ + if(handle==NULL || key==NULL || array_num<=0 || array==NULL || type!=TLD_TYPE_LONG || type!=TLD_TYPE_STRING) + { + return -1; + } + + int i=0; + Value obj_array(kArrayType); + + switch(type) + { + case TLD_TYPE_LONG: + for(i=0; idocument->GetAllocator()); + } + break; + case TLD_TYPE_STRING: + for(i=0; idocument->GetAllocator()); + } + break; + default: + return -1; + } + + add_object_member(handle, handle->document, key, obj_array); + + return 1; +} + struct TLD_handle_t *TLD_duplicate(struct TLD_handle_t *handle) { if (handle == NULL)