src/file.h

changeset 251
c4b96bc41298
parent 250
6e80f038e8df
child 253
0737c217a54d
equal deleted inserted replaced
250:6e80f038e8df 251:c4b96bc41298
49 MUTABLE_READ_PROPERTY (vector<LDObject*>, objs) 49 MUTABLE_READ_PROPERTY (vector<LDObject*>, objs)
50 PROPERTY (vector<LDObject*>, cache, setCache) 50 PROPERTY (vector<LDObject*>, cache, setCache)
51 PROPERTY (long, savePos, setSavePos) 51 PROPERTY (long, savePos, setSavePos)
52 52
53 public: 53 public:
54 typedef std::vector<LDObject*>::iterator it;
55 typedef std::vector<LDObject*>::const_iterator c_it;
56
57 LDOpenFile (); 54 LDOpenFile ();
58 ~LDOpenFile (); 55 ~LDOpenFile ();
59 56
60 // Saves this file to disk. 57 // Saves this file to disk.
61 bool save (str zPath = ""); 58 bool save (str zPath = "");
73 LDObject* obj (ulong pos) const { return object (pos); } 70 LDObject* obj (ulong pos) const { return object (pos); }
74 71
75 void insertObj (const ulong pos, LDObject* obj); 72 void insertObj (const ulong pos, LDObject* obj);
76 ulong numObjs () const { return m_objs.size (); } 73 ulong numObjs () const { return m_objs.size (); }
77 void setObject (ulong idx, LDObject* obj); 74 void setObject (ulong idx, LDObject* obj);
78
79 it begin () { return m_objs.begin (); }
80 it end () { return m_objs.end (); }
81 c_it cbegin () const { return m_objs.cbegin (); }
82 c_it cend () const { return m_objs.cend (); }
83 }; 75 };
84 76
85 // Close all current loaded files and start off blank. 77 // Close all current loaded files and start off blank.
86 void newFile (); 78 void newFile ();
87 79
118 } partListEntry; 110 } partListEntry;
119 111
120 // Init and parse parts.lst 112 // Init and parse parts.lst
121 void initPartList (); 113 void initPartList ();
122 114
123 std::vector<LDObject*> loadFileContents (FILE* fp, ulong* numWarnings, bool* ok = null); 115 vector<LDObject*> loadFileContents (FILE* fp, ulong* numWarnings, bool* ok = null);
124 116
125 extern vector<LDOpenFile*> g_loadedFiles; 117 extern vector<LDOpenFile*> g_loadedFiles;
126 extern vector<partListEntry> g_PartList; 118 extern vector<partListEntry> g_PartList;
127 119
128 str basename (str path); 120 str basename (str path);
129 str dirname (str path); 121 str dirname (str path);
130 122
131 class FileLoader : public QObject { 123 class FileLoader : public QObject {
132 Q_OBJECT 124 Q_OBJECT
133 125
134 READ_PROPERTY (std::vector<LDObject*>, objs) 126 READ_PROPERTY (vector<LDObject*>, objs)
135 READ_PROPERTY (bool, done) 127 READ_PROPERTY (bool, done)
136 READ_PROPERTY (ulong, progress) 128 READ_PROPERTY (ulong, progress)
137 PROPERTY (FILE*, filePointer, setFilePointer) 129 PROPERTY (FILE*, filePointer, setFilePointer)
138 PROPERTY (ulong*, warningsPointer, setWarningsPointer) 130 PROPERTY (ulong*, warningsPointer, setWarningsPointer)
139 131

mercurial