I am writing a Preview Handler for a file with custom extension.
The Preview Handler implements IInitializeWithStream interface which initializes IStream with file data which has been selected in windows explorer.
Now, I need to perform some parsing operations on this data stream (the data in the file is plain text in a predefined custom format).
In order to do that, I need the data in std::ifstream object so that i can easily use STL on it to achieve the desired output.
Long Story Short: I need a way to convert/fill the data from IStream to std::ifstream.
Thanks in advance.
I used the Read method of IStream interface to fill the data into char buffer and stream it into std::ostringstream using "<<" operator
Related
I want to store a list of strings in a column of a parquet table. I am able to do that using low level arrow APIs using the arrow::ListBuilder object and parquet::arrow::WriteTable call. I would like to do the same thing using the StreamWriter object too.
Apparently, StreamWriter object API does provide necessary methods for writing primitive types and strings but nothing for lists.
Is there a way to do that?
I want to write an IMFTransform that will blend 2 audio streams. But ideally I'd like to apply it in a stream-specific fashion. For example, I'd like to blend only a certain duration of the streams. To reiterate, the exact timing and duration would be different in each instance.
The problem is that I don't see any kind of function in the IMFTransform interface that allows me to pass this information. Am I missing something? Should I extend the IMFTransform interface with some custom methods or functions? What is the acceptable way forward?
You don't need to extend IMFTransform interface, this is not how things are supposed to be done. You typically implement another private interface on the same transform class and make it available using regular COM IUnknown::QueryInterface (or in some sense similar IMFGetService). The application would create an instance of transofrm, query this additional interface and pass necessary configuration.
I use a similar approach with this projet :MFSkVideoRenderer
VideoShaderEffect.idl : declare COM object (interface/method/library)
SinkVideoRenderer.h : add public IMFVideoShaderEffect, and declare method (STDMETHOD(FunctionName)();)
SinkVideoRenderer.cpp : implement method HRESULT CSinkVideoRenderer::FunctionName(){ return S_OK: } (could also be inlined in SinkVideoRenderer.h, if simple code)
include : #include "VideoShaderEffect_h.h" (will be generated from .idl)
to use inside an another program : #include "VideoShaderEffect_i.c" (will also be generated from .idl) see MFNodePlayer for an example
You will have to learn a little about MIDL
I want to serialize the following DTO using Protocol Buffer . Can somebody let me know what would be the .proto file entry for java Object type.
public class Person {
private Object role;
}
A bytes, that is a ByteString in Java, and a ByteString can be easily converted to a byte[] or an InputStream which you can e.g. warp in an ObjectInputStream and therefore read your serialized Object from it.
It's not very hard, but also not very protobuf-ish and/or a wise thing to do. I suggest saving some logical representation of your role object into the protobuf instead. I'm sure there is a solid option for you somewhere - be it a String, or an enum or something, you should save some the logical state of your role instead of the actual serialized object, and then try to construct the object upon retrieval.
We use protocol buffers for storing data in a database (as blobs). At some point, we read them again, need to modify them and store them again.
The problem is, protocol buffer message objects are immutable. What we had in mind was just creating a new builder object using the protocol buffer message as prototype:
Foo.Builder.newBuilder(prototype)
This basically works. But as we have a nested structure, so the prototype object actually contains attributes which are messages themselves, this does not work. Excerpt from the documentation:
Since embedded message and string objects are immutable, they are shared between the original and the copy.
Is there a way of cloning a whole structure to new builder objects which are mutable?
Well, sort of. I've done this using DynamicMessage.Builder, Descriptor and FieldDescriptor. I recursively walk the object graph using a fully qualified name to the property I want to update. Once found, I update it and call build on the DyynamicMessage.Builder(s) back up the stack. It is not straight forward particularly when dealing with repeated fields.
I am trying with NSArray.arrayWithContentsOfFile_("bla.sdef") but that returns None.
I also tried NSDictionary.dictionaryWithContentsOfFile_("bla.sdef") but that also returns None.
I am trying to get a NSDictionary object in the end in a form where parts of it are conforming to the dict for NSScriptCommandDescription initWithSuiteName:commandName:dictionary:.
(Note: I don't want to know here how to load scripting definitions into NSScriptSuiteRegistry. I really just want to know here how to read the sdef-file.)
Those methods are for reading property-list files. An sdef file is not a property list; it follows a different, purpose-specific XML schema, defined in sdef(5).
I don't think there is a public API for reading sdef files directly into a dictionary or more scripting-specific object; you'll need to do it yourself using an XML parser (either one of Cocoa's or one of Python's).