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