src/file.h

changeset 250
6e80f038e8df
parent 249
6b2cc2d82ba6
child 251
c4b96bc41298
equal deleted inserted replaced
249:6b2cc2d82ba6 250:6e80f038e8df
37 // ============================================================================= 37 // =============================================================================
38 // LDOpenFile 38 // LDOpenFile
39 // 39 //
40 // The LDOpenFile class stores a file opened in LDForge either as a editable file 40 // The LDOpenFile class stores a file opened in LDForge either as a editable file
41 // for the user or for subfile caching. Its methods handle file input and output. 41 // for the user or for subfile caching. Its methods handle file input and output.
42 //
43 // A file is implicit when they are opened automatically for caching purposes
44 // and are hidden from the user. User-opened files are explicit (not implicit).
42 // ============================================================================= 45 // =============================================================================
43 class LDOpenFile { 46 class LDOpenFile {
47 PROPERTY (str, name, setName)
48 PROPERTY (bool, implicit, setImplicit)
49 MUTABLE_READ_PROPERTY (vector<LDObject*>, objs)
50 PROPERTY (vector<LDObject*>, cache, setCache)
51 PROPERTY (long, savePos, setSavePos)
52
44 public: 53 public:
45 typedef std::vector<LDObject*>::iterator it; 54 typedef std::vector<LDObject*>::iterator it;
46 typedef std::vector<LDObject*>::const_iterator c_it; 55 typedef std::vector<LDObject*>::const_iterator c_it;
47
48 str m_filename, m_title;
49 vector<LDObject*> m_objs;
50 vector<LDObject*> m_objCache; // Cache of this file's contents, if desired
51
52 int lastError;
53
54 // Is this file implicit? Implicit files are opened automatically for
55 // caching purposes and are hidden from the user.
56 bool m_implicit;
57 56
58 LDOpenFile (); 57 LDOpenFile ();
59 ~LDOpenFile (); 58 ~LDOpenFile ();
60 59
61 // Saves this file to disk. 60 // Saves this file to disk.
68 ulong addObject (LDObject* obj); 67 ulong addObject (LDObject* obj);
69 68
70 // Deletes the given object from the object chain. 69 // Deletes the given object from the object chain.
71 void forgetObject (LDObject* obj); 70 void forgetObject (LDObject* obj);
72 71
73 // At what point was this file last saved? 72 LDObject* object (ulong pos) const { return m_objs[pos]; }
74 long savePos; 73 LDObject* obj (ulong pos) const { return object (pos); }
75
76 LDObject* object (ulong pos) const {
77 return m_objs[pos];
78 }
79 74
80 void insertObj (const ulong pos, LDObject* obj); 75 void insertObj (const ulong pos, LDObject* obj);
76 ulong numObjs () const { return m_objs.size (); }
77 void setObject (ulong idx, LDObject* obj);
81 78
82 it begin () { return m_objs.begin (); } 79 it begin () { return m_objs.begin (); }
83 it end () { return m_objs.end (); } 80 it end () { return m_objs.end (); }
84 c_it cbegin () const { return m_objs.cbegin (); } 81 c_it cbegin () const { return m_objs.cbegin (); }
85 c_it cend () const { return m_objs.cend (); } 82 c_it cend () const { return m_objs.cend (); }

mercurial