Doxygen
Loading...
Searching...
No Matches
condparser.cpp File Reference
#include "condparser.h"
#include <algorithm>
#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 296 of file condparser.cpp.

297{
298 if (expr.empty())
299 {
300 return error_str;
301 }
302 ConfigOption * opt = ConfigImpl::instance()->get(expr);
303 if (opt)
304 {
305 switch (opt->kind())
306 {
308 return((static_cast<ConfigBool*>(opt)->valueRef())? "YES" : "NO");
310 // due to the fact that there can be any character in the string
311 warn(fileName,lineNr,
312 "String setting '{}' not possible in conditional statement, ignored", expr);
313 return error_str;
315 return(*(static_cast<ConfigEnum*>(opt)->valueRef()));
317 return (DString().setNum(*(static_cast<ConfigInt*>(opt)->valueRef())));
319 warn(fileName,lineNr,
320 "List setting '{}' not possible in conditional statement, ignored", expr);
321 return error_str;
323 warn(fileName,lineNr,
324 "Obsolete setting '{}' not possible in conditional statement, ignored", expr);
325 return error_str;
327 warn(fileName,lineNr,
328 "Disabled setting '{}' not possible in conditional statement, ignored", expr);
329 return error_str;
331 warn(fileName,lineNr,
332 "Info setting '{}' not possible in conditional statement, ignored", expr);
333 return error_str;
334 default:
335 warn(fileName,lineNr,
336 "Unknown error occurrence '{}', ignored", expr);
337 return error_str;
338 }
339 }
340 else
341 {
342 warn(fileName,lineNr,
343 "Unknown setting '{}' not possible in conditional statement, ignored", expr);
344 return error_str;
345 }
346}
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:84
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
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 85 of file condparser.cpp.

86{
87 return (c>='A' && c<='Z') || (c>='a' && c<='z') || c=='_';
88}

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

◆ isAlphaNumSpec()

bool isAlphaNumSpec ( const char c)
static

Definition at line 90 of file condparser.cpp.

91{
92 return isAlpha(c) || (c>='0' && c<='9') || c=='-' || c=='.' || (static_cast<unsigned char>(c)>=0x80);
93}
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 77 of file condparser.cpp.

78{
79 return c=='&' || c=='|' || c=='!';
80}

Referenced by CondParser::getToken().

◆ resolveConfig()

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

Definition at line 348 of file condparser.cpp.

349{
350 if (expr.empty())
351 {
352 return "";
353 }
354
355 DString loc_expr;
356 signed char c = 0;
357 const char *p=expr.data();
358 while ((c=*p++)!=0)
359 {
360 switch(c)
361 {
362 case '\\':
363 case '@':
364 if (*p == 'd' && DString(p).startsWith("doxyconfig"))
365 {
366 p+=10; // skip doxyconfig
367 while (*p==' ' || *p=='\t') {p++;}
368 DString bufConfig;
369 while ((c=*p++)!=0)
370 {
371 if ((c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_') bufConfig += c;
372 else
373 {
374 break;
375 }
376 }
377 p--;
378 loc_expr += getConfig(fileName, lineNr, bufConfig);
379 }
380 break;
381 default:
382 loc_expr += c;
383 break;
384 }
385 }
386 return loc_expr;
387}
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:157
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 35 of file condparser.cpp.

Referenced by getConfig().