Doxygen
Loading...
Searching...
No Matches
condparser.cpp File Reference
#include <algorithm>
#include "condparser.h"
#include "config.h"
#include "configimpl.h"
#include "configoptions.h"
#include "message.h"
Include dependency graph for condparser.cpp:

Go to the source code of this file.

Functions

static DString resolveConfig (const DString &fileName, int lineNr, const DString &expr)
static DString getConfig (const DString &fileName, int lineNr, const DString &expr)
static bool isDelimiter (const char c)
 checks if the given char c is a delimiter minus is checked apart, can be unary minus
static bool isAlpha (const char c)
 checks if the given char c is a letter or underscore
static bool isAlphaNumSpec (const char c)

Variables

static DString error_str = "doxyconfig_error"
 Copyright (C) 1997-2015 by Dimitri van Heesch.

Function Documentation

◆ getConfig()

DString getConfig ( const DString & fileName,
int lineNr,
const DString & expr )
static

Definition at line 292 of file condparser.cpp.

293{
294 if (expr.empty())
295 {
296 return error_str;
297 }
298 ConfigOption * opt = ConfigImpl::instance()->get(expr);
299 if (opt)
300 {
301 switch (opt->kind())
302 {
304 return((static_cast<ConfigBool*>(opt)->valueRef())? "YES" : "NO");
306 // due to the fact that there can be any character in the string
307 warn(fileName,lineNr,
308 "String setting '{}' not possible in conditional statement, ignored", expr);
309 return error_str;
311 return(*(static_cast<ConfigEnum*>(opt)->valueRef()));
313 return (DString().setNum(*(static_cast<ConfigInt*>(opt)->valueRef())));
315 warn(fileName,lineNr,
316 "List setting '{}' not possible in conditional statement, ignored", expr);
317 return error_str;
319 warn(fileName,lineNr,
320 "Obsolete setting '{}' not possible in conditional statement, ignored", expr);
321 return error_str;
323 warn(fileName,lineNr,
324 "Disabled setting '{}' not possible in conditional statement, ignored", expr);
325 return error_str;
327 warn(fileName,lineNr,
328 "Info setting '{}' not possible in conditional statement, ignored", expr);
329 return error_str;
330 default:
331 warn(fileName,lineNr,
332 "Unknown error occurrence '{}', ignored", expr);
333 return error_str;
334 }
335 }
336 else
337 {
338 warn(fileName,lineNr,
339 "Unknown setting '{}' not possible in conditional statement, ignored", expr);
340 return error_str;
341 }
342}
Class representing a Boolean type option.
Definition configimpl.h:251
Class representing an enum type option.
Definition configimpl.h:153
static ConfigImpl * instance()
Definition configimpl.h:347
ConfigOption * get(const DString &name) const
Definition configimpl.h:396
Class representing an integer type option.
Definition configimpl.h:216
Abstract base class for any configuration option.
Definition configimpl.h:35
@ O_Disabled
Disabled compile time option.
Definition configimpl.h:51
@ O_List
A list of items.
Definition configimpl.h:45
@ O_Enum
A fixed set of items.
Definition configimpl.h:46
@ O_Bool
A boolean value.
Definition configimpl.h:49
@ O_String
A single item.
Definition configimpl.h:47
@ O_Obsolete
An obsolete option.
Definition configimpl.h:50
@ O_Int
An integer value.
Definition configimpl.h:48
@ O_Info
A section header.
Definition configimpl.h:44
OptionType kind() const
Definition configimpl.h:66
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:88
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:152
static DString error_str
Copyright (C) 1997-2015 by Dimitri van Heesch.
#define warn(file, line, fmt,...)
Definition message.h:97

References DString::empty(), error_str, ConfigImpl::get(), ConfigImpl::instance(), ConfigOption::kind(), ConfigOption::O_Bool, ConfigOption::O_Disabled, ConfigOption::O_Enum, ConfigOption::O_Info, ConfigOption::O_Int, ConfigOption::O_List, ConfigOption::O_Obsolete, ConfigOption::O_String, and warn.

Referenced by resolveConfig().

◆ isAlpha()

bool isAlpha ( const char c)
static

checks if the given char c is a letter or underscore

Definition at line 81 of file condparser.cpp.

82{
83 return (c>='A' && c<='Z') || (c>='a' && c<='z') || c=='_';
84}

Referenced by CondParser::getToken(), and isAlphaNumSpec().

◆ isAlphaNumSpec()

bool isAlphaNumSpec ( const char c)
static

Definition at line 86 of file condparser.cpp.

87{
88 return isAlpha(c) || (c>='0' && c<='9') || c=='-' || c=='.' || (static_cast<unsigned char>(c)>=0x80);
89}
static bool isAlpha(const char c)
checks if the given char c is a letter or underscore

References isAlpha().

Referenced by CondParser::getToken().

◆ isDelimiter()

bool isDelimiter ( const char c)
static

checks if the given char c is a delimiter minus is checked apart, can be unary minus

Definition at line 73 of file condparser.cpp.

74{
75 return c=='&' || c=='|' || c=='!';
76}

Referenced by CondParser::getToken().

◆ resolveConfig()

DString resolveConfig ( const DString & fileName,
int lineNr,
const DString & expr )
static

Definition at line 344 of file condparser.cpp.

345{
346 if (expr.empty())
347 {
348 return "";
349 }
350
351 DString loc_expr;
352 signed char c = 0;
353 const char *p=expr.data();
354 while ((c=*p++)!=0)
355 {
356 switch(c)
357 {
358 case '\\':
359 case '@':
360 if (*p == 'd' && DString(p).startsWith("doxyconfig"))
361 {
362 p+=10; // skip doxyconfig
363 while (*p==' ' || *p=='\t') {p++;}
364 DString bufConfig;
365 while ((c=*p++)!=0)
366 {
367 if ((c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_') bufConfig += c;
368 else
369 {
370 break;
371 }
372 }
373 p--;
374 loc_expr += getConfig(fileName, lineNr, bufConfig);
375 }
376 break;
377 default:
378 loc_expr += c;
379 break;
380 }
381 }
382 return loc_expr;
383}
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:161
static DString getConfig(const DString &fileName, int lineNr, const DString &expr)

References DString::data(), DString::empty(), and getConfig().

Referenced by CondParser::parse().

Variable Documentation

◆ error_str

DString error_str = "doxyconfig_error"
static

Copyright (C) 1997-2015 by Dimitri van Heesch.

Permission to use, copy, modify, and distribute this software and its documentation under the terms of the GNU General Public License is hereby granted. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. See the GNU General Public License for more details.

Documents produced by Doxygen are derivative works derived from the input used in their production; they are not affected by this license.

C++ Expression parser for ENABLED_SECTIONS in Doxygen

Features used: Operators: && AND operator || OR operator ! NOT operator

Definition at line 31 of file condparser.cpp.

Referenced by getConfig().