]> git.lyx.org Git - lyx.git/blob - src/BackStack.h
Fix small bug in reading \set_color in lyxrc
[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() 
28                         : x(0), y(0) {}
29                 ///
30                 BackStackItem(string const & f, int xx, int yy)
31                         : fname(f), x(xx), y(yy) {}
32                 /// Filename
33                 string fname;
34                 /// Cursor x-position
35                 int x;
36                 /// Cursor y-position
37                 int y;
38         };
39 public:
40         ///
41         void push(string f, int x, int y) {
42                 BackStackItem bit(f, x, y);
43                 stakk.push(bit);
44         }
45         ///
46         string pop(int * x, int * y) {
47                 BackStackItem bit = stakk.top();
48                 *x = bit.x;
49                 *y = bit.y;
50                 stakk.pop();
51                 return bit.fname;
52         }
53         ///
54         bool empty() const {
55                 return stakk.empty();
56         }
57 private:
58         ///
59         std::stack<BackStackItem> stakk;
60 };
61
62 #endif