Angus Leeming wrote:
> It isn't static in the patch you posted. 

Sure isn't ;-)

> Anyway, this is what you need: 
>
> LaTeXFeatures.h
>
> class LaTeXFeatures {
>     ...
>     static PackagesList packages_;
> };
>
> LaTeXFeatures.C (immediately below the #includes):
>
> PackagesList LaTeXFeatures::packages_;

I might be totally blind, but I cannot get it to compile. Here's the error:

then mv -f ".deps/LaTeXFeatures.Tpo" ".deps/LaTeXFeatures.Po"; else rm -f 
".deps/LaTeXFeatures.Tpo"; exit 1; fi
LaTeXFeatures.C:49: error: Syntaxfehler before `::' token
make[3]: *** [LaTeXFeatures.o] Fehler 1
make[3]: Leaving directory `/home/juergen/lyx/lyx-devel/src'
make[2]: *** [all-recursive] Fehler 1
make[2]: Leaving directory `/home/juergen/lyx/lyx-devel/src'
make[1]: *** [all] Fehler 2
make[1]: Leaving directory `/home/juergen/lyx/lyx-devel/src'
make: *** [all-recursive] Fehler 1

Line 49 is
PackagesList LaTeXFeatures::packages_;

What's wrong with the attached patch?

Jürgen
Index: LaTeXFeatures.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeXFeatures.C,v
retrieving revision 1.115
diff -u -r1.115 LaTeXFeatures.C
--- LaTeXFeatures.C	19 Jan 2005 11:44:29 -0000	1.115
+++ LaTeXFeatures.C	24 Jan 2005 14:25:38 -0000
@@ -22,6 +22,7 @@
 #include "Floating.h"
 #include "FloatList.h"
 #include "language.h"
+#include "lyxlex.h"
 #include "lyx_sty.h"
 #include "lyxrc.h"
 
@@ -30,6 +31,7 @@
 #include <sstream>
 
 using lyx::support::IsSGMLFilename;
+using lyx::support::LibFileSearch;
 using lyx::support::MakeRelPath;
 using lyx::support::OnlyPath;
 
@@ -44,6 +46,9 @@
 namespace biblio = lyx::biblio;
 
 
+PackagesList LaTeXFeatures::packages_;
+
+
 LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, bool n)
 	: buffer_(&b), params_(p), nice_(n)
 {}
@@ -66,6 +71,39 @@
 }
 
 
+void LaTeXFeatures::getAvailable()
+{
+	LyXLex lex(0, 0);
+	string real_file = LibFileSearch("", "packages.lst");
+
+	if (real_file.empty())
+		return;
+
+	lex.setFile(real_file);
+
+	if (!lex.isOK()) 
+		return;
+
+	bool finished = false;
+	// Parse config-file
+	while (lex.isOK() && !finished) {
+		switch (lex.lex()) {
+		case LyXLex::LEX_FEOF:
+			finished = true;
+			break;
+		default:
+			string const name = lex.getString();
+			PackagesList::const_iterator begin = packages_.begin();
+			PackagesList::const_iterator end   = packages_.end();
+			if (find(begin, end, name) == end)
+				packages_.push_back(name);
+		}
+	}
+
+	return;
+}
+
+
 void LaTeXFeatures::useLayout(string const & layoutname)
 {
 	// Some code to avoid loops in dependency definition
@@ -108,6 +146,14 @@
 bool LaTeXFeatures::isRequired(string const & name) const
 {
 	return find(features_.begin(), features_.end(), name) != features_.end();
+}
+
+
+bool LaTeXFeatures::isAvailable(string const & name) const
+{
+	if (packages_.empty())
+		getAvailable();
+	return find(packages_.begin(), packages_.end(), name) != packages_.end();
 }
 
 
Index: LaTeXFeatures.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeXFeatures.h,v
retrieving revision 1.58
diff -u -r1.58 LaTeXFeatures.h
--- LaTeXFeatures.h	19 Jan 2005 15:03:27 -0000	1.58
+++ LaTeXFeatures.h	24 Jan 2005 14:25:39 -0000
@@ -62,8 +62,12 @@
 	void addExternalPreamble(std::string const &);
 	/// Provide a string name-space to the requirements
 	void require(std::string const & name);
+	/// Which of the required packages are installed?
+	static void getAvailable();
 	/// Is the package required?
 	bool isRequired(std::string const & name) const;
+	/// Is the (required) package available?
+	bool isAvailable(std::string const & name) const;
 	///
 	void useFloat(std::string const & name);
 	///
@@ -96,6 +100,10 @@
 	FeaturesList features_;
 	///
 	FeaturesList preamble_snippets_;
+	/// The available (required) packages
+	typedef std::list<std::string> PackagesList;
+	///
+	static PackagesList packages_;
 	///
 	typedef std::set<Language const *> LanguageList;
 	///

Reply via email to