设为首页 加入收藏

TOP

C++结构体与Delphi结构体相互传参,结构体中包含结构体的嵌套,数组指针(一)
2019-08-23 00:31:43 】 浏览:45
Tags:结构 Delphi 相互 包含 指针

//结构体的声明
 typedef struct Mwinddirectbaseline { char* p; int s; int i; }Mwinddirectbaseline; typedef struct F { char* p; int s; int i; }F; typedef struct H { char* p; int s; int i; }H; typedef struct Coordinate1 { char* p; int s; int i; }Coordinate1; typedef struct Mwinddirectbar { F f; H h; }Mwinddirectbar; typedef struct Huxianarray { float* Params; }Huxianarray; typedef struct Hengxianarray { float* Params; }Hengxianarray; typedef struct Windspeedline { char* types; Coordinate1** coordinates; }Windspeedline; typedef struct Resultwindspeedgrid { int HuxianShu; int HengxianShu; Huxianarray* HuxianArrays; Hengxianarray* HengxianArrays; }Resultwindspeedgrid; typedef struct Coordinate { Mwinddirectbaseline *mWindDirectBaseLine; Mwinddirectbar *mWindDirectBars; }Coordinate; typedef struct Winddirectline { Coordinate* coordinates; }Winddirectline; //typedef struct Structtest { // int a; // int b; // int* arr; //}Structtest;
 typedef struct Rootobject { char* gridStartTime; char* gridEndTime; char* resultStartTime; char* resultEndTime; int gridMethod; char* WindDirectBorder; Winddirectline WindDirectLine; char* WindSpeedBorder; Windspeedline WindSpeedLine; /*void* LineDateTimeRelations; void* RatioConverts;*/
    //void* 不确定类型
    char* resultWindDirectGrid; Resultwindspeedgrid resultWindSpeedGrid; }Rootobject;
C++结构体的声明
__declspec(dllexport) Rootobject __stdcall RefRootobjectValues(char* path) { ifstream t(path); Rootobject Root; string str((istreambuf_iterator<char>(t)), istreambuf_iterator<char>()); CJsonObject Objson = CJsonObject(str); string strsss; Objson.Get("gridStartTime", strsss); Root.gridStartTime = ReturnCharArr(strsss); Objson.Get("gridEndTime", strsss); Root.gridEndTime = ReturnCharArr(strsss); Objson.Get("resultStartTime", strsss); Root.resultStartTime = ReturnCharArr(strsss); Objson.Get("resultEndTime", strsss); Root.resultEndTime = ReturnCharArr(strsss); Objson.Get("WindSpeedBorder", strsss); Root.WindSpeedBorder = ReturnCharArr(strsss); Objson.Get("WindDirectBorder", strsss); Root.WindDirectBorder = ReturnCharArr(strsss); Objson.Get("resultWindDirectGrid", strsss); Root.resultWindDirectGrid = ReturnCharArr(strsss); int nums = Objson["WindDirectLine"]["coordinates"].GetArraySize(); Root.WindDirectLine.coordinates = (struct Coordinate *)malloc(nums * sizeof(struct Coordinate)); /*Coordinate* coor=new Coordinate [nums];*/
    /*由于School_T中定义的student是一个结构体指针,必须要对其进行分配内存*/
    //Root.WindDirectLine->coordinates = (coordinates *)malloc(sizeof(Student_T));

    for (int i = 0; i < nums; i++) { int mWindDirectBaseLine_Length = Objson["WindDirectLine"]["coordinates"][i]["mWindDirectBaseLine"].GetArraySize(); Root.WindDirectLine.coordinates[i].mWindDirectBaseLine = (struct Mwinddirectbaseline *)malloc(nums * sizeof(struct Mwinddirectbaseline)); for (int j = 0; j < mWindDirectBaseLine_Length; j++) { string Str1; Objson["WindDirectLine"]["coordinates"][i]["mWindDirectBaseLine"][j].Get("p", Str1); Root.WindDirectLine.coordinates[i].mWindDirectBaseLine[j].p = ReturnCharArr(Str1); Objson["WindDirectLine"]["coordin  
		
C++结构体与Delphi结构体相互传参,结构体中包含结构体的嵌套,数组指针(一) https://www.cppentry.com/bencandy.php?fid=86&id=229771

首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇delphi中WMI的使用(网卡是否接入.. 下一篇Delphi中使用ISuperObject解析Jso..