marshalling

KML marshal produces zero-length files

烂漫一生 提交于 2019-12-23 02:56:16
问题 In Java code, I spawn a Thread which every second gathers DIS packets from a simulator, and tries to format KML output. In my Java code I am creating a Document, with Styles and Placemarks and Polygons. Once every second I can see that the "marshal" API routine does indeed create a KML file with my data. However, randomly sometimes it creates a complete file, and sometimes it creates a zero-length file. Even when I turn my DIS packet generator off, and leave my Java code still running, it

Insert additional fields in JAXB marshalling

北城以北 提交于 2019-12-23 02:39:00
问题 When marshaling some objects into XML, I need to insert an additional field in each of the resulting XML objects - sort of flag. The purpose is not modifying the source objects but inserting that information in the output XML. Any ideas if this is possible? 回答1: There are a few possible approaches: 1. Use an XmlAdapter You could leverage JAXB's XmlAdapter. Here you would create a version of the classes with the extra field (the adapted classes could extend the original). Then convert between

JAXB - marshal java object with XML string field

风流意气都作罢 提交于 2019-12-23 01:25:13
问题 suppose i have an object with String property that has an XML string. like: class myObject { String xml; @XmlElement(name = "xml", type = String.class) public String getXml() { return xml; } public void setXml(String xml) { this.xml = xml; } } i set an XML String to this property - such as myObject.setXml("<xml>bbb</xml>"); now i want to marshal it using JAXB and i get: <xml><xml>bbb</xml></xml> where i want to get <xml>bbb</xml> how can i do it? EDIT: the problem is that String xml, stores a

How do I register a proxy/stub for a COM interface defined by a third party?

喜欢而已 提交于 2019-12-23 01:12:40
问题 There's Another Company that ships the product that consumes IAnotherCompanyInterface. We want to ship a COM object that implements IAnotherCompanyInterface. That interface is not Automation-compatible, so the next easiest option to enable marshalling is using a proxy/stub. Another Company doesn't ship the proxy/stub and doesn't want to. Compiling and registering the proxy/stub is not a problem by itself but consider the following situation. There's our company shipping a COM object

Override JAXB annotation Mapping with MOXY oxm binding file

我与影子孤独终老i 提交于 2019-12-22 22:20:14
问题 I'm trying to implement two differents mappings for certains of my objects. The first mapping is done using JAXB annotations on my classes. It's working fine. The second mapping is really simple : it should take every Java attribute. To do this I wrote a very simple xml bindings file : <?xml version="1.0"?> <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="com.foo" xml-mapping-metadata-complete="true"> <java-types> <java-type name="com.foo

Access violation exception when use method Marshal.PtrToStructure in a loop

落爺英雄遲暮 提交于 2019-12-22 12:40:42
问题 In my program (C#), i used method Marshal.PtrToStructure to convert object add a memory address to structure in a loop. At the first element, this work normal. But at the second element, the access violation exception occurs. The access violation exception only occurs on win 7 (64 bits), it does not occur on win xp (32 bits). I don't know cause and solution for it. Please help me. Note: I use .NET Framework 3.5. Code as bellow: [StructLayout(LayoutKind.Sequential)] public struct gpc_vertex {

Interop'ing between C# and an unmanaged C library

你离开我真会死。 提交于 2019-12-22 10:59:12
问题 I have a small C library in a DLL and I need to call a handful of its methods. It uses pointers and a few structs but is otherwise quite simple. Problem is I'm not terribly knowledgable on .NET's interop with the unmanaged world and my attempts so far keep hitting memory access violation exceptions (presumably due to me not getting the pointers quite right). Could anyone give me some pointers (ooh a pun!) on the best way to approach this? Thank you extern vconfig_t *Pobsopen(Ppoly_t **

Marshal can't dump hash with default proc (TypeError)

放肆的年华 提交于 2019-12-22 09:13:44
问题 I have this ruby script that generates a hash and saves it to a file. Sometimes the file doesn't exist or is empty, so I always check the existence of it first. Then I load the old values into my hash and try to save again. I've been struggling with this for a long time now. This is a sample: newAppName = ARGV[0] newApp = Hash.new newApp["url"] = ARGV[1] newApp["ports"] = ARGV[2].to_i apps = Hash.new { |h, k| h[k] = Hash.new } # apps["test"] = {"url" => "www.test.com", "ports" => 3 } appsFile

Serializing C++ objects

纵然是瞬间 提交于 2019-12-22 09:13:31
问题 I would like to implement a Serialization Class which takes in an object and converts it into a binary stream and stored in a file. Later, the object should be reconstructed from a file. Though this functionality is provided by BinaryFormatter in C#, I would like to design my own Serialization class from scratch. Can someone point to some resources ? Thanks in advance 回答1: I have been using boost::serialization library for a while now and I think it is very good. You just need to create the

How do I convert a cli::array to a native array from native code?

喜欢而已 提交于 2019-12-22 08:57:56
问题 I'm writing a native wrapper around a managed component written in C++\CLI. I have the following function in managed code: array<Byte>^ Class::Function(); I want to expose this function from a native C++ class with the following signature: shared_array<unsigned char> Class::Function(); I've gotten as far as calling the managed function from native code, but I'm not sure how to safely copy the managed array into an unmanaged one. gcroot<cli::array<System::Byte>^> managedArray = _managedObject-