68 view.
m_Fields.push_back(section_obj);
83 const vector<string>& subsections)
const
91 vector<string>::const_reverse_iterator riter(subsections.end());
92 vector<string>::const_reverse_iterator rend(subsections.begin());
93 for (; riter != rend; ++riter) {
106 list< CConstRef<CUser_field> > fields;
113 fields.push_back(field);
126 return (field && field->GetData().IsInt()) ?
127 field->GetData().GetInt() : default_val;
132 return (field && field->GetData().IsReal()) ?
133 field->GetData().GetReal() : default_val;
138 return (field && field->GetData().IsBool()) ?
139 field->GetData().GetBool() : default_val;
144 return (field && field->GetData().IsStr()) ?
145 field->GetData().GetStr() : default_val;
153 if (field->GetData().IsInt()) {
154 val.push_back(field->GetData().GetInt());
156 else if (field->GetData().IsInts()) {
157 val = field->GetData().GetInts();
159 else if (field->GetData().IsFields()) {
162 if (
f.GetData().IsInt()) {
163 val.push_back(
f.GetData().GetInt());
165 else if (
f.GetData().IsInts()) {
167 f.GetData().GetInts().begin(),
168 f.GetData().GetInts().end());
179 if (field->GetData().IsReal()) {
180 val.push_back(field->GetData().GetReal());
182 else if (field->GetData().IsReals()) {
183 val = field->GetData().GetReals();
185 else if (field->GetData().IsFields()) {
188 if (
f.GetData().IsReal()) {
189 val.push_back(
f.GetData().GetReal());
191 else if (
f.GetData().IsReals()) {
193 f.GetData().GetReals().begin(),
194 f.GetData().GetReals().end());
205 if (field->GetData().IsStr()) {
206 val.push_back(field->GetData().GetStr());
208 else if (field->GetData().IsStrs()) {
210 field->GetData().GetStrs().begin(),
211 field->GetData().GetStrs().end());
213 else if (field->GetData().IsFields()) {
216 if (
f.GetData().IsStr()) {
217 val.push_back(
f.GetData().GetStr());
219 else if (
f.GetData().IsStrs()) {
221 f.GetData().GetStrs().begin(),
222 f.GetData().GetStrs().end());
296 if (!
info.key.empty()) {
301 key_info.push_back(
info);
330 TFields::const_reverse_iterator riter(
m_Fields.rbegin());
331 TFields::const_reverse_iterator rend(
m_Fields.rend());
333 for (; riter != rend; ++riter) {
342 key_map[key_it->key] = *key_it;
349 keys.push_back(iter->second);
374 if (fields.size() == 1)
375 return fields.front();
377 int merge_policy = 0;
383 if (
str ==
"append") {
386 else if (
str ==
"prepend") {
396 switch (merge_policy) {
404 field->
SetData().SetFields().push_back(
f);
412 std::reverse(fields.begin(), fields.end());
417 field->
SetData().SetFields().push_back(
f);
422 return fields.front();
431 ostr << keys.size() <<
" keys:" << endl;
435 ostr <<
key.key <<
"|";
439 vector<double> reals;
450 copy(ints.begin(), ints.end(), ostream_iterator<int>(ostr,
";"));
458 copy(reals.begin(), reals.end(), ostream_iterator<double>(ostr,
";"));
466 copy(strs.begin(), strs.end(), ostream_iterator<string>(ostr,
";"));
485 : m_Section(section), m_RegistryFile(®File)
518 "Too few components in key \"" +
key +
"\"");
587 v.reserve(
val.size());
CRef< objects::CUser_field > SetField(const string &key)
bool DeleteField(const string &key)
class CRegistryReadView provides a nested hierarchical view at a particular key.
int GetInt(const string &key, int default_val=0) const
access a named key at this level, with no recursion
double GetReal(const string &key, double default_val=0) const
bool GetBool(const string &key, bool default_val=false) const
void DumpAll(CNcbiOstream &ostr) const
Dump onto the stream all the keys in this view along with their types and data values.
void GetIntVec(const string &key, vector< int > &val) const
void x_GetKeys(TKeys &keys, bool recurse) const
implementing GetTopKeys and GetKeys.
list< SKeyInfo > TKeys
retrieve information about all keys in the registry
void GetTopKeys(TKeys &keys) const
Retrieve information about the top level keys in this view.
void GetRealVec(const string &key, vector< double > &val) const
bool HasField(const string &key) const
Does a field with this section and key exist in this view?
string GetString(const string &key, const string &default_val=kEmptyStr) const
void GetStringList(const string &key, list< string > &val) const
void GetStringVec(const string &key, vector< string > &val) const
CRegistryReadView GetReadView(const string §ion) const
list< CConstRef< objects::CUser_field > > TFields
ordered list of subfields to scan
void x_AppendToReadView(CRegistryReadView &view, const string §ion) const
CConstRef< objects::CUser_field > GetField(const string &key) const
provide raw field access
bool IsEmpty()
There is nothing in this view.
static CConstRef< objects::CUser_field > ResolveField(list< CConstRef< objects::CUser_field > > &fields, const objects::CUser_field *meta)
CRegistryReadView & operator+=(const CRegistryReadView &rhs)
void GetKeys(TKeys &keys) const
Retrieve information about all keys in this view.
CRegistryWriteView GetWriteView(const string §ion)
CRegistryFile * m_RegistryFile
CRef< objects::CUser_field > SetFieldToValue(const string &key)
same as SetField, but complain loudly if the field has subfields in it already.
CRef< objects::CUser_field > SetField(const string &key)
provide raw field access
void Set(const string &key, int val)
access a named key at this level, with no recursion
bool DeleteField(const string &key)
delete the specified field (and any of its subfields) from this view and from its registry.
CConstRef< CUser_field > GetFieldRef(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Return a field reference representing the tokenized key, or a NULL reference if the key doesn't exist...
bool HasField(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Verify that a named field exists.
static const char * str(char *buf, int n)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#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 Reset(void)
Reset reference object.
TObjectType * Release(void)
Release a reference to the object and return a pointer to the object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
static const string BoolToString(bool value)
Convert bool to string.
static string & ToLower(string &str)
Convert string to lower case – string& version.
const TStr & GetStr(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
const TFields & GetFields(void) const
Get the variant data.
vector< CRef< CUser_field > > TFields
bool IsFields(void) const
Check if variant Fields is selected.
bool IsStr(void) const
Check if variant Str is selected.
const TStr & GetStr(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
E_Choice Which(void) const
Which variant is currently selected.
const struct ncbi::grid::netcache::search::fields::KEY key
const struct ncbi::grid::netcache::search::fields::SUBKEY subkey
intr::rbtree< SNCCacheData, intr::base_hook< TKeyMapHook >, intr::constant_time_size< true >, intr::compare< SCacheKeyCompare > > TKeyMap
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
static const char * kEmptyViewError
static const string kDecimalDot
static void s_ExtractKeys(const CUser_field &field, const string &root, CRegistryReadView::TKeys &key_info, bool recurse)