35 fCurrItem(src.fCurrItem),
36 fCurrChld(src.fCurrChld),
37 fCurrStrict(src.fCurrStrict),
44 if (fCurrItem==0)
return false;
51 while (fCurrChld!=0) {
52 if (fCfg->IsNodeName(fCurrChld, name)) {
53 fCurrItem = fCurrChld;
66 if ((fCurrChld!=0) || (fCurrItem==0))
return false;
75 std::string sattr = attr ? fCfg->ResolveEnv(attr) : std::string(
"");
78 res = sattr.empty() ? false : (sattr == value);
81 res = (sattr == value);
82 if (!res) res = fnmatch(sattr.c_str(), value, FNM_NOESCAPE) == 0;
92 fCurrChld = fCurrItem;
106 if (lvl==0)
return obj;
108 while ((obj!=0) && (lvl-->0)) obj = obj->
GetParent();
114 if ((node==0) || (name==0) || (strlen(name)==0))
return node;
116 const char* pos = strchr(name,
'/');
117 if (pos==0)
return fCfg->FindChild(node, name);
119 std::string subname(name, pos-name);
120 return FindSubItem(fCfg->FindChild(node, subname.c_str()), pos+1);
125 if ((value==0) || (*value==0))
return std::string();
127 if ((strstr(value,
"${")==0) || (fCfg==0))
return std::string(value);
129 return fCfg->ResolveEnv(value, fCgfId);
138 if ((fCfg==0) || (obj==0))
return false;
142 while ((prnt = GetObjParent(obj, maxlevel)) != 0) {
149 if (prnt==0)
return false;
151 DOUT3(
"Start reading of obj %s item %s maxlevel %d", obj->
ItemName().c_str(), itemname.c_str(), maxlevel);
160 for (
int dcnt=0;dcnt<2;dcnt++) {
162 DOUT3(
"Switch to search mode %d", dcnt);
171 fCurrItem = fCfg->fSelected;
172 max_depth = maxlevel - 1;
176 fCurrItem = fCfg->RootNode();
177 max_depth = maxlevel;
180 default:
EOUT(
"INTERNAL ERROR");
break;
184 int level = max_depth;
188 prnt = (level==maxlevel) ?
dabc::mgr() : GetObjParent(obj, level);
190 DOUT3(
"Search with loop %d path level = %d obj = %s class %s", dcnt, level,
DNAME(prnt), (prnt ? prnt->
ClassName() :
"---"));
194 if (prnt == 0)
return false;
201 if (prnt->
Find(*
this)) {
202 DOUT3(
"Find parent of level:%d", level);
203 if (level-->0)
continue;
211 const char* attrvalue = 0;
212 if (itemnode!=0) attrvalue =
Xml::GetAttr(itemnode,
"value");
213 if (attrvalue==0) attrvalue =
Xml::GetAttr(fCurrItem, itemname.c_str());
216 field->
SetStr(ResolveEnv(attrvalue));
217 DOUT3(
"For item %s find value %s", itemname.c_str(), attrvalue);
221 std::vector<std::string> arr;
227 arr.push_back(ResolveEnv(arritemvalue));
236 if ((fieldsmap!=0) && (itemnode!=0)) {
242 if ((attrname==0) || (attrvalue==0))
continue;
245 fieldsmap->
Field(attrname).
SetStr(ResolveEnv(attrvalue));
254 if ((attrname==0) || (attrvalue==0))
continue;
257 fieldsmap->
Field(attrname).
SetStr(ResolveEnv(attrvalue));
263 if ((curr != fCurrItem) || (fCurrChld != 0)) {
264 EOUT(
"FIXME: should not happen");
265 EOUT(
"FIXME: problem in hierarchy search for %s lvl %d prnt %s", obj->
ItemName().c_str(), level, prnt->
GetName());
266 EOUT(
"fCurrChld %p curr %p fCurrItem %p", fCurrChld, curr, fCurrItem);
276 if (level > max_depth)
break;
278 fCurrChld = fCurrItem;
282 EOUT(
"FIXME: Wrong hierarchy search level = %d maxlevel = %d chld %p item %p dcnt = %d", level, maxlevel, fCurrChld, fCurrItem, dcnt);
Interface class between xml configuration and dabc objects.
bool FindItem(const char *name)
std::string ResolveEnv(const char *value)
bool ReadRecordField(Object *obj, const std::string &name, RecordField *field, RecordFieldsMap *fieldsmap)
XMLNodePointer_t FindSubItem(XMLNodePointer_t node, const char *name)
ConfigIO(Configuration *cfg, int id=-1)
bool CheckAttr(const char *name, const char *value)
Check if item, found by FindItem routine, has attribute with specified value.
static Object * GetObjParent(Object *obj, int lvl)
Full-functional class to reading configuration from xml files.
Base class for most of the DABC classes.
bool IsTopXmlLevel() const
Return true if object should be searched in the top level of the xml file, thread safe
std::string ItemName(bool compact=true) const
Produce string, which can be used as name argument in dabc::mgr.FindItem(name) call.
Object * GetParent() const
Returns pointer on parent object, thread safe
const char * GetName() const
Returns name of the object, thread safe
virtual const char * ClassName() const
Returns class name of the object instance.
virtual bool Find(ConfigIO &cfg)
Method to locate object in xml file.
bool SetStr(const std::string &v)
bool SetStrVect(const std::vector< std::string > &vect)
bool HasField(const std::string &name) const
RecordField & Field(const std::string &name)
Direct access to the fields.
bool HasAttr(XMLNodePointer_t xmlnode, const char *name)
XMLAttrPointer_t GetFirstAttr(XMLNodePointer_t xmlnode)
const char * GetAttrValue(XMLAttrPointer_t xmlattr)
XMLNodePointer_t GetNext(XMLNodePointer_t xmlnode)
XMLNodePointer_t GetParent(XMLNodePointer_t xmlnode)
const char * GetAttr(XMLNodePointer_t xmlnode, const char *name)
const char * GetNodeName(XMLNodePointer_t xmlnode)
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode)
const char * GetAttrName(XMLAttrPointer_t xmlattr)
XMLAttrPointer_t GetNextAttr(XMLAttrPointer_t xmlattr)