From f4c88d4f34bf37d52765d21bd0f9a377b398da3e Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sat, 29 Mar 2008 15:22:58 +0000 Subject: [PATCH] Improve these. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24038 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/EmbeddedFiles.cpp | 18 ++++++++++-------- src/EmbeddedFiles.h | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/EmbeddedFiles.cpp b/src/EmbeddedFiles.cpp index 9202a61d02..a6450073cf 100644 --- a/src/EmbeddedFiles.cpp +++ b/src/EmbeddedFiles.cpp @@ -494,8 +494,8 @@ void EmbeddedFileList::registerFile(EmbeddedFile const & file, BOOST_ASSERT(!buffer.embedded() || file.enabled()); string newfile = file.absFilename(); - EmbeddedFile * efp = findFile(newfile); - if (efp) { + iterator efp = findFile(newfile); + if (efp != end()) { if (efp->embedded() != file.embedded()) { Alert::error(_("Wrong embedding status."), bformat(_("File %1$s is included in more than one insets, " @@ -514,27 +514,29 @@ void EmbeddedFileList::registerFile(EmbeddedFile const & file, } -EmbeddedFile const * EmbeddedFileList::findFile(std::string const & filename) const +EmbeddedFileList::const_iterator + EmbeddedFileList::findFile(std::string const & filename) const { // try to find this file from the list std::vector::const_iterator it = begin(); std::vector::const_iterator it_end = end(); for (; it != it_end; ++it) if (it->absFilename() == filename) - return &*it; - return 0; + return it; + return end(); } -EmbeddedFile * EmbeddedFileList::findFile(std::string const & filename) +EmbeddedFileList::iterator + EmbeddedFileList::findFile(std::string const & filename) { // try to find this file from the list std::vector::iterator it = begin(); std::vector::iterator it_end = end(); for (; it != it_end; ++it) if (it->absFilename() == filename) - return &*it; - return 0; + return it; + return end(); } diff --git a/src/EmbeddedFiles.h b/src/EmbeddedFiles.h index 3dc1550b67..cca8e5e8e8 100644 --- a/src/EmbeddedFiles.h +++ b/src/EmbeddedFiles.h @@ -211,8 +211,8 @@ public: Buffer const & buffer); /// returns a pointer to the Embedded file representing this object, /// or null if not found. The filename should be absolute. - EmbeddedFile const * findFile(std::string const & filename) const; - EmbeddedFile * findFile(std::string const & filename); + const_iterator findFile(std::string const & filename) const; + iterator findFile(std::string const & filename); /// validate embedded fies after a file is read. void validate(Buffer const & buffer); /// scan the buffer and get a list of EmbeddedFile -- 2.39.2