80 _ASSERT(
key.find(delim + delim) == string::npos);
86 string first_key(
key);
88 string::size_type pos =
key.find_first_of(delim);
89 if (pos != string::npos) {
90 first_key =
key.substr(0, pos);
91 remainder =
key.substr(pos + 1,
key.length() - pos - 1);
97 if (
f.GetLabel().GetStr() == first_key) {
98 if (remainder.empty()) {
102 else if (
f.GetData().IsFields()) {
103 field_ref =
f.GetFieldRef(remainder, delim);
119 _ASSERT(
key.find(delim + delim) == string::npos);
125 string first_key(
key);
127 string::size_type pos =
key.find_first_of(delim);
128 if (pos != string::npos) {
129 first_key =
key.substr(0, pos);
130 remainder =
key.substr(pos + 1,
key.length() - pos - 1);
136 if (
f.GetLabel().GetStr() == first_key) {
137 if (remainder.empty()) {
142 field_ref =
f.SetFieldRef(remainder, delim);
153 field_ref->
SetLabel().SetStr(first_key);
154 obj.
SetData().push_back(field_ref);
156 if (!remainder.empty()) {
168 static string kMetaKey(
".meta");
172 list<string> meta_sections;
173 list<string> sections;
175 ITERATE (list<string>, iter, sections) {
176 string section(*iter);
177 string::size_type meta_pos = iter->find(kMetaKey);
178 if (meta_pos == iter->length() - kMetaKey.length()) {
180 string non_meta = section.erase(meta_pos);
182 meta_sections.push_back(section);
188 f->SetData().SetStr();
206 catch (std::exception&) {
214 catch (std::exception&) {
222 catch (std::exception&) {
229 ITERATE (list<string>, iter, meta_sections) {
240 string::size_type pos;
241 string section(*iter);
252 if (
type ==
"intvec") {
261 ITERATE (list<string>, it, toks) {
278 LOG_POST(
Error <<
"unexpected type in conversion to int-vec");
282 }
else if (
type ==
"realvec") {
291 ITERATE (list<string>, it, toks) {
308 LOG_POST(
Error <<
"unexpected type in conversion to int-vec");
312 }
else if (
type ==
"stringvec") {
321 ITERATE (list<string>, it, toks) {
337 LOG_POST(
Error <<
"unexpected type in conversion to string-vec");
356 string tag(field_tag);
357 if ( !
tag.empty() ) {
381 if ( !
str.empty() ) {
401 if ( !
str.empty() ) {
421 if ( !
str.empty() ) {
472 return obj ?
true :
false;
495 string first_key, remainder;
503 if (! parent_field) {
543 "Too few components in key \"" +
key +
"\"");
CConstRef< objects::CUser_field > GetField(const string &key) const
const objects::CUser_object & GetRegistry() const
CRegistryReadView GetReadView(const string §ion) const
CRef< objects::CUser_field > SetFieldToValue(const string &key)
void Read(CNcbiIstream &istr)
void ToConfigFile(CNcbiOstream &istr) const
CRef< objects::CUser_object > m_Registry
void FromConfigFile(CNcbiIstream &istr)
objects::CUser_object & SetRegistry()
CRef< objects::CUser_field > SetField(const string &key)
static bool IsRegistry(const objects::CUser_object &uo)
Is this user object suitable to use as a gui-registry site?
static CRef< objects::CUser_object > NewRegistryObject()
make a new user object suitable to use as a gui-registry site.
bool HasField(const string &key) const
void Write(CNcbiOstream &istr) const
bool DeleteField(const string &key)
CRegistryWriteView GetWriteView(const string §ion)
class CRegistryReadView provides a nested hierarchical view at a particular key.
CRef< CUser_field > SetFieldRef(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase)
Return a field reference representing the tokenized key, or a NULL reference if the key cannot be cre...
bool DeleteField(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase)
Delete the named field.
CUser_field & AddField(const string &label, int value)
add fields to the current user field
static const char * str(char *buf, int n)
#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 LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Warning(CExceptionArgs_Base &args)
#define MSerial_AsnText
I/O stream manipulators –.
void Reset(void)
Reset reference object.
void Reset(void)
Reset reference object.
virtual void EnumerateSections(list< string > *sections, TFlags flags=fAllLayers) const
Enumerate section names.
virtual const string & Get(const string §ion, const string &name, TFlags flags=0) const
Get the parameter value.
virtual void EnumerateEntries(const string §ion, list< string > *entries, TFlags flags=fAllLayers) const
Enumerate parameter names for a specified section.
bool Write(CNcbiOstream &os, TFlags flags=0) const
Write the registry content to output stream.
bool Set(const string §ion, const string &name, const string &value, TFlags flags=0, const string &comment=kEmptyStr)
Set the configuration parameter value.
@ fInternalSpaces
Allow internal whitespace in names.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
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 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 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 SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string.
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
const TStr & GetStr(void) const
Get the variant data.
const TStrs & GetStrs(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
TBool GetBool(void) const
Get the variant data.
bool IsFields(void) const
Check if variant Fields is selected.
bool IsStr(void) const
Check if variant Str is selected.
TData & SetData(void)
Assign a value to Data data member.
const TStr & GetStr(void) const
Get the variant data.
void SetLabel(TLabel &value)
Assign a value to Label data member.
TInt GetInt(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
const TObject & GetObject(void) const
Get the variant data.
TReal GetReal(void) const
Get the variant data.
const TReals & GetReals(void) const
Get the variant data.
void SetData(TData &value)
Assign a value to Data data member.
const TLabel & GetLabel(void) const
Get the Label member data.
vector< CStringUTF8 > TStrs
vector< CRef< CUser_field > > TData
E_Choice Which(void) const
Which variant is currently selected.
const TInts & GetInts(void) const
Get the variant data.
@ e_Object
for using other definitions
const struct ncbi::grid::netcache::search::fields::KEY key
Process information in the NCBI Registry, including working with configuration files.
static CRef< CUser_field > s_SetFieldAt(CUser_object &obj, const string &key, const string &delim)
recursively navigate an object tree, setting keys where necessary to get a named level
static const string kDecimalDot
static CConstRef< CUser_field > s_GetFieldAt(const CUser_object &obj, const string &key, const string &delim)
recursively navigate an object tree, retrieving an existing named key
static const string kConfigObjClass("NCBI")
static const string kConfigObjType("GUI-App-Registry")
static const string kMetaSuffix
static void s_ScanRecursive(const CUser_object &obj, CNcbiRegistry ®, const string &field_tag=kEmptyStr)
static wxAcceleratorEntry entries[3]