Doxygen
Loading...
Searching...
No Matches
ConfigList Class Referencefinal

Class representing a list type option. More...

#include <src/configimpl.h>

Inheritance diagram for ConfigList:
Collaboration diagram for ConfigList:

Public Types

enum  WidgetType { String , File , Dir , FileAndDir }
Public Types inherited from ConfigOption
enum  OptionType {
  O_Info , O_List , O_Enum , O_String ,
  O_Int , O_Bool , O_Obsolete , O_Disabled
}
enum  { MAX_OPTION_LENGTH = 23 }

Public Member Functions

 ConfigList (const char *name, const char *doc)
void addValue (const char *v)
void setWidgetType (WidgetType w)
WidgetType widgetType () const
StringVectorvalueRef ()
StringVector getDefault ()
void emptyValueToDefault () override
void writeTemplate (TextStream &t, bool sl, bool) override
void compareDoxyfile (TextStream &t, Config::CompareMode compareMode) override
void writeXMLDoxyfile (TextStream &t) override
void writeXSDDoxyfile (TextStream &t) override
void substEnvVars () override
void init () override
bool isDefault () override
Public Member Functions inherited from ConfigOption
 ConfigOption (OptionType t)
OptionType kind () const
DString name () const
DString docs () const
DString dependsOn () const
void addDependency (const char *dep)
void setEncoding (const DString &e)
void setUserComment (const DString &u)

Private Attributes

StringVector m_value
StringVector m_defaultValue
WidgetType m_widgetType

Additional Inherited Members

Protected Member Functions inherited from ConfigOption
virtual void convertStrToVal (Config::CompareMode)
void writeBoolValue (TextStream &t, bool v, bool initSpace=true)
void writeIntValue (TextStream &t, int i, bool initSpace=true)
void writeStringValue (TextStream &t, const DString &s, bool initSpace=true, bool wasQuoted=false)
void writeStringList (TextStream &t, const StringVector &l)
Protected Attributes inherited from ConfigOption
DString m_spaces
DString m_name
DString m_doc
DString m_dependency
DString m_encoding
DString m_userComment
OptionType m_kind

Detailed Description

Class representing a list type option.

Definition at line 120 of file configimpl.h.

Member Enumeration Documentation

◆ WidgetType

Enumerator
String 
File 
Dir 
FileAndDir 

Definition at line 123 of file configimpl.h.

Constructor & Destructor Documentation

◆ ConfigList()

ConfigList::ConfigList ( const char * name,
const char * doc )
inline

Definition at line 124 of file configimpl.h.

126 {
127 m_name = name;
128 m_doc = doc;
130 }
WidgetType m_widgetType
Definition configimpl.h:147
ConfigOption(OptionType t)
Definition configimpl.h:60
DString name() const
Definition configimpl.h:67
DString m_name
Definition configimpl.h:92
@ O_List
A list of items.
Definition configimpl.h:45
DString m_doc
Definition configimpl.h:93

References ConfigOption::ConfigOption(), ConfigOption::m_doc, ConfigOption::m_name, m_widgetType, ConfigOption::name(), ConfigOption::O_List, and String.

Member Function Documentation

◆ addValue()

void ConfigList::addValue ( const char * v)
inline

Definition at line 131 of file configimpl.h.

131{ m_defaultValue.emplace_back(v); }
StringVector m_defaultValue
Definition configimpl.h:146

References m_defaultValue.

◆ compareDoxyfile()

void ConfigList::compareDoxyfile ( TextStream & t,
Config::CompareMode compareMode )
overridevirtual

Implements ConfigOption.

Definition at line 417 of file configimpl.l.

418{
419 if (!isDefault()) writeTemplate(t,true,true);
420}
void writeTemplate(TextStream &t, bool sl, bool) override
Definition configimpl.l:368
bool isDefault() override
Definition configimpl.l:385

References isDefault(), and writeTemplate().

◆ emptyValueToDefault()

void ConfigList::emptyValueToDefault ( )
inlineoverridevirtual

Reimplemented from ConfigOption.

Definition at line 136 of file configimpl.h.

136{ if (m_value.empty() && !m_defaultValue.empty()) m_value=m_defaultValue; }
StringVector m_value
Definition configimpl.h:145

References m_defaultValue, and m_value.

◆ getDefault()

StringVector ConfigList::getDefault ( )
inline

Definition at line 135 of file configimpl.h.

135{ return m_defaultValue; }

References m_defaultValue.

◆ init()

void ConfigList::init ( )
inlineoverridevirtual

Reimplemented from ConfigOption.

Definition at line 142 of file configimpl.h.

References m_defaultValue, and m_value.

◆ isDefault()

bool ConfigList::isDefault ( )
overridevirtual

Reimplemented from ConfigOption.

Definition at line 385 of file configimpl.l.

