本文整理汇总了C++中TCfg::keyUse方法的典型用法代码示例。如果您正苦于以下问题:C++ TCfg::keyUse方法的具体用法?C++ TCfg::keyUse怎么用?C++ TCfg::keyUse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCfg
的用法示例。
在下文中一共展示了TCfg::keyUse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fieldSeek
bool MTable::fieldSeek( int row, TConfig &cfg, vector< vector<string> > *full )
{
MtxAlloc resource(owner().connRes, true);
if(!owner().enableStat()) return false;
mLstUse = SYS->sysTm();
vector< vector<string> > inTbl,
&tbl = full ? *full : inTbl;
//Request
if(!full || !full->size() || row == 0) {
tbl.clear();
vector<string> row, cf_el;
// Request preparing
map<string,int> headers;
cfg.cfgList(cf_el);
char *attrs[cf_el.size()+1];
row.reserve(cf_el.size());
string fltr; int fltrN = 0;
for(unsigned iC = 0, iA = 0; iC < cf_el.size(); iC++) {
TCfg &cf = cfg.cfg(cf_el[iC]);
if(cf.isKey() && cf.keyUse()) { fltr += "("+cf_el[iC]+"="+getVal(cf)+")"; fltrN++; }
else if(cf.isKey() || cf.view()) {
headers[cf_el[iC]] = row.size();
row.push_back(cf_el[iC]);
attrs[iA++] = (char*)cf_el[iC].c_str(); attrs[iA] = NULL;
}
}
tbl.push_back(row);
if(fltrN > 1) fltr = "&"+fltr;
if(fltr.empty())fltr = "(objectclass=*)";
// Request
LDAPMessage *result, *entry;
if(ldap_search_s(owner().ldp,("ou="+name()+","+owner().bdn).c_str(),LDAP_SCOPE_ONE,fltr.c_str(),attrs,0,&result) != LDAP_SUCCESS) return false;
for(entry = ldap_first_entry(owner().ldp,result); entry; entry = ldap_next_entry(owner().ldp,entry)) {
row.clear(); row.resize(headers.size());
char *a, **vals;
BerElement *ber;
bool entrMatch = true;
for(a = ldap_first_attribute(owner().ldp,entry,&ber); a != NULL && entrMatch; a = ldap_next_attribute(owner().ldp,entry,ber)) {
string attr = a;
ldap_memfree(a);
string val;
if((vals=ldap_get_values(owner().ldp,entry,attr.c_str())) != NULL) {
for(int iV = 0; vals[iV] != NULL; iV++) val += vals[iV];
ldap_value_free(vals);
}
TCfg *cf = NULL; //cfg.at(attr, true);
for(unsigned iC = 0; iC < cf_el.size() && !cf; iC++)
if(strcasecmp(attr.c_str(),cf_el[iC].c_str()) == 0) { cf = cfg.at(cf_el[iC], true); attr = cf_el[iC]; }
if(cf) {
if(cf->isKey() && (val.empty() || (cf->keyUse() && getVal(*cf) != val))) entrMatch = false;
if(headers.find(attr) != headers.end()) row[headers[attr]] = val;
}
}
if(entrMatch) {
// Late checking for keys
for(unsigned iC = 0; iC < cf_el.size() && entrMatch; iC++) {
TCfg &cf = cfg.cfg(cf_el[iC]);
if(cf.isKey() && !cf.keyUse() && row[headers[cf_el[iC]]].empty()) entrMatch = false;
}
if(entrMatch) tbl.push_back(row);
}
}
ldap_msgfree(result);
}
if(tbl.size() < 2 || (full && (row+1) >= tbl.size())) return false;
//Processing of the query
row = full ? row+1 : 1;
for(unsigned iFld = 0; iFld < tbl[0].size(); iFld++) {
string sid = tbl[0][iFld];
TCfg *cf = cfg.at(sid, true);
if(cf) setVal(*cf, tbl[row][iFld]);
}
return true;
}