using namespace std;
-CalendarObjectSaveResult CalendarObject::SaveString(string *SaveStringData){
+CalendarObjectSaveResult CalendarObject::SaveFile(string SaveFilename){
+ ofstream FileStream;
+ string ReceivedStringData = "";
+
+ // Open the file.
+
+ FileStream.open(SaveFilename, ofstream::out);
+ if (FileStream.rdstate() & ofstream::failbit){
+ return CALENDAROBJECTSAVE_CANNOTOPEN;
+ }
+ if (FileStream.rdstate() & ofstream::badbit){
+ return CALENDAROBJECTSAVE_CANNOTOPEN;
+ }
+
+ FileStream.close();
+
+ // Process the data into a string.
+
+ CalendarObjectSaveResult SaveResult = CALENDAROBJECTSAVE_UNITTESTFAIL;
+ string SaveStringData;
+
+ SaveResult = SaveString(&SaveStringData);
+
+ return SaveResult;
+
}
-CalendarObjectSaveResult CalendarObject::SaveFile(string SaveFilename){
+CalendarObjectSaveResult CalendarObject::SaveString(string *SaveStringData){
+
+ *SaveStringData += "BEGIN:VCARD\n";
+ *SaveStringData += "VERSION:2.0\n";
+
+ // Check if METHOD has a value and print it if it does (and
+ // any token data if there).
+
+ if (MethodData.size() > 0){
+
+ if (MethodTokens.size() > 0){
+
+ *SaveStringData += "METHOD;";
+ *SaveStringData += MethodTokens;
+
+ } else {
+
+ *SaveStringData += "METHOD";
+
+ }
+
+ *SaveStringData += ":";
+ *SaveStringData += MethodData;
+ *SaveStringData += "\n";
+
+ }
+
+ // Check if CALSCALE has a value and print it if it does (and
+ // any token data if there).
+
+ if (CalendarScaleData.size() > 0){
+
+ if (CalendarScaleTokens.size() > 0){
+
+ *SaveStringData += "CALSCALE;";
+ *SaveStringData += CalendarScaleTokens;
+
+ } else {
+
+ *SaveStringData += "CALSCALE";
+
+ }
+ *SaveStringData += ":";
+ *SaveStringData += CalendarScaleData;
+ *SaveStringData += "\n";
+
+ }
+
+#if defined(XESTIACAL_UNITTEST)
+
+ *SaveStringData += "PRODID:-//Xestia//Calendar Unit Testing//KW\n";
+
+#else
+
+ *SaveStringData += "PRODID:-//Xestia//Calendar Version ";
+ *SaveStringData += XSDCAL_VERSION;
+ *SaveStringData += "\n";
+
+#endif
+
+ SaveObjectData(SaveStringData);
+ *SaveStringData += "END:VCARD";
}
\ No newline at end of file