summaryrefslogtreecommitdiffstats
path: root/src/configimpl.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/configimpl.l')
-rw-r--r--src/configimpl.l123
1 files changed, 108 insertions, 15 deletions
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);