variant

SCons: How to use the same builders for multiple variants (release/debug) of a program

The SCons User Guide tells about the usage of Multiple Construction Environments to build build multiple versions of a single program and gives the following example: opt = Environment(CCFLAGS = '-O2') dbg = Environment(CCFLAGS = '-g') o = opt.Object('foo-opt', 'foo.c') opt.Program(o) d = dbg.Object('foo-dbg', 'foo.c') dbg.Program(d) ...

What's the recommended implementation for hashing OLE Variants?

OLE Variants, as used by older versions of Visual Basic and pervasively in COM Automation, can store lots of different types: basic types like integers and floats, more complicated types like strings and arrays, and all the way up to IDispatch implementations and pointers in the form of ByRef variants. Variants are also weakly typed: th...

Does VBScript have a DateTime.TryParse equivalent?

Given a variant, does VBScript have an equivalent of C#'s DateTime.TryParse method? ...

identifying the type

Hi, In my application, there is a inheritance hierarchy in which only the classes that are at the end of the inheritance chain are non-abstract classes. Also there is some usage of boost::variant. I want to write a function which takes a pointer and a Type and says whether the object belongs to that type. For example #define IsA(nod...

Variant datatype library for C

Is there a decent open-source C library for storing and manipulating dynamically-typed variables (a.k.a. variants)? I'm primarily interested in atomic values (int8, int16, int32, uint, strings, blobs, etc.), while JSON-style arrays and objects as well as custom objects would also be nice. A major case where such a library would be usef...

Casting between variant and bstr_t causing inconsisten crash in Windows 2008

We have a C# application, calling a simple C++ wrapper class, that then calls an existing C++ DLL. The C++ code is all VC++ 6.0. We are getting inconsistent behaviour, but the crash, when it happens, always happens within the C++ wrapper DLL, and always in the same spot (have confirmed using painful logging statements). It never happe...

Cast object as OleVariant in Delphi

Is there a way to pass a wrap and unwrap a TObject descendent in an OleVariant? I am trying to pass a TObject across automation objects. I know it's not a good idea but I don't have a good alternative. The object is to be passed between objects from the same automation dll, if that makes any difference. Something like this: function...

Calling Matlab's MLApp.MLAppClass.FEval from F#

Matlab provides a COM interface that supports remote execution of arbitrary functions (and code snippets). In particular, it has an Feval method that calls a given Matlab function. The third parameter to this method, pvarArgOut, has COM type VARIANT*, and appears in the Visual Studio F# editor as an argument of type: pvarArgOut: byref<o...

Iterator for boost::variant

Hy there, I'm trying to adapt an existing code to boost::variant. The idea is to use boost::variant for a heterogeneous vector. The problem is that the rest of the code use iterators to access the elements of the vector. Is there a way to use the boost::variant with iterators? I've tried typedef boost::variant<Foo, Bar> Variant; std...

VariantClear() throws an exception when called on A VARIANT containing a SAFEARRAY

Hi, I am trying to wrap up some data from an array of BYTES into a VARIANT but I can't seem to free the data: When I run this code... SAFEARRAY * NewSArray; SAFEARRAYBOUND aDim[1]; // a one dimensional array aDim[0].lLbound = 0; //Sets the index to start from 0 //Sets the number of elements (bytes) that will go into the SAFEARRAY aD...

Null check on a COleVariant

Is it possible to do a null check on a COleVariant or at the very least check if it's type is set to VT_NULL? I see that there is a ChangeType() method but was hoping I could somehow figure out what the current type was before I attempt to change the type as changing from VT_NULL to VT_INT throws a type mismatch. ...

Delphi, olevariants and arrays of strings

i have an ole Object created with (simple verion) obj := CreateOleObject('foo.bar'); obj.OnResult := DoOnResult; procedure TMyDM.DoOnResult(Res: olevariant); which all works, the res variable has a function String[] GetAns() which im calling like this var ans: array of string; begin ans := Res.GetAns; end; which again works.. ex...

Passing an object from C++ to C# though COM

Hi, hi have a COM visible API in C# which looks like the following: public void DoSomething(string par1, string par2, object additionalParameter) The idea is that based on the value of the string parameters I expect a different class as the third parameter and cast it appropriately in the implementation (I know this design is not opt...

How to handle Variant Missing

I'm new in C# world. I have a COM server written in C++ and in some situation it returns a variant_t::missing(). When I try to receive that value in C#: object a; a = comServer.Value // Value returns missing it throws a exception that I cannot event handle in C#. How I should do? ...

visitor template for boost::variant

Hi, I would like to use a boost.variant<T0,T1,T2> as a parameter to a template 'Visitor' class which would provide visitor operators as required by the boost.variant visitor mechanism, in this case all returning void i.e., void operator()(T0 value); void operator()(T1 value); void operator()(T2 value); The template would also have fo...

Mapping COM VARIANT Types to actual types using a map

I am writing a COM wrapper for a COM object that sends different types of values from a client and want to map these types in a Map to their actual C++ type, such as VT_BSTR to a wstring, etc. I was thinking of defining an enumuration of all COM Variant types and then using a map to have that Enum as the key and the actual type containi...

How to use variant arrays in Delphi

Hello all! I have two Delphi7 programs: a COM automation server (EXE) and the other program which is using the automation server. I need to pass an array of bytes from one program to the other. After some searching I've found that using variant arrays is the way to go (correct me please if you know any better methods). My question is...

How do I stop this Variant memory leak?

I'm using an old script engine that's no longer supported by its creators, and having some trouble with memory leaks. It uses a function written in ASM to call from scripts into Delphi functions, and returns the result as an integer then passes that integer as an untyped parameter to another procedure that translates it into the correct...

Old-school Pascal question about how to cast variant record function parameters properly

I am trying to create a function with a variant record-type parameter that allows inline-casting or assignment, as such: type rectype = ( VT_INT, VT_CHAR, VT_BOOL ); rec = record case t : rectype of VT_INT : ( i : integer ); VT_CHAR : ( c : char ); VT_BOOL : ( b : boolean ); end; procedure h...

boost::any, variants, calling functions based on arrays of them.

Given a set of functions, such as: template<class A1> Void Go(A1 a); template<class A1, class A2> Void Go(A1 a1, A2 a2); template<class A1, class A2, class A3> Void Go(A1 a1, A2 a2, A3 a3); Is it possible to take an array of some variant type and given its contents, fire the correct function? My application for this is that I want ...