This commit was manufactured by cvs2svn to create tag
[lyx.git] / src / lastfiles.h
blob0fdbf71e86e150807a1cec5736458bff70b403e7
1 // -*- C++ -*-
2 /* This file is part of
3 * ======================================================
4 *
5 * LyX, The Document Processor
6 *
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1999 The LyX Team.
10 * ====================================================== */
12 #ifndef LASTFILES_H
13 #define LASTFILES_H
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
19 #include <deque>
20 #include "LString.h"
23 /** The latest documents loaded
24 This class takes care of the last .lyx files used by the LyX user. It
25 both reads and writes this information to a file. The number of files
26 kept are user defined, but defaults to four.
28 class LastFiles
30 public:
31 ///
32 typedef deque<string> Files;
34 /**@name Constructors and Deconstructors */
35 //@{
36 /**
37 Parameters are: name of file to read. Whether LastFiles should
38 check for file existance, and the number of files to remember.
40 LastFiles(string const &, bool dostat = true, unsigned int num = 4);
41 //@}
43 /**@name Methods */
44 //@{
45 /**
46 This funtion inserts #file# into the last files list. If the file
47 already exist it is moved to the top of the list, else exist it
48 is placed on the top of the list. If the list is full the last
49 file in the list is popped from the end.
51 void newFile(string const &);
52 /** Writes the lastfiles table to disk. One file on each line, this
53 way we can at least have some special chars (e.g. space), but
54 newline in filenames are thus not allowed.
56 void writeFile(string const &) const;
57 ///
58 string operator[](unsigned int) const;
59 ///
60 Files::const_iterator begin() const { return files.begin(); }
61 ///
62 Files::const_iterator end() const { return files.end(); }
63 //@}
64 private:
65 /**@name const variables */
66 //@{
67 enum {
68 ///
69 DEFAULTFILES = 4,
70 /** There is no point in keeping more than this number
71 of files at the same time. However perhaps someday
72 someone finds use for more files and wants to
73 change it. Please do. But don't show the files in
74 a menu...
76 ABSOLUTEMAXLASTFILES = 20
78 //@}
80 /**@name Variables */
81 //@{
82 /// a list of lastfiles
83 Files files;
84 /// number of files in the lastfiles list.
85 unsigned int num_files;
86 /// check for file existance or not.
87 bool dostat;
88 //@}
90 /**@name Methods */
91 //@{
92 /** reads the .lyx_lastfiles at the beginning of the LyX session.
93 This will read the lastfiles file (usually .lyx_lastfiles). It
94 will normally discard files that don't exist anymore, unless
95 LastFiles has been initialized with dostat = false.
97 void readFile(string const &);
98 /// used by the constructor to set the number of stored last files.
99 void setNumberOfFiles(unsigned int num);
100 //@}
102 #endif