]> git.lyx.org Git - features.git/blob - src/BackStack.h
several small and larger changes, read the Changelog
[features.git] / src / BackStack.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1997-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #ifndef BACK_STACK_H
12 #define BACK_STACK_H
13
14 #include <stack>
15 using std::stack;
16
17 #include "LString.h"
18
19 // Created by Alejandro Aguilar Sierra, 970806
20
21 /**  Utility to get back from a reference or from a child document.
22  */
23 class BackStack {
24 private:
25         ///
26         struct BackStackItem {
27                 ///
28                 BackStackItem(string const & f, int xx, int yy)
29                         : fname(f), x(xx), y(yy) {}
30                 /// Filename
31                 string fname;
32                 /// Cursor x-position
33                 int x;
34                 /// Cursor y-position
35                 int y;
36         };
37 public:
38         ///
39         void push(string f, int x, int y) {
40                 BackStackItem bit(f, x, y);
41                 stakk.push(bit);
42         }
43         ///
44         string pop(int * x, int * y) {
45                 BackStackItem bit = stakk.top();
46                 *x = bit.x;
47                 *y = bit.y;
48                 stakk.pop();
49                 return bit.fname;
50         }
51         ///
52         bool empty() const {
53                 return stakk.empty();
54         }
55 private:
56         ///
57         stack<BackStackItem> stakk;
58 };
59
60 #endif