1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
1999-10-25 18:52:23 +00:00
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997-1999 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-25 18:52:23 +00:00
|
|
|
#ifndef BACK_STACK_H
|
|
|
|
#define BACK_STACK_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#include <stack>
|
1999-11-08 13:54:04 +00:00
|
|
|
using std::stack;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
// Created by Alejandro Aguilar Sierra, 970806
|
|
|
|
|
|
|
|
/** Utility to get back from a reference or from a child document.
|
|
|
|
*/
|
|
|
|
class BackStack {
|
1999-11-04 01:40:20 +00:00
|
|
|
private:
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
struct BackStackItem {
|
1999-11-04 01:40:20 +00:00
|
|
|
BackStackItem(string const & f, int xx, int yy)
|
|
|
|
: fname(f), x(xx), y(yy) {}
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
//void set(string f, int xx, int yy) {
|
|
|
|
// fname = f; x = xx; y = yy;
|
|
|
|
//}
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Filename
|
1999-10-02 16:21:10 +00:00
|
|
|
string fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Cursor x-position
|
|
|
|
int x;
|
|
|
|
/// Cursor y-position
|
1999-10-25 18:52:23 +00:00
|
|
|
int y;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
1999-11-04 01:40:20 +00:00
|
|
|
public:
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void push(string f, int x, int y) {
|
1999-11-04 01:40:20 +00:00
|
|
|
BackStackItem bit(f, x, y);
|
|
|
|
stakk.push(bit);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
string pop(int * x, int * y) {
|
|
|
|
BackStackItem bit = stakk.top();
|
|
|
|
*x = bit.x;
|
|
|
|
*y = bit.y;
|
|
|
|
stakk.pop();
|
|
|
|
return bit.fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-10-25 18:52:23 +00:00
|
|
|
///
|
|
|
|
bool empty() const {
|
1999-11-04 01:40:20 +00:00
|
|
|
return stakk.empty();
|
1999-10-25 18:52:23 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
stack<BackStackItem> stakk;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|