Introduce a typedef for vector<Buffer *>. No change in behavior

anticipated.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35529 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-09-29 11:55:10 +00:00
parent efc2747a5c
commit 2291614a6c
8 changed files with 59 additions and 44 deletions

View File

@ -142,7 +142,9 @@ void showPrintError(string const & name)
} // namespace anon
class BufferSet : public std::set<Buffer const *> {};
typedef std::set<Buffer *> BufferSet;
class Buffer::Impl
{
@ -2297,9 +2299,10 @@ void Buffer::getLanguages(std::set<Language const *> & languages) const
for (ParConstIterator it = par_iterator_begin(); it != end; ++it)
it->getLanguages(languages);
// also children
std::vector<Buffer *> clist = getChildren();
for (vector<Buffer *>::const_iterator cit = clist.begin();
cit != clist.end(); ++cit)
ListOfBuffers clist = getChildren();
ListOfBuffers::const_iterator cit = clist.begin();
ListOfBuffers::const_iterator const cen = clist.end();
for (; cit != cen; ++cit)
(*cit)->getLanguages(languages);
}
@ -2496,12 +2499,12 @@ void Buffer::Impl::collectRelatives(BufferSet & bufs) const
}
std::vector<Buffer const *> Buffer::allRelatives() const
ListOfBuffers Buffer::allRelatives() const
{
BufferSet bufs;
d->collectRelatives(bufs);
BufferSet::iterator it = bufs.begin();
std::vector<Buffer const *> ret;
ListOfBuffers ret;
for (; it != bufs.end(); ++it)
ret.push_back(*it);
return ret;
@ -2534,7 +2537,7 @@ DocIterator Buffer::firstChildPosition(Buffer const * child)
}
void Buffer::getChildren(std::vector<Buffer *> & clist, bool grand_children) const
void Buffer::getChildren(ListOfBuffers & clist, bool grand_children) const
{
// loop over children
Impl::BufferPositionMap::iterator it = d->children_positions.begin();
@ -2544,16 +2547,16 @@ void Buffer::getChildren(std::vector<Buffer *> & clist, bool grand_children) con
clist.push_back(child);
if (grand_children) {
// there might be grandchildren
vector<Buffer *> glist = child->getChildren();
ListOfBuffers glist = child->getChildren();
clist.insert(clist.end(), glist.begin(), glist.end());
}
}
}
vector<Buffer *> Buffer::getChildren(bool grand_children) const
ListOfBuffers Buffer::getChildren(bool grand_children) const
{
vector<Buffer *> v;
ListOfBuffers v;
getChildren(v, grand_children);
return v;
}
@ -3442,9 +3445,10 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
} else
errors(error_type);
// also to the children, in case of master-buffer-view
std::vector<Buffer *> clist = getChildren();
for (vector<Buffer *>::const_iterator cit = clist.begin();
cit != clist.end(); ++cit) {
ListOfBuffers clist = getChildren();
ListOfBuffers::const_iterator cit = clist.begin();
ListOfBuffers::const_iterator const cen = clist.end();
for (; cit != cen; ++cit) {
if (d->cloned_buffer_) {
(*cit)->d->cloned_buffer_->d->errorLists[error_type] =
(*cit)->d->errorLists[error_type];

View File

@ -29,7 +29,6 @@ namespace lyx {
class BiblioInfo;
class BufferParams;
class BufferSet;
class DispatchResult;
class DocIterator;
class docstring_list;
@ -70,6 +69,11 @@ class FileName;
class FileNameList;
}
class Buffer;
typedef std::vector<Buffer *> ListOfBuffers;
/** The buffer object.
* This is the buffer object. It contains all the informations about
* a document loaded into LyX.
@ -301,8 +305,8 @@ public:
void setParent(Buffer const *);
Buffer const * parent() const;
// Collect all relative buffer
std::vector<Buffer const *> allRelatives() const;
/// Collect all relative buffers
ListOfBuffers allRelatives() const;
/** Get the document's master (or \c this if this is not a
child document)
@ -312,11 +316,11 @@ public:
/// \return true if \p child is a child of this \c Buffer.
bool isChild(Buffer * child) const;
/// return a vector with all children (and grandchildren)
std::vector<Buffer *> getChildren(bool grand_children = true) const;
/// return a vector of all children (and grandchildren)
ListOfBuffers getChildren(bool grand_children = true) const;
/// Add all children (and grandchildren) to supplied vector
void getChildren(std::vector<Buffer *> & children, bool grand_children = true) const;
void getChildren(ListOfBuffers & children, bool grand_children = true) const;
/// Is buffer read-only?
bool isReadonly() const;

View File

@ -276,10 +276,10 @@ Buffer * BufferList::getBufferFromTmp(string const & s)
if (suffixIs(s, master_name))
return *it;
// if not, try with the children
vector<Buffer *> clist = (*it)->getChildren();
vector<Buffer *>::const_iterator cit = clist.begin();
vector<Buffer *>::const_iterator cend = clist.end();
for (; cit < cend; ++cit) {
ListOfBuffers clist = (*it)->getChildren();
ListOfBuffers::const_iterator cit = clist.begin();
ListOfBuffers::const_iterator cend = clist.end();
for (; cit != cend; ++cit) {
string const mangled_child_name = DocFileName(
changeExtension((*cit)->absFileName(),
".tex")).mangledFileName();

View File

@ -2190,8 +2190,8 @@ bool BufferView::setCursorFromInset(Inset const * inset)
void BufferView::gotoLabel(docstring const & label)
{
std::vector<Buffer const *> bufs = buffer().allRelatives();
std::vector<Buffer const *>::iterator it = bufs.begin();
ListOfBuffers bufs = buffer().allRelatives();
ListOfBuffers::iterator it = bufs.begin();
for (; it != bufs.end(); ++it) {
Buffer const * buf = *it;

View File

@ -808,6 +808,7 @@ bool LyX::init()
// Set up command definitions
pimpl_->toplevel_cmddef_.read(lyxrc.def_file);
// FIXME
// Set up bindings
pimpl_->toplevel_keymap_.read("site");
pimpl_->toplevel_keymap_.read(lyxrc.bind_file);

View File

@ -122,7 +122,8 @@ bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event)
}
static docstring buffer_to_latex(Buffer & buffer) {
static docstring buffer_to_latex(Buffer & buffer)
{
OutputParams runparams(&buffer.params().encoding());
odocstringstream os;
runparams.nice = true;
@ -143,7 +144,8 @@ static docstring buffer_to_latex(Buffer & buffer) {
}
static vector<string> const & allManualsFiles() {
static vector<string> const & allManualsFiles()
{
static vector<string> v;
static const char * files[] = {
"Intro", "UserGuide", "Tutorial", "Additional",
@ -169,9 +171,10 @@ static vector<string> const & allManualsFiles() {
** Not using p_buf->allRelatives() here, because I'm not sure
** whether or not the returned order is independent of p_buf.
**/
static bool next_document_buffer(Buffer * & p_buf) {
Buffer *p_master = p_buf;
Buffer *p_old;
static bool next_document_buffer(Buffer * & p_buf)
{
Buffer * p_master = p_buf;
Buffer * p_old;
do {
p_old = p_master;
p_master = const_cast<Buffer *>(p_master->masterBuffer());
@ -181,12 +184,12 @@ static bool next_document_buffer(Buffer * & p_buf) {
<< p_master);
} while (p_master != p_old);
LASSERT(p_master != NULL, /**/);
vector<Buffer *> v_children;
ListOfBuffers v_children;
/* Root master added as first buffer in the vector */
v_children.push_back(p_master);
p_master->getChildren(v_children, true);
LYXERR(Debug::FIND, "v_children.size()=" << v_children.size());
vector<Buffer *>::const_iterator it =
ListOfBuffers::const_iterator it =
find(v_children.begin(), v_children.end(), p_buf);
LASSERT(it != v_children.end(), /**/)
++it;
@ -207,9 +210,10 @@ static bool next_document_buffer(Buffer * & p_buf) {
** Not using p_buf->allRelatives() here, because I'm not sure
** whether or not the returned order is independent of p_buf.
**/
static bool prev_document_buffer(Buffer * & p_buf) {
Buffer *p_master = p_buf;
Buffer *p_old;
static bool prev_document_buffer(Buffer * & p_buf)
{
Buffer * p_master = p_buf;
Buffer * p_old;
do {
p_old = p_master;
p_master = const_cast<Buffer *>(p_master->masterBuffer());
@ -218,12 +222,13 @@ static bool prev_document_buffer(Buffer * & p_buf) {
<< ", p_master=" << p_master);
} while (p_master != p_old);
LASSERT(p_master != NULL, /**/);
vector<Buffer *> v_children;
// Use allRelatives()...
ListOfBuffers v_children;
/* Root master added as first buffer in the vector */
v_children.push_back(p_master);
p_master->getChildren(v_children, true);
LYXERR(Debug::FIND, "v_children.size()=" << v_children.size());
vector<Buffer *>::const_iterator it =
ListOfBuffers::const_iterator it =
find(v_children.begin(), v_children.end(), p_buf);
LASSERT(it != v_children.end(), /**/)
if (it == v_children.begin()) {

View File

@ -2782,7 +2782,7 @@ void GuiDocument::paramsToDialog()
}
// Master/Child
std::vector<Buffer *> children;
ListOfBuffers children;
if (bufferview())
children = buffer().getChildren(false);
if (children.empty()) {
@ -3048,9 +3048,9 @@ void GuiDocument::updateIncludeonlys()
masterChildModule->maintainAuxCB->setEnabled(true);
}
QTreeWidgetItem * item = 0;
std::vector<Buffer *> children = buffer().getChildren(false);
vector<Buffer *>::const_iterator it = children.begin();
vector<Buffer *>::const_iterator end = children.end();
ListOfBuffers children = buffer().getChildren(false);
ListOfBuffers::const_iterator it = children.begin();
ListOfBuffers::const_iterator end = children.end();
bool has_unincluded = false;
bool all_unincluded = true;
for (; it != end; ++it) {

View File

@ -2328,9 +2328,10 @@ bool GuiView::closeBuffer(Buffer & buf)
// in the session file in the correct order. If we close the master
// buffer, we can close or release the child buffers here too.
if (!closing_) {
vector<Buffer *> clist = buf.getChildren(false);
for (vector<Buffer *>::const_iterator it = clist.begin();
it != clist.end(); ++it) {
ListOfBuffers clist = buf.getChildren(false);
ListOfBuffers::const_iterator const bend = clist.end();
for (ListOfBuffers::const_iterator it = clist.begin();
it != bend; ++it) {
// If a child is dirty, do not close
// without user intervention
//FIXME: should we look in other tabworkareas?