]> git.lyx.org Git - features.git/commitdiff
Buffer: Make Buffer::readFile() private.
authorVincent van Ravesteijn <vfr@lyx.org>
Tue, 26 Oct 2010 13:17:10 +0000 (13:17 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Tue, 26 Oct 2010 13:17:10 +0000 (13:17 +0000)
It's strange to have a public interface which has a function loadLyXFile and a function readFile. A user of this class will be confused about the difference.

Therefore, loadThisLyXFile will be next to loadLyXFile to stress that loadThisLyXFile will not load another file ;). I don't know whether all of you like that this function just calls readFile, but it feels good this way. All public paths for loading a file will now go through loadThisLyXFile (i.e. the paths that come from loadLyXFile), while readFile is a pure private function. If this doesn't make sense, just shout.

I think this improves the readability of the class.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35852 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Buffer.h

index 6db387a35f3d0d7291b9e1870de3fccdca24cc55..877329b4aff184e490b4f5a032ef962d37188c64 100644 (file)
@@ -3633,8 +3633,8 @@ Buffer::ReadStatus Buffer::readEmergency(FileName const & fn)
        {
        case 0: {
                docstring str;
-               ReadStatus const ret_rf = readFile(emergencyFile);
-               bool const success = (ret_rf == ReadSuccess);
+               ReadStatus const ret_llf = loadThisLyXFile(emergencyFile);
+               bool const success = (ret_llf == ReadSuccess);
                if (success) {
                        saveCheckSum(fn);
                        markDirty();
@@ -3689,9 +3689,9 @@ Buffer::ReadStatus Buffer::readAutosave(FileName const & fn)
        switch (ret)
        {
        case 0: {
-               ReadStatus const ret_rf = readFile(autosaveFile);
+               ReadStatus const ret_llf = loadThisLyXFile(autosaveFile);
                // the file is not saved if we load the autosave file.
-               if (ret_rf == ReadSuccess) {
+               if (ret_llf == ReadSuccess) {
                        markDirty();
                        saveCheckSum(fn);
                        return ReadSuccess;
@@ -3725,6 +3725,12 @@ Buffer::ReadStatus Buffer::loadLyXFile(FileName const & fn)
        if (ret_ra == ReadSuccess || ret_ra == ReadCancel)
                return ret_ra;
 
+       return loadThisLyXFile(fn);
+}
+
+
+Buffer::ReadStatus Buffer::loadThisLyXFile(FileName const & fn)
+{
        return readFile(fn);
 }
 
index d8a1c199e1226abab11b46406b35d1486bccd590..deb66ee4975b056724c7f0ec947c60eff7c4e199 100644 (file)
@@ -189,19 +189,25 @@ public:
        /// tries to extract the file from version control if it
        /// cannot be found. If it can be found, it will try to
        /// read an emergency save file or an autosave file.
+       /// \sa loadThisLyXFile
        ReadStatus loadLyXFile(support::FileName const & fn);
+       /// Loads a LyX file \c fn into the buffer. If you want
+       /// to check for files in a version control container,
+       /// emergency or autosave files, one should use \c loadLyXFile.
+       /// /sa loadLyXFile
+       ReadStatus loadThisLyXFile(support::FileName const & fn);
        /// read a new document from a string
        bool readString(std::string const &);
        /// Reloads the LyX file
        bool reload();
-//FIXME: The following two functions should be private
+//FIXME: The following function should be private
 //private:
-       /// read a new file
-       ReadStatus readFile(support::FileName const & fn);
        /// read the header, returns number of unknown tokens
        int readHeader(Lexer & lex);
        
 private:
+       /// read a new file
+       ReadStatus readFile(support::FileName const & fn);
        /// Reads a file without header.
        /// \param par if != 0 insert the file.
        /// \return \c true if file is not completely read.