386{
387 auto get_stripped = [](const std::string &s) { return DString(s).stripWhiteSpace(); };
388 auto is_not_empty = [get_stripped](const std::string &s) { return !get_stripped(s).empty(); };
389 size_t defCnt = std::count_if( m_value.begin(), m_value.end(),is_not_empty);
390 size_t valCnt = std::count_if(m_defaultValue.begin(),m_defaultValue.end(),is_not_empty);
391 if ( valCnt != defCnt)
392 {
393 return false;
394 }
395 auto it1 = m_value.begin();
396 auto it2 = m_defaultValue.begin();
397 while (it1!=m_value.end() && it2!=m_defaultValue.end())
398 {
399 // skip over empty values
400 while (it1!=m_value.end() && !is_not_empty(*it1))
401 {
402 ++it1;
403 }
404 if (it1!=m_value.end()) // non-empty value
405 {
406 if (get_stripped(*it1) != get_stripped(*it2)) // not the default, write as difference
407 {
408 return false;
409 }
410 ++it1;
411 ++it2;
412 }
413 }
414 return true;
415}

References m_defaultValue, m_value, and DString::stripWhiteSpace().

Referenced by compareDoxyfile(), and writeXMLDoxyfile().

◆ setWidgetType()

void ConfigList::setWidgetType ( WidgetType w)
inline

Definition at line 132 of file configimpl.h.

132{ m_widgetType = w; }

References m_widgetType.

◆ substEnvVars()

void ConfigList::substEnvVars ( )
overridevirtual

Implements ConfigOption.

Definition at line 1520 of file configimpl.l.

1521{
1523}
static void substEnvVarsInStrList(StringVector &sl)

References m_value, and substEnvVarsInStrList().

◆ valueRef()

StringVector * ConfigList::valueRef ( )
inline

Definition at line 134 of file configimpl.h.

134{ return &m_value; }

References m_value.

◆ widgetType()

WidgetType ConfigList::widgetType ( ) const
inline

Definition at line 133 of file configimpl.h.

133{ return m_widgetType; }

References m_widgetType.

◆ writeTemplate()

void ConfigList::writeTemplate ( TextStream & t,
bool sl,
bool  )
overridevirtual

Implements ConfigOption.

Definition at line 368 of file configimpl.l.

369{
370 if (!sl)
371 {
372 t << "\n";
374 t << "\n";
375 }
376 else if (!m_userComment.empty())
377 {
379 }
382 t << "\n";
383}
DString m_spaces
Definition configimpl.h:91
DString m_userComment
Definition configimpl.h:96
void writeStringList(TextStream &t, const StringVector &l)
Definition configimpl.l:171
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:152
DString left(size_t len) const
Definition dstring.h:310
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:155
static DString convertToComment(const DString &s, const DString &u)
Definition configimpl.l:88

References convertToComment(), DString::empty(), DString::left(), DString::length(), ConfigOption::m_doc, ConfigOption::m_name, ConfigOption::m_spaces, ConfigOption::m_userComment, m_value, ConfigOption::MAX_OPTION_LENGTH, and ConfigOption::writeStringList().

Referenced by compareDoxyfile().

◆ writeXMLDoxyfile()

void ConfigList::writeXMLDoxyfile ( TextStream & t)
overridevirtual

Implements ConfigOption.

Definition at line 422 of file configimpl.l.

423{
424 t << " <option id='" << m_name << "'";
425 t << " default='" << (isDefault() ? "yes" : "no") << "'";
426 t << " type='stringlist'";
427 t << ">";
428 t << "\n";
429 for (const auto &p : m_value)
430 {
431 DString s = p;
432 t << " <value>";
433 t << "<![CDATA[";
434 writeStringValue(t,s,false);
435 t << "]]>";
436 t << "</value>\n";
437 }
438 t << " </option>\n";
439}
void writeStringValue(TextStream &t, const DString &s, bool initSpace=true, bool wasQuoted=false)
Definition configimpl.l:139

References isDefault(), ConfigOption::m_name, m_value, and ConfigOption::writeStringValue().

◆ writeXSDDoxyfile()

void ConfigList::writeXSDDoxyfile ( TextStream & t)
overridevirtual

Implements ConfigOption.

Definition at line 441 of file configimpl.l.

442{
443 t << " <xsd:enumeration value=\"" << m_name << "\"/>\n";
444}

References ConfigOption::m_name.

Member Data Documentation

◆ m_defaultValue

StringVector ConfigList::m_defaultValue
private

Definition at line 146 of file configimpl.h.

Referenced by addValue(), emptyValueToDefault(), getDefault(), init(), and isDefault().

◆ m_value

StringVector ConfigList::m_value
private

◆ m_widgetType

WidgetType ConfigList::m_widgetType
private

Definition at line 147 of file configimpl.h.

Referenced by ConfigList(), setWidgetType(), and widgetType().


The documentation for this class was generated from the following files: