variant

dbus Variant: How to preserve boolean datatype in Python?

偶尔善良 提交于 2020-01-04 09:27:38
问题 I've been experimenting with dbus lately. But I can't seem to get my dbus Service to guess the correct datatypes for boolean values. Consider the following example: import gtk import dbus import dbus.service from dbus.mainloop.glib import DBusGMainLoop class Service(dbus.service.Object): def __init__(self): bus_name = dbus.service.BusName("org.foo.bar", bus = dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, "/org/foo/bar") @dbus.service.method("org.foo.bar", in_signature = "a

VBA Array of variant type as class property

不想你离开。 提交于 2020-01-04 01:25:09
问题 I have a class that handles several numeric arrays (type double) and also needs to handle an array of descriptors, which will include a mix of strings and integers, which need to be utilized as strings and numbers accordingly. So I decide to make an array property of type variant (not a variant containing an array). But this one does not seem to work, while the type double arrays do. Specifically, this type double array-property works fine, to receive or return an array all at once: Private p

Why does this get_index implementation fail on VS2017?

梦想的初衷 提交于 2020-01-03 11:49:11
问题 Barry gave us this gorgeous get_index for variants: template <typename> struct tag { }; template <typename T, typename V> struct get_index; template <typename T, typename... Ts> struct get_index<T, std::variant<Ts...>> : std::integral_constant<size_t, std::variant<tag<Ts>...>(tag<T>()).index()> { }; To be used as follows: using V = variant<A, B, C>; constexpr const size_t N = get_index<B, V>::value; // 1 It works great in Clang (OSX). But in Visual Studio 2017 I'm getting the following:

How to stream std::variant<…,…>

不想你离开。 提交于 2020-01-01 09:04:10
问题 My std::variant contains streamable types: std::variant<int, std::string> a, b; a = 1; b = "hi"; std::cout << a << b << std::endl; Compiling with g++7 with -std=c++1z returns compilation time errors. An excerpt: test.cpp: In function 'int main(int, char**)': test.cpp:10:13: error: no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'std::variant<int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >') std::cout << a <<

Android Gradle Plugin (Warning) API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'

房东的猫 提交于 2019-12-30 18:05:09
问题 I am trying to build and run this repository augmented-images and I encounted this error. Caused by: java.lang.RuntimeException: Error creating sfa. Which drill down to this warning Warning ! API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()' . More from the build log analysis I see the following errors ERROR: Failed to import 'sampledata/airplane/Airplane.obj' I tried to find where this variant.getMergeResources() is used so I can

Adding or multiplying variants in VBA

我们两清 提交于 2019-12-29 01:30:08
问题 Suppose we are given two variants, X and Y , that may be numbers, ranges or arrays. Is there a simple way to add or multiply them like in worksheet formulas =X+Y and =X*Y ? One possibility i thought of would be to use the Evaluate operation, something like this: Dim X, Y Sub AddMult() Dim Add, Mult X = Array(Array(1, 3), Array(2, 4)) Y = Array(1, 2) Add = [GetX()+GetY()] Mult = [GetX()*GetY()] End Sub Function GetX() GetX = X End Function Function GetY() GetY = Y End Function It seems a

Convert std::variant to another std::variant with super-set of types

吃可爱长大的小学妹 提交于 2019-12-28 06:45:12
问题 I have a std::variant that I'd like to convert to another std::variant that has a super-set of its types. Is there a way of doing it than that allows me to simply assign one to the other? template <typename ToVariant, typename FromVariant> ToVariant ConvertVariant(const FromVariant& from) { ToVariant to = std::visit([](auto&& arg) -> ToVariant {return arg ; }, from); return to; } int main() { std::variant<int , double> a; a = 5; std::variant <std::string, double, int> b; b = ConvertVariant

How do I (or if I can't) use Variants on simple DLLs?

廉价感情. 提交于 2019-12-25 16:24:10
问题 I want to expose some functionality of a internal object as a DLL - but that functionality uses variants. But I need to know: I can export a function with Variant parameters and/or return - or is better to go to an string-only representation? What is better, from language-agnostic POV (the consumer is not made with Delphi - but all will run in Windows)? 回答1: You could use OleVariant, which is the variant value type that is used by COM. Make sure not to return it as a function result as

How to make a type safe wrapper around Variant values

柔情痞子 提交于 2019-12-24 18:46:49
问题 I'm working with a OPC Server control that stores data tags as variant types, described by System.Runtime.InteropServices.VarEnum . These types include the following, VT_BSTR (string), VT_I2 (short) and VT_I4 (long). All these values are stored by the server as objects and then I have to cast to the correct value when I fetch them. I know that I can do something like the following: object tagValue = (object)"testing"; //this would be returned from a function rather than created this way!! var

JAXB: How to implement a JAXB-compatible variant wrapper class?

こ雲淡風輕ζ 提交于 2019-12-24 09:49:40
问题 How could I implement a "variant" class which would act as an adapter between Object and JAXB-natively-supported types? I could then use Object in JAXB-annotated classes. Therefor, I guess, I would need to store a type ID inside that adapter. Any ideas? NOTE: With "JAXB-natively-supported types" I mean types such as: all primitive types, String , Date , byte[] , List<any-JAXB-supported-type> . Usage Scenario @XmlType class SomeClass { @XmlJavaTypeAdapter(VariantAdapter.class) // WITH OR