#include <boost/noncopyable.hpp>
-#include <list>
#include <map>
#include <set>
#include <vector>
// typedefs
///////////////////////////////////////////////////////////////////
/// The individual paragraph layouts comprising the document class
+ // NOTE Do NOT try to make this a container of Layout pointers, e.g.,
+ // std::vector<Layout *>. This will lead to problems. The reason is
+ // that DocumentClass objects are generally created by copying a
+ // LayoutFile, which serves as a base for the DocumentClass. If the
+ // LayoutList is a container of pointers, then every DocumentClass
+ // that derives from a given LayoutFile (e.g., article) will SHARE
+ // a basic set of layouts. So if one Buffer were to modify a layout
+ // (say, Standard), that would modify that layout for EVERY Buffer
+ // that was based upon the same DocumentClass. (Of course, if you
+ // really, REALLY want to make LayoutList a vector<Layout *>, then
+ // you can implement custom assignment and copy constructors.)
typedef std::vector<Layout> LayoutList;
/// The inset layouts available to this class
typedef std::map<docstring, InsetLayout> InsetLayouts;
enum ReadType {
BASECLASS, //>This is a base class, i.e., top-level layout file
MERGE, //>This is a file included in a layout file
- MODULE //>This is a layout module
+ MODULE, //>This is a layout module
+ VALIDATION //>We're just validating
};
+ /// return values for read()
+ enum ReturnValues {
+ OK,
+ ERROR,
+ FORMAT_MISMATCH
+ };
+
/// Performs the read of the layout file.
/// \return true on success.
bool read(support::FileName const & filename, ReadType rt = BASECLASS);
+ ///
+ bool read(std::string const & str, ReadType rt = BASECLASS);
+ ///
+ ReturnValues read(Lexer & lex, ReadType rt = BASECLASS);
+ /// validates the layout information passed in str
+ static bool validate(std::string const & str);
///////////////////////////////////////////////////////////////////
// loading
///////////////////////////////////////////////////////////////////
///
bool deleteLayout(docstring const &);
+ ///
+ bool convertLayoutFormat(support::FileName const &, ReadType);
/// \return true for success.
bool readStyle(Lexer &, Layout &);
///
/// will invoke the layout object defined by name = 'CharStyle'.
/// If that doesn't work either, an empty object returns (shouldn't
/// happen). -- Idea JMarc, comment MV
- ///
InsetLayout const & insetLayout(docstring const & name) const;
/// an empty inset layout for use as a default
static InsetLayout const & emptyInsetLayout() { return empty_insetlayout_; }
// accessors
///////////////////////////////////////////////////////////////////
/// the list of floats defined in the document class
- /// the list of floats defined in the document class
FloatList const & floats() const { return floatlist_; }
///
Counters & counters() const { return counters_; }
/// Constructs a DocumentClass based upon a LayoutFile.
DocumentClass(LayoutFile const & tc);
/// Needed in tex2lyx
- DocumentClass() {};
+ DocumentClass() {}
private:
/// The only class that can create a DocumentClass is
/// DocumentClassBundle, which calls the protected constructor.
private:
/// control instantiation
DocumentClassBundle() {}
+ /// clean up
+ ~DocumentClassBundle();
///
- std::list<DocumentClass *> tc_list_;
+ std::vector<DocumentClass *> documentClasses_;
};