Hi,
I'm trying to load data from xml files and to use it with Quantlib. But, I am having a type casting problem. The fields I load from xml are "string" or "char *", but unfortunately when I try to cast them to "Real" or "Spread", or any other Quantlib type... It does not work... Let me give you a sample: char * data = "1.22" Real strike = (Real)"data"; -> error: invalid cast from type ‘char*’ to type ‘QuantLib::Real’ Any help greatly appreciated... Thanks, Baptiste. |
Hello,
this is not casting, this have to be conversation: double atof ( const char * string ); see: http://cplusplus.com/ref/cstdlib/ after you get float double or whatever, you can cast it to Real...etc, but char is different type than numbers... Tamas On Thu, 16 Feb 2006 06:53:07 -0600, Baptiste Debrabant <[hidden email]> wrote: > > Hi, > > > I'm trying to load data from xml files and to use it with Quantlib. > > But, I am having a type casting problem. > The fields I load from xml are "string" or "char *", but unfortunately > when I try to cast them to "Real" or "Spread", or any other Quantlib > type... It does not work... > > > Let me give you a sample: > > char * data = "1.22" > Real strike = (Real)"data"; > > -> error: invalid cast from type ‘char*’ to type ‘QuantLib::Real’ > > > Any help greatly appreciated... > > Thanks, > > Baptiste. > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 > _______________________________________________ > Quantlib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Thanks for your help guys.
It works now with char* to Real, Rate, etc. conversions. But it doesn't works yet with Date... For example, the following code returns an error: char *month = "February"; Month m = (Month)month; Date todaysDate(14, m , 2006); -> invalid cast from type ‘char*’ to type ‘QuantLib::Month’ How can I do do convert char* dates to Quantlib::Date ? Thanks. Baptiste Tamas R Sashalmi a écrit : > Hello, > > this is not casting, this have to be conversation: > double atof ( const char * string ); > > see: http://cplusplus.com/ref/cstdlib/ > > after you get float double or whatever, you can cast it to Real...etc, > but char is different type than numbers... > > Tamas > > > On Thu, 16 Feb 2006 06:53:07 -0600, Baptiste Debrabant > <[hidden email]> wrote: > >> >> Hi, >> >> >> I'm trying to load data from xml files and to use it with Quantlib. >> >> But, I am having a type casting problem. >> The fields I load from xml are "string" or "char *", but unfortunately >> when I try to cast them to "Real" or "Spread", or any other Quantlib >> type... It does not work... >> >> >> Let me give you a sample: >> >> char * data = "1.22" >> Real strike = (Real)"data"; >> >> -> error: invalid cast from type ‘char*’ to type ‘QuantLib::Real’ >> >> >> Any help greatly appreciated... >> >> Thanks, >> >> Baptiste. >> >> >> ------------------------------------------------------- >> This SF.net email is sponsored by: Splunk Inc. Do you grep through >> log files >> for problems? Stop! Download the new AJAX search engine that makes >> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 >> _______________________________________________ >> Quantlib-users mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/quantlib-users > > > |
Sorry guys... stupid question...
it's now ok... int month = 2; Month m = (Month)month; Date todaysDate(14, m , 2006); Sorry... Baptiste Baptiste Debrabant a écrit : > Thanks for your help guys. > It works now with char* to Real, Rate, etc. conversions. > > But it doesn't works yet with Date... > > For example, the following code returns an error: > > char *month = "February"; > Month m = (Month)month; > > Date todaysDate(14, m , 2006); > > > -> invalid cast from type ‘char*’ to type ‘QuantLib::Month’ > > > How can I do do convert char* dates to Quantlib::Date ? > > Thanks. > > Baptiste > > > > > Tamas R Sashalmi a écrit : > >>Hello, >> >>this is not casting, this have to be conversation: >>double atof ( const char * string ); >> >>see: http://cplusplus.com/ref/cstdlib/ >> >>after you get float double or whatever, you can cast it to Real...etc, >>but char is different type than numbers... >> >>Tamas >> >> >>On Thu, 16 Feb 2006 06:53:07 -0600, Baptiste Debrabant >><[hidden email]> wrote: >> >> >>>Hi, >>> >>> >>>I'm trying to load data from xml files and to use it with Quantlib. >>> >>>But, I am having a type casting problem. >>>The fields I load from xml are "string" or "char *", but unfortunately >>>when I try to cast them to "Real" or "Spread", or any other Quantlib >>>type... It does not work... >>> >>> >>>Let me give you a sample: >>> >>>char * data = "1.22" >>>Real strike = (Real)"data"; >>> >>>-> error: invalid cast from type ‘char*’ to type ‘QuantLib::Real’ >>> >>> >>>Any help greatly appreciated... >>> >>>Thanks, >>> >>>Baptiste. >>> >>> >>>------------------------------------------------------- >>>This SF.net email is sponsored by: Splunk Inc. Do you grep through >>>log files >>>for problems? Stop! Download the new AJAX search engine that makes >>>searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! >>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 >>>_______________________________________________ >>>Quantlib-users mailing list >>>[hidden email] >>>https://lists.sourceforge.net/lists/listinfo/quantlib-users >> >> >> > > |
In reply to this post by Baptiste Debrabant
Sorry guys... stupid question...
it's now ok... int month = 2; Month m = (Month)month; Date todaysDate(14, m , 2006); Sorry... Baptiste Baptiste Debrabant a écrit : > Thanks for your help guys. > It works now with char* to Real, Rate, etc. conversions. > > But it doesn't works yet with Date... > > For example, the following code returns an error: > > char *month = "February"; > Month m = (Month)month; > > Date todaysDate(14, m , 2006); > > > -> invalid cast from type ‘char*’ to type ‘QuantLib::Month’ > > > How can I do do convert char* dates to Quantlib::Date ? > > Thanks. > > Baptiste > > > > > Tamas R Sashalmi a écrit : > >>Hello, >> >>this is not casting, this have to be conversation: >>double atof ( const char * string ); >> >>see: http://cplusplus.com/ref/cstdlib/ >> >>after you get float double or whatever, you can cast it to Real...etc, >>but char is different type than numbers... >> >>Tamas >> >> >>On Thu, 16 Feb 2006 06:53:07 -0600, Baptiste Debrabant >><[hidden email]> wrote: >> >> >>>Hi, >>> >>> >>>I'm trying to load data from xml files and to use it with Quantlib. >>> >>>But, I am having a type casting problem. >>>The fields I load from xml are "string" or "char *", but unfortunately >>>when I try to cast them to "Real" or "Spread", or any other Quantlib >>>type... It does not work... >>> >>> >>>Let me give you a sample: >>> >>>char * data = "1.22" >>>Real strike = (Real)"data"; >>> >>>-> error: invalid cast from type ‘char*’ to type ‘QuantLib::Real’ >>> >>> >>>Any help greatly appreciated... >>> >>>Thanks, >>> >>>Baptiste. >>> >>> >>>------------------------------------------------------- >>>This SF.net email is sponsored by: Splunk Inc. Do you grep through >>>log files >>>for problems? Stop! Download the new AJAX search engine that makes >>>searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! >>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 >>>_______________________________________________ >>>Quantlib-users mailing list >>>[hidden email] >>>https://lists.sourceforge.net/lists/listinfo/quantlib-users >> >> >> > > |
Free forum by Nabble | Edit this page |