summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.h5
-rw-r--r--src/configimpl.h26
-rw-r--r--src/configimpl.l123
-rw-r--r--src/xmlgen.cpp14
4 files changed, 150 insertions, 18 deletions
diff --git a/src/config.h b/src/config.h
index f3fd278..6d74817 100644
--- a/src/config.h
+++ b/src/config.h
@@ -61,6 +61,11 @@ namespace Config
*/
void compareDoxyfile(std::ostream &t);
+ /*! Writes a the used settings of the current configuartion as XML format
+ * to stream \a t.
+ */
+ void writeXMLDoxyfile(std::ostream &t);
+
/*! Parses a configuration file with name \a fn.
* \returns TRUE if successful, FALSE if the file could not be
* opened or read.
diff --git a/src/configimpl.h b/src/configimpl.h
index 2a124f8..cfebcee 100644
--- a/src/configimpl.h
+++ b/src/configimpl.h
@@ -77,14 +77,16 @@ class ConfigOption
protected:
virtual void writeTemplate(std::ostream &t,bool sl,bool upd) = 0;
virtual void compareDoxyfile(std::ostream &t) = 0;
+ virtual void writeXMLDoxyfile(std::ostream &t) = 0;
virtual void convertStrToVal() {}
virtual void emptyValueToDefault() {}
virtual void substEnvVars() = 0;
virtual void init() {}
+ virtual bool isDefault() {return true;}
- void writeBoolValue(std::ostream &t,bool v);
- void writeIntValue(std::ostream &t,int i);
- void writeStringValue(std::ostream &t,const QCString &s);
+ void writeBoolValue(std::ostream &t,bool v,bool initSpace = true);
+ void writeIntValue(std::ostream &t,int i,bool initSpace = true);
+ void writeStringValue(std::ostream &t,const QCString &s,bool initSpace = true);
void writeStringList(std::ostream &t,const StringVector &l);
QCString m_spaces;
@@ -109,6 +111,7 @@ class ConfigInfo : public ConfigOption
}
void writeTemplate(std::ostream &t, bool sl,bool);
void compareDoxyfile(std::ostream &){};
+ void writeXMLDoxyfile(std::ostream &) {};
void substEnvVars() {}
};
@@ -132,8 +135,10 @@ class ConfigList : public ConfigOption
StringVector getDefault() { return m_defaultValue; }
void writeTemplate(std::ostream &t,bool sl,bool);
void compareDoxyfile(std::ostream &t);
+ void writeXMLDoxyfile(std::ostream &t);
void substEnvVars();
void init() { m_value = m_defaultValue; }
+ bool isDefault();
private:
StringVector m_value;
StringVector m_defaultValue;
@@ -160,7 +165,9 @@ class ConfigEnum : public ConfigOption
void writeTemplate(std::ostream &t,bool sl,bool);
void convertStrToVal();
void compareDoxyfile(std::ostream &t);
+ void writeXMLDoxyfile(std::ostream &t);
void init() { m_value = m_defValue.copy(); }
+ bool isDefault() { return (m_value == m_defValue); }
private:
std::vector<QCString> m_valueRange;
@@ -190,9 +197,11 @@ class ConfigString : public ConfigOption
QCString *valueRef() { return &m_value; }
void writeTemplate(std::ostream &t,bool sl,bool);
void compareDoxyfile(std::ostream &t);
+ void writeXMLDoxyfile(std::ostream &t);
void substEnvVars();
void init() { m_value = m_defValue.copy(); }
void emptyValueToDefault() { if(m_value.isEmpty()) m_value=m_defValue; };
+ bool isDefault() { return (m_value.stripWhiteSpace() == m_defValue.stripWhiteSpace()); }
private:
QCString m_value;
@@ -223,7 +232,9 @@ class ConfigInt : public ConfigOption
void substEnvVars();
void writeTemplate(std::ostream &t,bool sl,bool upd);
void compareDoxyfile(std::ostream &t);
+ void writeXMLDoxyfile(std::ostream &t);
void init() { m_value = m_defValue; }
+ bool isDefault() { return (m_value == m_defValue); }
private:
int m_value;
int m_defValue;
@@ -252,7 +263,9 @@ class ConfigBool : public ConfigOption
void setValueString(const QCString &v) { m_valueString = v; }
void writeTemplate(std::ostream &t,bool sl,bool upd);
void compareDoxyfile(std::ostream &t);
+ void writeXMLDoxyfile(std::ostream &t);
void init() { m_value = m_defValue; }
+ bool isDefault() { return (m_value == m_defValue); }
private:
bool m_value;
bool m_defValue;
@@ -268,6 +281,7 @@ class ConfigObsolete : public ConfigOption
{ m_name = name; }
void writeTemplate(std::ostream &,bool,bool);
void compareDoxyfile(std::ostream &) {}
+ void writeXMLDoxyfile(std::ostream &) {};
void substEnvVars() {}
};
@@ -280,6 +294,7 @@ class ConfigDisabled : public ConfigOption
{ m_name = name; }
void writeTemplate(std::ostream &,bool,bool);
void compareDoxyfile(std::ostream &) {}
+ void writeXMLDoxyfile(std::ostream &) {};
void substEnvVars() {}
};
@@ -480,6 +495,11 @@ class ConfigImpl
*/
void compareDoxyfile(std::ostream &t);
+ /*! Writes a the used settings of the current configuartion as XML format
+ * to stream \a t.
+ */
+ void writeXMLDoxyfile(std::ostream &t);
+
void setHeader(const char *header) { m_header = header; }
/////////////////////////////
diff --git a/src/configimpl.l b/src/configimpl.l
index 6f22061..2e3b5e7 100644
--- a/src/configimpl.l
+++ b/src/configimpl.l
@@ -37,6 +37,7 @@
#include "portable.h"
#include "message.h"
#include "lang_cfg.h"
+#include "language.h"
#include "configoptions.h"
#include "fileinfo.h"
#include "dir.h"
@@ -127,18 +128,19 @@ static QCString convertToComment(const QCString &s, const QCString &u)
return result;
}
-void ConfigOption::writeBoolValue(std::ostream &t,bool v)
+void ConfigOption::writeBoolValue(std::ostream &t,bool v,bool initSpace)
{
- t << " ";
+ if (initSpace) t << " ";
if (v) t << "YES"; else t << "NO";
}
-void ConfigOption::writeIntValue(std::ostream &t,int i)
+void ConfigOption::writeIntValue(std::ostream &t,int i,bool initSpace)
{
- t << " " << i;
+ if (initSpace) t << " ";
+ t << i;
}
-void ConfigOption::writeStringValue(std::ostream &t,const QCString &s)
+void ConfigOption::writeStringValue(std::ostream &t,const QCString &s,bool initSpace)
{
char c;
bool needsEscaping=FALSE;
@@ -147,7 +149,7 @@ void ConfigOption::writeStringValue(std::ostream &t,const QCString &s)
const char *p=se.data();
if (p)
{
- t << " ";
+ if (initSpace) t << " ";
while ((c=*p++)!=0 && !needsEscaping)
needsEscaping = (c==' ' || c== ',' || c=='\n' || c=='\t' || c=='"' || c=='#');
if (needsEscaping)
@@ -349,7 +351,7 @@ void ConfigList::writeTemplate(std::ostream &t,bool sl,bool)
t << "\n";
}
-void ConfigList::compareDoxyfile(std::ostream &t)
+bool ConfigList::isDefault()
{
auto get_stripped = [](std::string s) { return QCString(s.c_str()).stripWhiteSpace(); };
auto is_not_empty = [get_stripped](std::string s) { return !get_stripped(s).isEmpty(); };
@@ -357,8 +359,7 @@ void ConfigList::compareDoxyfile(std::ostream &t)
int valCnt = std::count_if(m_defaultValue.begin(),m_defaultValue.end(),is_not_empty);
if ( valCnt != defCnt)
{
- writeTemplate(t,TRUE,TRUE);
- return;
+ return false;
}
auto it1 = m_value.begin();
auto it2 = m_defaultValue.begin();
@@ -373,13 +374,37 @@ void ConfigList::compareDoxyfile(std::ostream &t)
{
if (get_stripped(*it1) != get_stripped(*it2)) // not the default, write as difference
{
- writeTemplate(t,TRUE,TRUE);
- return;
+ return false;
}
++it1;
++it2;
}
}
+ return true;
+}
+
+void ConfigList::compareDoxyfile(std::ostream &t)
+{
+ if (!isDefault()) writeTemplate(t,TRUE,TRUE);
+}
+
+void ConfigList::writeXMLDoxyfile(std::ostream &t)
+{
+ t << " <option id='" << m_name << "'";
+ t << " default='" << (isDefault() ? "yes" : "no") << "'";
+ t << " type='stringlist'";
+ t << ">";
+ t << "\n";
+ for (const auto &p : m_value)
+ {
+ QCString s=p.c_str();
+ t << " <value>";
+ t << "<![CDATA[";
+ writeStringValue(t,s,false);
+ t << "]]>";
+ t << "</value>\n";
+ }
+ t << " </option>\n";
}
void ConfigEnum::writeTemplate(std::ostream &t,bool sl,bool)
@@ -401,7 +426,19 @@ void ConfigEnum::writeTemplate(std::ostream &t,bool sl,bool)
void ConfigEnum::compareDoxyfile(std::ostream &t)
{
- if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE);
+ if (!isDefault()) writeTemplate(t,TRUE,TRUE);
+}
+
+void ConfigEnum::writeXMLDoxyfile(std::ostream &t)
+{
+ t << " <option id='" << m_name << "'";
+ t << " default='" << (isDefault() ? "yes" : "no") << "'";
+ t << " type='string'";
+ t << ">";
+ t << "<value>";
+ writeStringValue(t,m_value,false);
+ t << "</value>";
+ t << "</option>\n";
}
void ConfigString::writeTemplate(std::ostream &t,bool sl,bool)
@@ -423,7 +460,21 @@ void ConfigString::writeTemplate(std::ostream &t,bool sl,bool)
void ConfigString::compareDoxyfile(std::ostream &t)
{
- if (m_value.stripWhiteSpace() != m_defValue.stripWhiteSpace()) writeTemplate(t,TRUE,TRUE);
+ if (!isDefault()) writeTemplate(t,TRUE,TRUE);
+}
+
+void ConfigString::writeXMLDoxyfile(std::ostream &t)
+{
+ t << " <option id='" << m_name << "'";
+ t << " default='" << (isDefault() ? "yes" : "no") << "'";
+ t << " type='string'";
+ t << ">";
+ t << "<value>";
+ t << "<![CDATA[";
+ writeStringValue(t,m_value,false);
+ t << "]]>";
+ t << "</value>";
+ t << "</option>\n";
}
void ConfigInt::writeTemplate(std::ostream &t,bool sl,bool upd)
@@ -452,9 +503,22 @@ void ConfigInt::writeTemplate(std::ostream &t,bool sl,bool upd)
void ConfigInt::compareDoxyfile(std::ostream &t)
{
- if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE);
+ if (!isDefault()) writeTemplate(t,TRUE,TRUE);
+}
+
+void ConfigInt::writeXMLDoxyfile(std::ostream &t)
+{
+ t << " <option id='" << m_name << "'";
+ t << " default='" << (isDefault() ? "yes" : "no") << "'";
+ t << " type='int'";
+ t << ">";
+ t << "<value>";
+ writeIntValue(t,m_value,false);
+ t << "</value>";
+ t << "</option>\n";
}
+
void ConfigBool::writeTemplate(std::ostream &t,bool sl,bool upd)
{
if (!sl)
@@ -482,9 +546,22 @@ void ConfigBool::writeTemplate(std::ostream &t,bool sl,bool upd)
void ConfigBool::compareDoxyfile(std::ostream &t)
{
- if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE);
+ if (!isDefault()) writeTemplate(t,TRUE,TRUE);
}
+void ConfigBool::writeXMLDoxyfile(std::ostream &t)
+{
+ t << " <option id='" << m_name << "'";
+ t << " default='" << (isDefault() ? "yes" : "no") << "'";
+ t << " type='bool'";
+ t << ">";
+ t << "<value>";
+ writeBoolValue(t,m_value,false);
+ t << "</value>";
+ t << "</option>\n";
+}
+
+
void ConfigObsolete::writeTemplate(std::ostream &,bool,bool) {}
void ConfigDisabled::writeTemplate(std::ostream &,bool,bool) {}
@@ -1117,6 +1194,17 @@ void ConfigImpl::compareDoxyfile(std::ostream &t)
}
}
+void ConfigImpl::writeXMLDoxyfile(std::ostream &t)
+{
+ t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";
+ t << "<doxyfile xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"doxyfile.xsd\" version=\"" << getDoxygenVersion() << "\" xml:lang=\"" << theTranslator->trISOLang() << "\">\n";
+ for (const auto &option : m_options)
+ {
+ option->writeXMLDoxyfile(t);
+ }
+ t << "</doxyfile>\n";
+}
+
void ConfigImpl::convertStrToVal()
{
for (const auto &option : m_options)
@@ -2073,6 +2161,11 @@ void Config::compareDoxyfile(std::ostream &t)
ConfigImpl::instance()->compareDoxyfile(t);
}
+void Config::writeXMLDoxyfile(std::ostream &t)
+{
+ ConfigImpl::instance()->writeXMLDoxyfile(t);
+}
+
bool Config::parse(const char *fileName,bool update)
{
return ConfigImpl::instance()->parse(fileName,update);
diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp
index 9f74b69..39346da 100644
--- a/src/xmlgen.cpp
+++ b/src/xmlgen.cpp
@@ -1822,6 +1822,7 @@ void generateXML()
ResourceMgr::instance().copyResource("xml.xsd",outputDirectory);
ResourceMgr::instance().copyResource("index.xsd",outputDirectory);
+ ResourceMgr::instance().copyResource("doxyfile.xsd",outputDirectory);
QCString fileName=outputDirectory+"/compound.xsd";
std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary);
@@ -1858,6 +1859,19 @@ void generateXML()
}
t.close();
+ std::ofstream f;
+ fileName=outputDirectory+"/Doxyfile.xml";
+ bool fileOpened=openOutputFile(fileName,f);
+ if (fileOpened)
+ {
+ Config::writeXMLDoxyfile(f);
+ }
+ else
+ {
+ err("Cannot open file %s for writing\n",fileName.data());
+ return;
+ }
+
fileName=outputDirectory+"/index.xml";
t.open(fileName.str(),std::ofstream::out | std::ofstream::binary);
if (!t.is_open())