1 #include "CalendarObject.h"
2 #include "../../common/file.h"
6 CalendarObjectSaveResult CalendarObject::SaveFile(string SaveFilename){
9 string ReceivedStringData = "";
13 FileStream.open(SaveFilename, ofstream::out);
15 if (FileStream.rdstate() & ofstream::failbit){
16 return CALENDAROBJECTSAVE_CANNOTOPEN;
19 if (FileStream.rdstate() & ofstream::badbit){
20 return CALENDAROBJECTSAVE_CANNOTOPEN;
25 // Process the data into a string.
27 CalendarObjectSaveResult SaveResult = CALENDAROBJECTSAVE_UNITTESTFAIL;
28 string SaveStringData;
30 SaveResult = SaveString(&SaveStringData);
36 CalendarObjectSaveResult CalendarObject::SaveString(string *SaveStringData){
38 *SaveStringData += "BEGIN:VCALENDAR\n";
39 *SaveStringData += "VERSION:2.0\n";
41 // Check if METHOD has a value and print it if it does (and
42 // any token data if there).
44 if (MethodData.size() > 0){
46 if (MethodTokens.size() > 0){
48 *SaveStringData += "METHOD;";
49 *SaveStringData += MethodTokens;
53 *SaveStringData += "METHOD";
57 *SaveStringData += ":";
58 *SaveStringData += MethodData;
59 *SaveStringData += "\n";
63 // Check if CALSCALE has a value and print it if it does (and
64 // any token data if there).
66 if (CalendarScaleData.size() > 0){
68 if (CalendarScaleTokens.size() > 0){
70 *SaveStringData += "CALSCALE;";
71 *SaveStringData += CalendarScaleTokens;
75 *SaveStringData += "CALSCALE";
79 *SaveStringData += ":";
80 *SaveStringData += CalendarScaleData;
81 *SaveStringData += "\n";
85 #if defined(XESTIACAL_UNITTEST)
87 *SaveStringData += "PRODID:-//Xestia//Calendar Unit Testing//KW\n";
91 *SaveStringData += "PRODID:-//Xestia//Calendar Version ";
92 *SaveStringData += XSDCAL_VERSION;
93 *SaveStringData += "\n";
97 SaveObjectData(SaveStringData);
99 *SaveStringData += "END:VCALENDAR";