marshalling

Marshalling nested structs to C#

时间秒杀一切 提交于 2020-01-15 03:46:07
问题 We have COM Server (as dll, we have only dll file), that implements two COM interfaces. One of interfaces allows us to get messages (as structure) from some device. Depending on message we need to process corresponding structure. Every structure is pointer to a structure VARIANT . This structure is of type byte array (VT_ARRAY | VT_UI1) . All structures contains structure Header and some other information. Structure Header contains field MsgId . Depending on MsgId we need to process other

C++ struct two dimension array into C# [duplicate]

痴心易碎 提交于 2020-01-15 03:44:29
问题 This question already has an answer here : Closed 8 years ago . Possible Duplicate: What does “Invalid managed/unmanaged type combination.” mean? how we will code these structures(Written in C++) in C# typedef struct tagBIRDMATRIX { short n[3][3]; // array of matrix elements }BIRDMATRIX; 回答1: The size should be the number of elements in your cross product. struct BIRDMATRIX { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] short[,] n; } 来源: https://stackoverflow.com/questions/6197504/c

Grails: Defining a JSON custom marshaller as static method in domain

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-14 19:21:27
问题 I'm using Grails 2.4.2. As can be seen here: https://grails.org/Converters+Reference You can create a static method in your domain with your custom marshaller to render the JSON in the controller. Like that: Domain: // a class to output in JSON package com.sample class User { String login String passwd // JSON definition of the User object static { grails.converters.JSON.registerObjectMarshaller(User) { return [ login: it.login ] } } Then in your controller: def user = new User(login:'bob',

marshaling variable arguments - __arglist or alternative

点点圈 提交于 2020-01-14 03:30:30
问题 Best way to describe the problem I'm trying to solve is to talk in code. I see a lot of __arglist questions on this forum, but not a lot of helpful answers. I know _arglist should be avoided so I'm open to alternative methods In one C++ module I have something like the following void SomeFunction(LPCWSTR pszFormat, va_args args) { // this function is not exported... // it is designed to take a format specifier and a list of variable // arguments and "printf" it into a buffer. This code //

Getting x_test, y_test from generator in Keras?

假如想象 提交于 2020-01-14 01:36:09
问题 For certain problems, the validation data can't be a generator, e.g.: TensorBoard histograms: If printing histograms, validation_data must be provided, and cannot be a generator. My current code looks like: image_data_generator = ImageDataGenerator() training_seq = image_data_generator.flow_from_directory(training_dir) validation_seq = image_data_generator.flow_from_directory(validation_dir) testing_seq = image_data_generator.flow_from_directory(testing_dir) model = Sequential(..) # .. model

how to call a C function from C# with a WCHAR* out parameter?

我的未来我决定 提交于 2020-01-13 02:23:08
问题 I'm having a bit of problem with marshaling and I just can't figure it out by myself. I've searched for this topic, but hadn't have any luck yet, so basically I'm trying to call an unmanaged C function from my managed C# application. The signature of the C function looks like this: long MyFunction(WCHAR* upn, long upnSize, WCHAR* guid, long* guidSize); I don't access to the .dll file, I just know that the function is being exposed for usage and I know what the function is supposed to do, but

What is the preferred method of marshalling COM interfaces across threads?

不羁的心 提交于 2020-01-13 01:39:11
问题 What are the pros/cons of using the GIT as opposed to CoMarshalInterThreadInterfaceInStream and CoGetInterfaceAndReleaseStream for marshalling COM interfaces across threads? Are there strong reasons for preferring one method over the other, or is it more a matter of personal preference? 回答1: From MSDN: If you are unmarshaling an interface pointer multiple times between apartments in a process, you might use the IGlobalInterfaceTable interface. With other techniques, you would have to

Flattening marshalled JSON structs with anonymous members in Go

老子叫甜甜 提交于 2020-01-12 07:30:08
问题 Given the following code: (reproduced here at play.golang.org.) package main import ( "encoding/json" "fmt" ) type User struct { Id int `json:"id"` Name string `json:"name"` } type Session struct { Id int `json:"id"` UserId int `json:"userId"` } type Anything interface{} type Hateoas struct { Anything Links map[string]string `json:"_links"` } func MarshalHateoas(subject interface{}) ([]byte, error) { h := &Hateoas{subject, make(map[string]string)} switch s := subject.(type) { case *User: h

json.Unmarshal json string to object is empty result [duplicate]

半世苍凉 提交于 2020-01-11 14:40:10
问题 This question already has answers here : Printing Empty Json as a result [duplicate] (1 answer) json.Marshal(struct) returns “{}” (2 answers) Closed 4 months ago . I've got a very simple program like this: package main import ( "encoding/json" "fmt" ) type RunCommand struct{ level string `json:"level"` caller string `json:"caller"` msg string `json:"msg"` cmd string `json:"cmd"` } func main() { content := `{"level":"info","caller":"my.go:10","msg":"run","cmd":"--parse"}` runCommand :=

Can JAXB Incrementally Marshall An Object?

限于喜欢 提交于 2020-01-11 13:24:08
问题 I've got a fairly simple, but potentially large structure to serialize. Basically the structure of the XML will be: <simple_wrapper> <main_object_type> <sub_objects> </main_object_type> ... main_object_type repeats up to 5,000 times </simple_wrapper> The main_object_type can have a significant amount of data. On my first 3,500 record extract, I had to give the JVM way more memory than it should need. So, I'd like to write out to disk after each (or a bunch of) main_object_type . I know that