]> git.lyx.org Git - lyx.git/blob - src/BackStack.h
more changes, read the Changelog
[lyx.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
16 #include "LString.h"
17
18 // Created by Alejandro Aguilar Sierra, 970806
19
20 /**  Utility to get back from a reference or from a child document.
21  */
22 class BackStack {
23 private:
24         ///
25         struct BackStackItem {
26                 ///
27                 BackStackItem(string const & f, int xx, int yy)
28                         : fname(f), x(xx), y(yy) {}
29                 /// Filename
30                 string fname;
31                 /// Cursor x-position
32                 int x;
33                 /// Cursor y-position
34                 int y;
35         };
36 public:
37         ///
38         void push(string f, int x, int y) {
39                 BackStackItem bit(f, x, y);
40                 stakk.push(bit);
41         }
42         ///
43         string pop(int * x, int * y) {
44                 BackStackItem bit = stakk.top();
45                 *x = bit.x;
46                 *y = bit.y;
47                 stakk.pop();
48                 return bit.fname;
49         }
50         ///
51         bool empty() const {
52                 return stakk.empty();
53         }
54 private:
55         ///
56         std::stack<BackStackItem> stakk;
57 };
58
59 #endif