#include "fileio.h"
//#include <stdio.h>
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
intrinsic to either the Line or the Circle, but is a function of the
relationship between them by virtue of their connection.
+
+OTHER CONSIDERATIONS:
+---------------------
+
+ - Need to figure out how to store the Layer list (should layer list be optional?)
+ - Need to figure out how to store the Block list and blocks
+
+
*/
enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFLine, OTFCircle, OTFArc, OTFDimension,
if (objectType == OTFEndOfFile)
{
-printf("Load: container size = %li\n", drawing->objects.size());
+//printf("Load: container size = %li\n", drawing->objects.size());
return true;
}
else if (objectType == OTFContainer)
else
{
currentTopContainer->Add(object);
-printf("Load: Adding object. Container size = %li (%li)\n", drawing->objects.size(), currentTopContainer->objects.size());
+//printf("Load: Adding object. Container size = %li (%li)\n", drawing->objects.size(), currentTopContainer->objects.size());
}
}
/*static*/ bool FileIO::GetObjectFromFile(FILE * file, Object * parent, Object ** object, int * objectType)
{
char buffer[256];
- fscanf(file, "%s ", buffer);
+ int foundLayer = 0;
+ int num = fscanf(file, "%s", buffer);
bool recognized = false;
-//printf("Load: buffer = \"%s\"\n", buffer);
+ *object = NULL;
+//printf("FileIO: fscanf returned %i, buffer = \"%s\"\n", num, buffer);
+
+// The following fugliness is for troubleshooting. Can remove later.
+ if ((strcmp(buffer, "END") != 0) && (strcmp(buffer, "ENDCONTAINER") != 0))
+{
+errno = 0;
+ num = fscanf(file, " %i ", &foundLayer);
+//printf("FileIO: fscanf returned %i, foundLayer = %i\n", num, foundLayer);
+if (errno)
+{
+ if (errno == EAGAIN)
+ printf("EAGAIN\n");
+ else if (errno == EBADF)
+ printf("EBADF\n");
+ else if (errno == EILSEQ)
+ printf("EILSEQ\n");
+ else if (errno == EINTR)
+ printf("EINTR\n");
+ else if (errno == EINVAL)
+ printf("EINVAL\n");
+ else if (errno == ENOMEM)
+ printf("ENOMEM\n");
+ else if (errno == ERANGE)
+ printf("ERANGE\n");
+ else
+ printf("errno = %i\n", errno);
+}
+}
if (strcmp(buffer, "LINE") == 0)
{
*objectType = OTFEndOfFile;
}
+ if (*object)
+ (*object)->layer = foundLayer;
+
return recognized;
}