Update of /cvsroot/quantlibaddin/QuantLibAddin/qlo
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13933/qlo
Modified Files:
calendarfactory.cpp typefactory.hpp
Log Message:
small fixes for calendar factory
Index: calendarfactory.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/calendarfactory.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** calendarfactory.cpp 4 Oct 2006 13:33:52 -0000 1.7
--- calendarfactory.cpp 4 Oct 2006 20:13:45 -0000 1.8
***************
*** 65,69 ****
Parse the joint calendar ID.
A JointCalendar ID is in a format such as
! JoinHolidays(UnitedKingdom::Exchange, UnitedStates::Settlement)
- the initial string is either "JoinHolidays" or "JoinBusinessDays"
- the parentheses contain a comma-delimited list of 2, 3 or 4 calendar IDs
--- 65,69 ----
Parse the joint calendar ID.
A JointCalendar ID is in a format such as
! JoinHolidays(UnitedStates::Settlement, UnitedKingdom::Exchange)
- the initial string is either "JoinHolidays" or "JoinBusinessDays"
- the parentheses contain a comma-delimited list of 2, 3 or 4 calendar IDs
***************
*** 77,81 ****
// parse the ID (the other ~50%).
static boost::regex jointCalendarID(
! "JOIN((?:HOLIDAYS)|(?:BUSINESSDAYS))\\((.+?),(.+?)(?:,(.+?))?(?:,(.+))?\\)");
boost::smatch m;
QL_REQUIRE(boost::regex_match(idStrip, m, jointCalendarID),
--- 77,81 ----
// parse the ID (the other ~50%).
static boost::regex jointCalendarID(
! "((?:JOINHOLIDAYS)|(?:JOINBUSINESSDAYS))\\((.+?),(.+?)(?:,(.+?))?(?:,(.+))?\\)");
boost::smatch m;
QL_REQUIRE(boost::regex_match(idStrip, m, jointCalendarID),
***************
*** 88,97 ****
// Given that the regex succeeded, we're guaranteed :-) to have
! // m[1] - "HOLIDAYS"/"BUSINESSDAYS"
// m[2] - the ID of the first calendar
// m[3] - the ID of the second calendar
! if (m[1] == "HOLIDAYS")
jointCalendarRule = QuantLib::JointCalendarRule(QuantLib::JoinHolidays);
! else // "BUSINESSDAYS"
jointCalendarRule = QuantLib::JointCalendarRule(QuantLib::JoinBusinessDays);
calendarIdSet.insert(m[2]);
--- 88,97 ----
// Given that the regex succeeded, we're guaranteed :-) to have
! // m[1] - "JOINHOLIDAYS"/"JOINBUSINESSDAYS"
// m[2] - the ID of the first calendar
// m[3] - the ID of the second calendar
! if (m[1] == "JOINHOLIDAYS")
jointCalendarRule = QuantLib::JointCalendarRule(QuantLib::JoinHolidays);
! else // "JOINBUSINESSDAYS"
jointCalendarRule = QuantLib::JointCalendarRule(QuantLib::JoinBusinessDays);
calendarIdSet.insert(m[2]);
***************
*** 111,119 ****
"' is not a valid joint calendar identifier");
! // set the key "idFull" equal to the list of sorted, delimited IDs
! // and transfer the IDs from the set to a vector
std::set<std::string>::const_iterator i = calendarIdSet.begin();
std::ostringstream s;
! s << "JOIN" << m[1] << "(" << *i;
calendarIDs.push_back(*i);
i++;
--- 111,125 ----
"' is not a valid joint calendar identifier");
! /*
! 1) transfer the IDs from the set to a vector
! 2) in the same loop, format a unique key "idFull" for the object,
! this will be the same as the ID provided by the user e.g.
! JoinHolidays(UnitedStates::Settlement, UnitedKingdom::Exchange)
! -> uppercase, no whitespace, IDs sorted alphabetically e.g.
! JOINHOLIDAYS(UNITEDKINGDOM::EXCHANGE,UNITEDSTATES::SETTLEMENT)
! */
std::set<std::string>::const_iterator i = calendarIdSet.begin();
std::ostringstream s;
! s << m[1] << "(" << *i;
calendarIDs.push_back(*i);
i++;
Index: typefactory.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/typefactory.hpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** typefactory.hpp 4 Oct 2006 16:00:52 -0000 1.45
--- typefactory.hpp 4 Oct 2006 20:13:45 -0000 1.46
***************
*** 40,56 ****
namespace QuantLibAddin {
- inline std::string uppercase(const std::string &s) {
- return QuantLib::uppercase(s);
- }
-
- inline KeyPair uppercase(const KeyPair &s) {
- return KeyPair(QuantLib::uppercase(s.first), QuantLib::uppercase(s.second));
- }
-
- inline std::ostream& operator<<(std::ostream& left, const KeyPair &right) {
- left << right.first << ":" << right.second;
- return left;
- }
-
template<typename T, typename RegistryClass>
class RegistryManager {
--- 40,43 ----
***************
*** 292,295 ****
--- 279,297 ----
};
+ // some utilities required by class RegistryManager
+
+ inline std::string uppercase(const std::string &s) {
+ return QuantLib::uppercase(s);
+ }
+
+ inline KeyPair uppercase(const KeyPair &s) {
+ return KeyPair(QuantLib::uppercase(s.first), QuantLib::uppercase(s.second));
+ }
+
+ inline std::ostream& operator<<(std::ostream& left, const KeyPair &right) {
+ left << right.first << ":" << right.second;
+ return left;
+ }
+
}
|