type-conversion

Providing *implicit* conversion operator for template specialization

I have a templated sparse_vector<T> class, and I am also using Boost UBLAS. How would I provide implicit conversions between sparse_vector<double> and boost::numeric::ublas::compressed_vector<double>? I would also like to provide similar conversions between std::vector<double> and boost::numeric::ublas::vector<double>. (I am using gcc...

C++ putting a 2d array of floats into a char*

Hello, I'm trying to take a 2d vector of floats (input) and put them into a char* (output) in c++. void foo(const std::vector<std::vector<float> > &input, char* &output ) { char charBuf[sizeof(output)]; int counter = 0; for(unsigned int i=0; i<input.size(); i++) { for(unsigned int p=0; p<input.at(i).size(); p++) ...

A point class editable in both PropertyGrid and CollectionEditor

I have the following point class definition along with its type converter, and ... [TypeConverterAttribute(typeof(MyPointConverter))] public class MyPoint { public MyPoint(double x, double y) { X = x; Y = y; } public MyPoint() { } public double X { get; set; } public double Y { get; set;...

Implicit type conversion in DB/2 inserts?

We're using SQL Inserts to insert some data via a script into DB/2 tables, e.g. CREATE TABLE TICKETS (TICKETID VARCHAR(10) NOT NULL); On my home installation, this statement works fine (note that I'm using an integer which is autoatically cast into a VarChar): INSERT INTO TICKETS (TICKETID) VALUES (1); while at my customer's site I...

Struts2 converting empty string parameter to an "int"

How does one convert an empty string to an int using Struts2. When the application encounters this parameter with no value, like from an empty text field, it throws the following exception. java.lang.NoSuchMethodException: com.XXXXXXXXXXXX.setID([Ljava.lang.String;) Where ID is an integer, and the URL is: Something.action?ID=&oth...

How to convert MS doc to pdf

How to convert doc to pdf using java api. where document contains various formats such as tables in ms word. when converting to pdf using iText. where actual document looks different to converted pdf. please provide any api not an exe installed for converting . must be an open source ...

Struts2 Converting Enum Array fills array with single null value

For a simple action class with these member variables: ... private TestConverterEnum test; private TestConverterEnum[] tests; private List<TestConverterEnum> tList; ... And a simple enum: public enum TestConverterEnum { A, B, C; } Using the default struts2 enum conversion, when I send the request like so: TestConterter...

Converting Generic Type into reference type after checking its type using GetType(). How ?

i am trying to call a function that is defined in a class RFIDeas_Wrapper(dll being used). But when i checked for type of reader and after that i used it to call function it shows me error Cannot convert type T to RFIDeas_Wrapper. EDIT private List<string> GetTagCollection<T>(T Reader) { TagCollection = new ...

Convert List of one type to Array of another type using Dozer

I'm wondering how to convert a List of one type to an array of another type in Java using Dozer. The two types have all the same property names/types. For example, consider these two classes. public class A{ private String test = null; public String getTest(){ return this.test } public void setTest(String test){...

С++ TYPE CASTING

Hello there, i have very low C++ experiences and i need little help in casting a type. I actually in a big dependence for that cast, need it rly hard. So ... I have this types : typedef short DCTELEM; typedef DCTELEM DCTBLOCK[64]; Array of last type and a pointer to a malloc'ed array of shorts: DCTBLOCK MQUAD; short * ptrArray; ...

Force Loading of all Related Entities within Entity without knowing Entity Class Types

I'm trying to serialize an entity and all its related entities for storing as xml before physically deleting the entity (leaving an audit trail). I'm using a DataContractSerializer which seems to be getting around the shallow serialization performed when using an XmlSerializer. The only trouble is that only related entities that have b...

How to convert byte array to image file?

Hi, I have browsed and uploaded a png/jpg file in my MVC web app. I have stored this file as byte[] in my database. Now I want to read and convert the byte[] to original file. How can i achieve this? thanks, kapil ...

ImageSource dependency property on a user control - XAML value set throws

I've created a small user control consisting of a button whose content is an Image. I created an "ImageSource" dependency property on the user control in order to bind to it from the Image inside the button. However in the XAML where I placed an instance of my user control setting the property throws an error at runtime : <ctrl:ImageBu...

How do I do a cast to an object type in C#?

I have a: public class MyClass { private string PrivateString; } and I have an interface that accepts: object o I have a list of MyClass that I need to push through object o, and my Google is failing me. What's the procedure to make this work? I know this must be crazy simple, but I've yet to do type casting in C#. ...

Can I include a Generic type parameter in a lamba expression? (VB.NET 2010)

(Not really sure if I phrased the question correctly...) I want to create a lambda expression that would take an Object, attempt to convert it to a passed-in Type, and print to the console whether it was successful or not. At a glance, the lambda expression may seem a pretty silly way to accomplish this task, but I'd really like to kno...

C++ Integer overflow problem when casting from double to unsigned int

I need to convert time from one format to another in C++ and it must be cross-platform compatible. I have created a structure as my time container. The structure fields must also be unsigned int as specified by legacy code. struct time{ unsigned int timeInteger; unsigned int timeFraction; } time1, time2; Mathematically the conv...

Do rvalue references allow implicit conversions?

Is the following code legal? std::string&& x = "hello world"; g++ 4.5.0 compiles this code without any problems. ...

Is there a good way to force type incompatibility in C?

For purposes of type checking I would like to define a function on the lines of void myfunc(type1 a, type2 b) { ... } where type1 and type2 are both typedefed to uint8_t. So far so good, but for sanity and checking purposes (think DbC) I would like to prevent the function being called with a type2 value for the first parameter or a t...

Spring 3 Type Conversion Errors

I have been trying out the new Spring MVC 3.0 Type Conversion Framework. I cannot find out how to trap conversion errors. I am using the new mvc schema: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi=...

What is the difference between casting and conversion?

Eric Lippert's comments in this question have left me thoroughly confused. What is the difference between casting and conversion in C#? ...