s_StringToBool(
const string&
value)
77 strings_GetEnvVarName(
const char* section,
78 const char* variable,
79 const char* env_var_name)
82 if( env_var_name && *env_var_name ) {
83env_var = env_var_name;
87 if( section && *section ) {
99 const TXChar* s_GetEnv(
const char* section,
100 const char* variable,
101 const char* env_var_name)
104s_GetEnvVarName(section, variable, env_var_name).c_str() ));
107 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 108 static const char*
constCONFIG_DUMP_SECTION =
"NCBI";
109 static const char*
constCONFIG_DUMP_VARIABLE =
"CONFIG_DUMP_VARIABLES";
111CONFIG_DUMP_VARIABLE,
115 static volatile bools_InConfigDump =
false;
117 inline bools_CanDumpConfig(
void)
126 #define DUMP_CONFIG(code, data) \ 127 if ( !s_InConfigDump ) { \ 128 s_InConfigDump = true; \ 129 ERR_POST_X(code, Note << data); \ 130 s_InConfigDump = false; \ 134 const char* variable,
135 const char* env_var_name,
138 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 139 boolis_config_dump =
NStr::Equal(section, CONFIG_DUMP_SECTION) &&
145 const TXChar*
str= s_GetEnv(section, variable, env_var_name);
149 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 150 if( is_config_dump ) {
151s_ConfigDump =
value;
153 if( s_CanDumpConfig() ) {
154 if( section && *section ) {
156 " ["<< section <<
"]" 160s_GetEnvVarName(section, variable, env_var_name));
177 if( section && *section ) {
180 const string& s = app->
GetConfig().
Get(section, variable);
183 bool value= s_StringToBool(s);
184 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 185 if( is_config_dump ) {
186s_ConfigDump =
value;
188 if( s_CanDumpConfig() ) {
190 " ["<< section <<
"]" 204 bool value= default_value;
205 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 206 if( is_config_dump ) {
207s_ConfigDump =
value;
209 if( s_CanDumpConfig() ) {
210 if( section && *section ) {
212 " ["<< section <<
"]" 230 const char* variable,
231 const char* env_var_name,
236 const TXChar*
str= s_GetEnv(section, variable, env_var_name);
240 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 241 if( s_CanDumpConfig() ) {
242 if( section && *section ) {
244 " ["<< section <<
"]" 248s_GetEnvVarName(section, variable, env_var_name));
265 if( section && *section ) {
268 const string& s = app->
GetConfig().
Get(section, variable);
272 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 273 if( s_CanDumpConfig() ) {
275 " ["<< section <<
"]" 289 int value= default_value;
290 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 291 if( s_CanDumpConfig() ) {
292 if( section && *section ) {
294 " ["<< section <<
"]" 312 const char* variable,
313 const char* env_var_name,
314 doubledefault_value)
318 const TXChar*
str= s_GetEnv(section, variable, env_var_name);
324 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 325 if( s_CanDumpConfig() ) {
326 if( section && *section ) {
328 " ["<< section <<
"]" 332s_GetEnvVarName(section, variable, env_var_name));
349 if( section && *section ) {
352 const string& s = app->
GetConfig().
Get(section, variable);
358 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 359 if( s_CanDumpConfig() ) {
361 " ["<< section <<
"]" 375 double value= default_value;
376 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 377 if( s_CanDumpConfig() ) {
378 if( section && *section ) {
380 " ["<< section <<
"]" 398 const char* variable,
399 const char* env_var_name,
400 const char* default_value,
405 const TXChar*
value= s_GetEnv(section, variable, env_var_name);
407 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 408 if( s_CanDumpConfig() ) {
409 if( section && *section ) {
411 " ["<< section <<
"]" 413 " = \""<<
value<<
"\"" 415s_GetEnvVarName(section, variable, env_var_name));
420 " = \""<<
value<<
"\"" 429 if( section && *section ) {
432 const string& v = app->
GetConfig().
Get(section, variable);
434 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 435 if( s_CanDumpConfig() ) {
437 " ["<< section <<
"]" 439 " = \""<<
value<<
"\"" 448 const char* dvalue = default_value? default_value:
"";
450 #ifdef NCBI_PARAM_ENABLE_CONFIG_DUMP 451 if( s_CanDumpConfig() ) {
452 if( section && *section ) {
454 " ["<< section <<
"]" 456 " = \""<< dvalue <<
"\"" 462 " = \""<< dvalue <<
"\""CAtomicCounter_WithAutoInit â.
static const char * str(char *buf, int n)
static CNcbiApplicationGuard InstanceGuard(void)
Singleton method.
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
bool FinishedLoadingConfig(void) const
Check if the application has finished loading config file (successfully or not).
TValue Add(int delta) THROWS_NONE
Atomically add value (=delta), and return new counter value.
TValue Get(void) const THROWS_NONE
Get atomic counter value.
static bool IsMainThreadDataInitialized(void)
TErrCode GetErrCode(void) const
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
int g_GetConfigInt(const char *section, const char *variable, const char *env_var_name, int default_value)
Get integer configuration value.
double g_GetConfigDouble(const char *section, const char *variable, const char *env_var_name, double default_value)
Get double configuration value.
virtual const char * GetErrCodeString(void) const override
Translate from the error code value to its string representation.
static void EnableConfigDump(bool enable)
string g_GetConfigString(const char *section, const char *variable, const char *env_var_name, const char *default_value, CParamBase::EParamSource *src)
Helper functions for getting values from registry/environment.
EParamSource
Source of the value returned by CParam::GetDefault().
bool g_GetConfigFlag(const char *section, const char *variable, const char *env_var_name, bool default_value)
Get boolean configuration value.
@ eNoThreadValue
Per-thread value is prohibited by flags.
@ eRecursion
Recursion while initializing param.
@ eParserError
Can not convert string to value.
@ eBadValue
Unexpected parameter value.
@ eSource_EnvVar
Environment.
@ eSource_Config
The app. config file.
@ eSource_NotSet
Not fully initialized.
@ eSource_Default
Hardcoded default.
virtual const string & Get(const string §ion, const string &name, TFlags flags=0) const
Get the parameter value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static bool StringToBool(const CTempString str)
Convert string to bool.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static double StringToDouble(const CTempStringEx str, TStringToNumFlags flags=0)
Convert string to double.
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
static string & ToUpper(string &str)
Convert string to upper case â string& version.
@ fAllowTrailingSpaces
Ignore trailing whitespace characters.
@ fAllowLeadingSpaces
Ignore leading whitespace characters in converted string.
@ fDecimalPosixOrLocal
StringToDouble*(): For decimal point, try both C and current locale.
#define NCBI_XNCBI_EXPORT
Definition of all error codes used in corelib (xncbi.lib).
const GenericPointer< typename T::ValueType > T2 value
static CAtomicCounter_WithAutoInit s_ConfigDumpDisabled(0)
Helper functions for getting values from registry/environment.
#define DUMP_CONFIG(code, data)
const char * kNcbiConfigPrefix
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4