<
classTValue>
72 operatorTValue& (void)
130 operator string&(void)
141 template<
classTValue>
161 template<
classTValue>
170 template<
classTValue>
201 template<
classTEnum,
classTParam>
218 template<
classTValue>
227 template<
classTDescription,
classTParam>
240 "Can not initialize parameter from string: "+
str);
247 template<
classTDescription,
classTParam>
333 template<
classTEnum,
classTParam>
341 returndescr.
enums[
i].value;
346 "Can not initialize enum from string: "+
str);
353 template<
classTEnum,
classTParam>
374 template<
classTDescription>
377: m_ValueSet(
false)
389 template<
classTDescription>
393 returns_ParamValueLock;
397 template<
classTDescription>
401 bool& def_init = TDescription::sm_DefaultInitialized;
402 _ASSERT(TDescription::sm_ParamDescription.section);
404TDescription::sm_Default = TDescription::sm_ParamDescription.default_value;
406sx_GetSource() = eSource_Default;
410TDescription::sm_Default = TDescription::sm_ParamDescription.default_value;
411sx_GetState() = eState_NotSet;
412sx_GetSource() = eSource_Default;
415 if(sx_GetState() < eState_Func) {
416 _ASSERT(sx_GetState() != eState_InFunc);
417 if(sx_GetState() == eState_InFunc) {
420 "Recursion detected during CParam initialization.");
422 if( TDescription::sm_ParamDescription.init_func ) {
424sx_GetState() = eState_InFunc;
426TDescription::sm_Default = TParamParser::StringToValue(
427TDescription::sm_ParamDescription.init_func(),
428TDescription::sm_ParamDescription);
429sx_GetSource() = eSource_Func;
432sx_GetState() = eState_Error;
436sx_GetState() = eState_Func;
439 if(sx_GetState() < eState_Config) {
442 state= eState_Config;
446 stringconfig_value =
448TDescription::sm_ParamDescription.name,
449TDescription::sm_ParamDescription.env_var_name,
452 if( !config_value.empty() ) {
454TDescription::sm_Default = TParamParser::StringToValue(config_value,
455TDescription::sm_ParamDescription);
459sx_GetState() = eState_Error;
460 ERR_POST(
"Error reading CParam value "<<
461TDescription::sm_ParamDescription.section <<
"/"<< TDescription::sm_ParamDescription.name);
467? eState_Config : eState_EnvVar;
471 returnTDescription::sm_Default;
475 template<
classTDescription>
479 returnTDescription::sm_ValueTls;
483 template<
classTDescription>
487 returnTDescription::sm_State;
491 template<
classTDescription>
495 returnTDescription::sm_Source;
499 template<
classTDescription>
503 return(TDescription::sm_ParamDescription.
flags& flag) != 0;
507 template<
classTDescription>
513 if(sourcing_complete) {
514*sourcing_complete =
state== eState_Config;
517*param_source = sx_GetSource();
523 template<
classTDescription>
529 returnsx_GetDefault();
533 template<
classTDescription>
538sx_GetDefault() =
val;
540 if(
state< eState_User) {
543sx_GetSource() = eSource_User;
547 template<
classTDescription>
552sx_GetDefault(
true);
556 template<
classTDescription>
571 template<
classTDescription>
577 "The parameter does not allow thread-local values");
579 TTls& tls = sx_GetTls();
580tls.SetValue(
new TValueType(
val), g_ParamTlsValueCleanup<TValueType>);
584 template<
classTDescription>
591sx_GetTls().SetValue(
NULL);
595 template<
classTDescription>
603 template<
classTDescription>
614m_Value = GetThreadDefault();
615 if(GetState() >= eState_Config) {
626 template<
classTDescription>
635 template<
classTDescription>
SParamEnumDescription< TEnum > TParamDesc
static TEnumType StringToEnum(const string &str, const TParamDesc &descr)
static string EnumToString(const TEnumType &val, const TParamDesc &descr)
SEnumDescription< TEnum > TEnumDesc
static CNcbiApplication * Instance(void)
Singleton method.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
CSafeStatic< string > m_Value
CSafeStatic_Proxy & operator=(const string &value)
CSafeStatic_Proxy & operator=(const CSafeStatic_Proxy &proxy)
CSafeStatic_Proxy(const char *value)
CSafeStatic_Proxy(const CSafeStatic_Proxy &proxy)
CSafeStatic_Proxy & operator=(const char *value)
CSafeStatic_Proxy(const string &value)
CSafeStatic_Proxy(TValue value)
enable_if< std::is_scalar< TValue >::value, TValue >::type TStaticInit
CSafeStatic_Proxy & operator=(TValue value)
static const char * str(char *buf, int n)
static CNcbiApplicationGuard InstanceGuard(void)
Singleton method.
bool FinishedLoadingConfig(void) const
Check if the application has finished loading config file (successfully or not).
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
static void ResetDefault(void)
Reload the global default value from the environment/registry or reset it to the initial value specif...
void Reset(void)
Reset value as if it has not been initialized yet.
EParamState
Current param state flag - indicates which possible sources for the param have been checked.
static EParamState GetState(bool *sourcing_complete=nullptr, EParamSource *param_source=nullptr)
Get current state of the param.
static void SetThreadDefault(const TValueType &val)
Set new thread-local default value.
static bool sx_IsSetFlag(ENcbiParamFlags flag)
TParamDescription::TValueType TValueType
void Set(const TValueType &val)
Set new parameter value (this instance only).
static TValueType GetThreadDefault(void)
Get thread-local default value if set or global default value.
static bool sx_CanGetDefault(void)
EParamCacheFlag
Caching default value on construction of a param.
static SSystemMutex & s_GetLock(void)
static TTls & sx_GetTls(void)
static string ValueToString(const TValueType &val, const TParamDesc &descr)
static EParamSource & sx_GetSource(void)
TValueType Get(void) const
Get current parameter value.
ENcbiParamFlags
ENcbiParamFlags.
TDescription::TValueType TValueType
static void ResetThreadDefault(void)
Reset thread default value as if it has not been set.
string g_GetConfigString(const char *section, const char *variable, const char *env_var_name, const char *default_value, CParamBase::EParamSource *src=nullptr)
Helper functions for getting values from registry/environment.
static void SetDefault(const TValueType &val)
Set new global default value.
static EParamState & sx_GetState(void)
EParamSource
Source of the value returned by CParam::GetDefault().
static TValueType GetDefault(void)
Get global default value.
static TValueType & sx_GetDefault(bool force_reset=false)
static TValueType StringToValue(const string &str, const TParamDesc &descr)
@ eParamCache_Force
Force caching currently set default value.
@ eParamCache_Defer
Do not try to cache the default value.
@ eParam_NoLoad
Do not load from registry or environment.
@ eParam_NoThread
Do not use per-thread values.
#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 string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
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 const string BoolToString(bool value)
Convert bool to string.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
@ fAllowTrailingSpaces
Ignore trailing whitespace characters.
@ fAllowLeadingSpaces
Ignore leading whitespace characters in converted string.
@ fDecimalPosixOrLocal
StringToDouble*(): For decimal point, try both C and current locale.
@ fDoublePosix
DoubleToString*(): Use C locale for double conversions.
#define DEFINE_STATIC_MUTEX(id)
Define static mutex and initialize it.
const GenericPointer< typename T::ValueType > T2 value
void g_ParamTlsValueCleanup(TValue *value, void *)
Static variables safety - create on demand, destroy on application termination.
Common macro to detect used sanitizers and suppress memory leaks if run under LeakSanitizer.
#define NCBI_CLANG_ANALYZER_SUPPRESS
Suppress clang analyzer report.
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
std::istream & in(std::istream &in_, double &x_)
CSafeStatic_Proxy< TValue > TStaticValue
string(* FInitFunc)(void)
CSafeStatic_Proxy< TValue >::TStaticInit TStaticInit
TStaticInit default_value
const char * env_var_name
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