(it->second == &mapper) {
92 "CEnvironmentRegistry::RemoveMapper:" 93 " unknown mapper (already removed?)", 0);
100 stringsection, name;
104 if(mapper->second->EnvToReg(*it, section, name)) {
145 stringvar_name = it->second->RegToEnv(section, name);
146 const string* resultp = &
m_Env->
Get(var_name, &found);
175 static const charkLowercaseASCII[] =
"abcdefghijklmnopqrstuvwxyz";
176 static const char kPattern[] =
".*";
179 stringsection2, name;
182 for(
int i=
sizeof(
kPattern) - 1;
i>= 0; --
i) {
183 string mask= mapper.second->RegToEnv(section,
kPattern+
i);
185 if(
mask.find_first_of(kLowercaseASCII) !=
NPOS) {
192 for(
const auto&
env:
l) {
194&& mapper.second->EnvToReg(
env, section2, name)
228TEntrySet entry_set(use_case);
229 stringparsed_section, parsed_name;
234 if(mapper->second->EnvToReg(*it, parsed_section, parsed_name)) {
235 if(section.empty()) {
236entry_set.insert(parsed_section);
237}
else if(
NStr::Equal(section, parsed_section, use_case)) {
238entry_set.insert(parsed_name);
243 ITERATE(TEntrySet, it, entry_set) {
268 stringvar_name = it->second->RegToEnv(section, name);
269 if( !var_name.empty() ) {
270 stringcap_name = var_name;
272 stringold_value =
m_Env->
Get(var_name);
274old_value =
m_Env->
Get(cap_name);
286 "no mapping defined for ["<< section <<
']'<< name);
296 stringvar_name = it->second->RegToEnv(section, name);
298 if(var_name.empty()) {
307 stringcap_name = var_name;
323<<
"CEnvironmentRegistry::x_SetComment: unsupported operation");
329 const string& prefix,
330 const string& suffix)
331: m_Section(section), m_Prefix(prefix), m_Suffix(suffix)
351name =
env.substr(plen,
env.length() - tlen);
364 static const char*
kPrefix=
"NCBI_CONFIG_";
374 result+= name.substr(1) +
"__"+ section;
376 result+=
"_"+ section +
"__"+ name;
378 #ifdef UPPER_CASE_ONLY 381 if(
result.find_first_of(
".-/ ") !=
NPOS) {
395 if(s.
size() == 3 && s ==
"DOT") {
400 if(s.
size() == 6 && s ==
"HYPHEN") {
405 if(s.
size() == 5) {
408}
else if(s ==
"SPACE") {
426 #ifdef UPPER_CASE_ONLY 427 for(
autoc : env_in ) {
433vector<CTempString> v;
436 env.reserve(env_in.size());
437 for(
const auto& it : v) {
440 if(&it != &v.back() && !
env.empty() &&
env[
l- 1] ==
'_' 446 if(&it != &v.back()) {
456 for( ; section_start_pos <
env.size(); section_start_pos++) {
457 if(
isalnum(
env[section_start_pos]))
break;
459 SIZE_TYPEuu_pos =
env.find(
"__", section_start_pos + 1);
460 if(uu_pos ==
NPOS|| uu_pos ==
env.size() - 2) {
466name =
env.substr(uu_pos + 2);
471section =
env.substr(uu_pos + 2);
474 ERR_POST(
Info<<
"Invalid registry section name in environment " 475 "variable "<<
env);
478 ERR_POST(
Info<<
"Invalid registry entry name in environment " 479 "variable "<<
env);
ncbi::TMaskedQueryRegions mask
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
iterator insert(const value_type &val)
container_type::value_type value_type
static char s_IdentifySubstitution(const CTempString &s)
static const size_t kPrefixLen
static const char * kPrefix
Classes to support using environment variables as a backend for the registry framework.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define REVERSE_ITERATE(Type, Var, Cont)
ITERATE macro to reverse sequence through container elements.
@ eTakeOwnership
An object can take ownership of another.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void Set(const string &name, const string &value)
Set an environment variable by name.
const string & Get(const string &name, bool *found=NULL) const
Get environment value by name.
void Unset(const string &name)
Delete an environment variable by name.
void Enumerate(list< string > &names, const string &prefix=kEmptyStr) const
Find all variable names starting with an optional prefix.
void Warning(CExceptionArgs_Base &args)
#define NCBI_THROW2(exception_class, err_code, message, extra)
Throw exception with extra parameter.
void Info(CExceptionArgs_Base &args)
CSimpleEnvRegMapper(const string §ion, const string &prefix, const string &suffix=kEmptyStr)
int TFlags
Binary OR of "EFlags".
bool x_Unset(const string §ion, const string &name, TFlags flags)
string RegToEnv(const string §ion, const string &name) const
Returns empty strings for unsupported (section, name) pairs.
void RemoveMapper(const IEnvRegMapper &mapper)
AutoPtr< CNcbiEnvironment > m_Env
~CEnvironmentRegistry()
Destructor.
void x_Clear(TFlags flags)
Called locked, like the virtual methods inherited from IRegistry.
string GetPrefix(void) const
Can be overriden to speed enumeration.
const string & x_Get(const string §ion, const string &name, TFlags flags) const
static bool MaybeSet(string &target, const string &value, TFlags flags)
bool EnvToReg(const string &env, string §ion, string &name) const
The return value indicates whether the environment variable was appropriately formatted.
bool x_HasEntry(const string §ion, const string &name, TFlags flags) const
const string & x_GetComment(const string §ion, const string &name, TFlags flags) const
bool x_Empty(TFlags flags) const
Implementations of the fundamental operations above, to be run with the lock already acquired and som...
TPriorityMap m_PriorityMap
bool x_HasSection(const string §ion, TFlags flags) const
int TPriority
Not restricted to ePriority_*.
string GetPrefix(void) const
Can be overriden to speed enumeration.
void x_ChildLockAction(FLockAction action)
bool x_Set(const string §ion, const string &name, const string &value, TFlags flags, const string &comment)
void x_SetModifiedFlag(bool modified, TFlags flags)
bool x_Modified(TFlags flags) const
string RegToEnv(const string §ion, const string &name) const
Returns empty strings for unsupported (section, name) pairs.
void x_Enumerate(const string §ion, list< string > &entries, TFlags flags) const
bool m_Modified
only tracks mods made through this.
static bool IsNameEntry(const string &str, TFlags flags)
void AddMapper(const IEnvRegMapper &mapper, TPriority prio=ePriority_Default)
bool x_SetComment(const string &comment, const string §ion, const string &name, TFlags flags)
static bool IsNameSection(const string &str, TFlags flags)
Check if "str" consists of alphanumeric and '_' only Treat the case of set fSectionlessEntries separa...
bool EnvToReg(const string &env, string §ion, string &name) const
The return value indicates whether the environment variable was appropriately formatted.
CEnvironmentRegistry(TFlags flags=0)
Constructors.
@ fPersistent
Persistent â saved when file is written.
@ fInternalSpaces
Allow internal whitespace in names.
@ fSectionCase
Create with case-sensitive section names.
@ fTransient
Transient â not saved by default.
@ fInSectionComments
Indicates that we want in-section comments from x_Enumerate.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
NCBI_NS_STD::string::size_type SIZE_TYPE
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
ECase
Which type of string comparison.
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 & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static string & ToUpper(string &str)
Convert string to upper case â string& version.
size_type size(void) const
Return the length of the represented array.
@ eNocase
Case insensitive compare.
@ eCase
Case sensitive compare.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
bool Match(CTempString str, NStr::ECase use_case=NStr::eCase) const
Match a string.
void Add(const string &mask)
Add an inclusion mask.
Definition of all error codes used in corelib (xncbi.lib).
const GenericPointer< typename T::ValueType > T2 value
Classes to match a string against a set of masks.
Defines unified interface to application:
static const string kPattern("pattern")
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
static wxAcceleratorEntry entries[3]
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