// Loads an encapsulated block into a temporary list INXObjList* BlockOperations::LoadBlock(INXString Info) { ifstream datafile(Info); INXObjList* encapsulated = new INXObjList; char type[256]; long int id; // store the id value id = ConData::uniqueidgenerator; if(datafile.is_open()) { int i = 0; while ((!datafile.eof()) && (!datafile.bad())) { i++; datafile >> type; // TRACE(type); if (strcmp(type,"END_OF_BLOCKS")==0) break; else if (strcmp(type,"BEGIN_BLOCK")==0) { ConData *blob = new ConData; blob->Load(&datafile); encapsulated->AddTail((CObject*) blob); } if(i>500) { // TRACE("hang\n"); } } }
INXObjList* EditList::LoadTemp() { ConData* blob; long int id = 0; INXObjList* temp = new INXObjList; // Copy the condata list to the flattened list // save the condata list and then load it back in to flattened // Alternatively could use a copy constructor temp->RemoveAll(); //SaveProg(workDir + TEMPDIR + "temp"); ifstream datafile(workDir + TEMPDIR + "temp"); char type[256]; while ((!datafile.eof()) && (!datafile.fail())) { datafile >> type; if (strcmp(type,"END_OF_BLOCKS")==0) break; else if (strcmp(type,"BEGIN_BLOCK")==0) { blob = new ConData; if(blob) { blob->Load(&datafile); temp->AddTail((CObject*) blob); id = blob->identnum; } else { //delete blob; break; } } } // set the uniqueidgenerator to the identnum of the last icon // This is necessary as it is possible that this value may be greater than // the number of icons loaded, due to icons being deleted previously. This // prevents icon IDs being duplicated // Need to add 1, since uniqueidgenerator is incremented after a new icon is // instantiated. //id++; //ConData::uniqueidgenerator = id; return temp; }
// Loads the saved copySelList into the pasteList INXObjList* EditList::LoadPaste(INXString Info) { ifstream datafile(Info); char type[256] = {'\0'}; long int id; INXObjList* pasteList = NULL; datafile >> type; // if a file is empty don't load it if ((INXString)type == "") { return NULL; } datafile.close(); datafile.open(Info); // store the id value id = ConData::uniqueidgenerator; while ((!datafile.eof()) && (!datafile.bad())) { datafile >> type; if (strcmp(type,"END_OF_BLOCKS")==0) break; else if (strcmp(type,"BEGIN_BLOCK")==0) { ConData *blob = new ConData; blob->Load(&datafile); if (!pasteList) { pasteList = new INXObjList; } pasteList->AddTail((CObject*) blob); } } // restore the id value, since it will have been increased when creating flattened ConData::uniqueidgenerator = id; return pasteList; }