X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffileio.cpp;h=931c5131653b64b89069ec995d67e6305fc25345;hb=11cff81f10ccca1b31288fce04d696e715b922b0;hp=b64e5bd200fa05ac1223dd337133abe522c19896;hpb=642cf72c11b49a9e00128ab6258a2438c785a5ab;p=architektonas diff --git a/src/fileio.cpp b/src/fileio.cpp index b64e5bd..931c513 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -15,6 +15,7 @@ #include "fileio.h" //#include +#include #include #include #include @@ -101,6 +102,14 @@ perpendicular, or an arbitrary angle. How to encode that information? It's not 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, @@ -159,7 +168,7 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFLine, OTFCircle, OTFArc, 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) @@ -177,7 +186,7 @@ printf("Load: container size = %li\n", drawing->objects.size()); 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()); } } @@ -191,9 +200,38 @@ printf("Load: Adding object. Container size = %li (%li)\n", drawing->objects.siz /*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) { @@ -248,6 +286,9 @@ printf("Load: Adding object. Container size = %li (%li)\n", drawing->objects.siz *objectType = OTFEndOfFile; } + if (*object) + (*object)->layer = foundLayer; + return recognized; }