]> git.lyx.org Git - lyx.git/blob - src/BackStack.h
fix static array
[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 /**  Utility to get back from a reference or from a child document.
19      @author Alejandro Aguilar Sierra
20      @version 970806
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 const 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            @return returns #true# if the stack is empty, #false# otherwise.
55          */
56         bool empty() const {
57                 return stakk.empty();
58         }
59 private:
60         ///
61         std::stack<BackStackItem> stakk;
62 };
63
64 #endif