Update of /cvsroot/quantlibaddin/QuantLibAddin/qlo/Conversions
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv16424/qlo/Conversions
Added Files:
conversions.cpp conversions.hpp
Log Message:
support for coercion
--- NEW FILE: conversions.cpp ---
/*
Copyright (C) 2005 Plamen Neykov
Copyright (C) 2004, 2005, 2006 Eric Ehlers
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it under the
terms of the QuantLib license. You should have received a copy of the
license along with this program; if not, please email qua...@li...
The license is also available online at http://quantlib.org/html/license.html
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
#if defined(HAVE_CONFIG_H) // Dynamically created by configure
#include <qlo/config.hpp>
#endif
#include <qlo/Conversions/conversions.hpp>
namespace ObjHandler {
double libraryToScalar(const QuantLib::InterestRate &i) {
return i.rate();
}
double libraryToScalar(const QuantLib::Rate &r) {
return r;
}
long libraryToScalar(const QuantLib::Date &d) {
return d.serialNumber();
}
std::string libraryToScalar(const QuantLib::Period &period) {
std::ostringstream s;
s << period;
return s.str();
}
std::vector<std::string> libraryToVector(const std::vector<QuantLib::Period> &v) {
std::vector<std::string> ret;
for (std::vector<QuantLib::Period>::const_iterator i = v.begin();
i != v.end(); i++)
ret.push_back(libraryToScalar(*i));
return ret;
}
std::vector<long> libraryToVector(const std::vector<QuantLib::Date> &v) {
std::vector<long> ret;
for (std::vector<QuantLib::Date>::const_iterator i = v.begin();
i != v.end(); i++)
ret.push_back(i->serialNumber());
return ret;
}
std::vector<long> libraryToVector(const std::vector<QuantLib::Size> &v) {
std::vector<long> ret;
for (std::vector<QuantLib::Size>::const_iterator i = v.begin();
i != v.end(); i++)
ret.push_back(*i);
return ret;
}
}
--- NEW FILE: conversions.hpp ---
/*
Copyright (C) 2005 Plamen Neykov
Copyright (C) 2004, 2005, 2006 Eric Ehlers
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it under the
terms of the QuantLib license. You should have received a copy of the
license along with this program; if not, please email qua...@li...
The license is also available online at http://quantlib.org/html/license.html
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
#ifndef qlo_conversions_hpp
#define qlo_conversions_hpp
#include <qlo/qladdindefines.hpp>
#include <ql/date.hpp>
#include <ql/calendar.hpp>
#include <ql/interestrate.hpp>
#include <vector>
namespace ObjHandler {
double libraryToScalar(const QuantLib::InterestRate&);
double libraryToScalar(const QuantLib::Rate&);
long libraryToScalar(const QuantLib::Date&);
std::string libraryToScalar(const QuantLib::Period&);
std::vector<long> libraryToVector(const std::vector<QuantLib::Date>&);
std::vector<long> libraryToVector(const std::vector<QuantLib::Size>&);
std::vector<std::string> libraryToVector(const std::vector<QuantLib::Period>&);
}
#endif
|