1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
* ======================================================
|
1999-10-25 18:52:23 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-02-04 09:38:32 +00:00
|
|
|
* Copyright 1997-2000 The LyX Team.
|
1999-10-25 18:52:23 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
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
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
/** Utility to get back from a reference or from a child document.
|
2000-08-07 20:58:24 +00:00
|
|
|
@author Alejandro Aguilar Sierra
|
|
|
|
@version 970806
|
1999-09-27 18:44:28 +00:00
|
|
|
*/
|
|
|
|
class BackStack {
|
1999-11-04 01:40:20 +00:00
|
|
|
private:
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
struct BackStackItem {
|
2000-02-04 09:38:32 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
BackStackItem()
|
|
|
|
: x(0), y(0) {}
|
|
|
|
///
|
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
|
|
|
/// 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
|
|
|
}
|
2000-08-07 20:58:24 +00:00
|
|
|
/**
|
|
|
|
@return returns #true# if the stack is empty, #false# otherwise.
|
|
|
|
*/
|
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:
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
std::stack<BackStackItem> stakk;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|