Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

struct to ubyte[] or ubyte[] to struct for d language

Tags:

d

dmd

How the implementation of the struct in the D language to ubyte [] or ubyte [] to the struct, please brothers help answer this question, thank you!

If a struct contains the string or char [] what to do?

For example, such a structure:

struct UserLogin 
{ 
    align(1): 
      ushort ClientId; 
      int AccectId; 
      string LoginUid; 
      string LoginPwd; 
} 

Attention to my application in the socket!

like image 823
Dev Wolf Avatar asked Dec 17 '22 03:12

Dev Wolf


1 Answers

I don't think there's anything in the standard library to automatically serialize and deserialize structures to byte streams. std.stream does that for a variety of basic types, but not entire structs. Apache Thrift support is on the way. Among 3rd-party solutions, you can have a look at the Orange serialization library.

like image 188
Vladimir Panteleev Avatar answered Jan 07 '23 16:01

Vladimir Panteleev