#ifndef BUFFER_FUNCS_H
#define BUFFER_FUNCS_H
-#include "support/std_string.h"
+#include "lyxlayout_ptr_fwd.h"
+#include "support/docstring.h"
+
+#include <string>
+
+
+namespace lyx {
+
+namespace support { class FileName; }
class Buffer;
-class TeXErrors;
+class DocIterator;
class ErrorList;
+class TeXErrors;
+class ParIterator;
+
+
+/**
+ * Returns true if the file is already loaded into a buffer.
+ */
+bool checkIfLoaded(support::FileName const & fn);
/**
* Loads a LyX file \c filename into \c Buffer
* and \return success status.
*/
-bool loadLyXFile(Buffer *, string const & filename);
+bool loadLyXFile(Buffer *, support::FileName const & filename);
+
+/**
+ * Checks and loads a LyX file \param filename.
+ * \retval the newly created \c Buffer pointer if successful or 0.
+ * \retval 0 if the \c Buffer could not be created.
+ */
+Buffer * checkAndLoadLyXFile(support::FileName const & filename);
-/* Make a new file (buffer) with name \c filename based on a template
- * named \c templatename
+/** Make a new file (buffer) with name \c filename based on a template
+ * named \c templatename
*/
-Buffer * newFile(string const & filename, string const & templatename,
+Buffer * newFile(std::string const & filename, std::string const & templatename,
bool isNamed = false);
///return the format of the buffer on a string
-string const BufferFormat(Buffer const & buffer);
+std::string const bufferFormat(Buffer const & buffer);
+
+/// Fill in the ErrorList with the TeXErrors
+void bufferErrors(Buffer const &, TeXErrors const &, ErrorList &);
+
+/// Count the number of words in the text between these two iterators
+int countWords(DocIterator const & from, DocIterator const & to);
+
+/// updates all counters
+void updateLabels(Buffer const &, bool childonly = false);
+
///
-void bufferErrors(Buffer const &, TeXErrors const &);
+void updateLabels(Buffer const &, ParIterator &);
+
///
-void bufferErrors(Buffer const &, ErrorList const &);
+void checkBufferStructure(Buffer &, ParIterator const &);
+
+///
+void loadChildDocuments(Buffer const & buffer);
+
+} // namespace lyx
#endif // BUFFER_FUNCS_H