casting

SSIS passing custom objects

廉价感情. 提交于 2019-12-23 20:25:24
问题 I've created a custom class in one of my flow tasks and assign values to it's properties. I store the collection of these custom classes in the Object variable Later on in a different script task i want to read the values from this collection of custom objects. The custom class is unknown in the other ssis components. I can't create a dll and store it on the SQL server so how to a transport the collection of custom objects. I can get them to the script tasks and they have all the properties

Bitfield and union for low level data structures and type conversion in Rust

大城市里の小女人 提交于 2019-12-23 20:13:49
问题 I need to manage bitfield data and unions. Here is the code like I think it in C: typedef struct __attribute__((__packed__)){ union { struct __attribute__((__packed__)){ unsigned short protocol : 4; unsigned short target : 12; unsigned short target_mode : 4; unsigned short source : 12; unsigned char cmd; unsigned char size; }; unsigned char unmap[6]; // Unmapped form. }; }header_t; I use this union to switch easily from a mapped to an unmapped form. I can write to header_t.protocol or header

Casting from void* to an object array in c++

别说谁变了你拦得住时间么 提交于 2019-12-23 20:11:55
问题 I'm having problems getting this to work, class A { public: A(int n) { a = n; } int getA() { return a; } private: int a; }; int main(){ A* a[3]; A* b[3]; for (int i = 0; i < 3; ++i) { a[i] = new A(i + 1); } void * pointer = a; b = (A* [])pointer; // DOESNT WORK Apparently ISO C++ forbids casting to an array type ‘A* []’. b = static_cast<A*[]>(pointer); // DOESN'T WORK invalid static_cast from type ‘void*’ to type ‘A* []’ return 0; } And i can't use generic types for what i need. Thanks in

SQL [Conversion to bool]

*爱你&永不变心* 提交于 2019-12-23 20:10:03
问题 C++Builder ADOQuery SQLServer I'm using a stored procedure with this select SELECT Name, COALESCE( ( SELECT TOP 1 0 FROM TbUserParam WHERE TbUserParam.ID_User = @ID_User AND TbUserParam.ID_Param = CfgListParIzm.ID_ListParIzm ), 1) Visi FROM CfgListParIzm WHERE CfgListParIzm.ID_ListGroupParIzm = @ID_ListGroupParIzm Stuff about this query in my query with SQL string : FlowClientHardQ :ID_User, :ID_ListGroupParIzm then DataSource and DBGrid with CheckBox fields. Source So I need a bool (or bit)

How do we cast context to fragment reference?

爱⌒轻易说出口 提交于 2019-12-23 19:27:31
问题 I have a class 'Common' and a fragment 'FragmentTest'. The 'Common.java' is a general class that have some common functions for other activities..Those functions are accessed by context of each activities.. And here I am passing the fragment's context to a function in that class. I am doing like this In Fragment :- Common commonObj = new Common(); commonObj.myfunction(this.getActivity(),"Do you want to Update ?"); And in Class after some operation i'm trying to return back to fragment class

Why I cannot cast derived generic type to base non-generic type (through a constrain)?

纵饮孤独 提交于 2019-12-23 19:19:20
问题 Given this fictional example: class NonGeneric { } class Generic<T> : NonGeneric where T : NonGeneric { T DoSomething() { return this; // ** } } I'd expect it compiles: Generic<T> derives from NonGeneric and T must be a derived class so it satisfies its constrain. I should be able to do this: NonGeneric obj = new Generic<NonGeneric>(); Then there should be no problem in this instruction: return this; Or at least this: return (T)this; Unfortunately it doesn't work and above example doesn't

Java Class.cast() and Overload

六眼飞鱼酱① 提交于 2019-12-23 18:28:03
问题 I'm trying to code a packet listener for a little server. I'm very new to Java and this is the first time i mess around with networking. The whole idea it's recive the packet, match the packet id with it's class, pass the input stream to the constructor of the packet so it can be constructed and then give it to the packetHander, wich will have an overladed method for each packet. To achive this im using an array that maps the packets ids to the classes of each one, and using a method called

Typecasting `this` of a base class template to its derived class

浪尽此生 提交于 2019-12-23 18:01:37
问题 A simplified version of my code looks like so: template <class T> struct Base { void SayHello( T* aDerived ) { } void SaySomething() { SayHello( this ); // This is where the error happens } }; struct Derived : public Base< Derived > { }; int main(int argc, const char * argv[]) { Derived iDerived; iDerived.SaySomething(); } And it won't compile on the SayHello( this ) line with this error message: Cannot initialize a parameter of type 'Derived *' with an rvalue of type 'Base<Derived> *' Now it

string values to byte array without converting

核能气质少年 提交于 2019-12-23 17:29:07
问题 I'm trying to put the values of a string into a byte array with out changing the characters. This is because the string is in fact a byte representation of the data. The goal is to move the input string into a byte array and then convert the byte array using: string result = System.Text.Encoding.UTF8.GetString(data); I hope someone can help me although I know it´s not a very good description. EDIT: And maybe I should explain that what I´m working on is a simple windows form with a textbox

Is there any alternative to strtoull() function in C?

独自空忆成欢 提交于 2019-12-23 17:13:52
问题 I need to convert char* to unsigned long long int and there is a function called strtoull() in the C standard library but it takes to much time. I need to quick conversion between char* to unsigned long long int . How can I write my own conversion function which is faster than the standard one? 回答1: Shortest/fastest code I can think of right now: unsigned long long strtoull_simple(const char *s) { unsigned long long sum = 0; while (*s) { sum = sum*10 + (*s++ - '0'); } return sum; } No error