本文整理汇总了C++中TCfg类的典型用法代码示例。如果您正苦于以下问题:C++ TCfg类的具体用法?C++ TCfg怎么用?C++ TCfg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TCfg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cfgChange
bool TMdPrm::cfgChange( TCfg &co, const TVariant &pc )
{
//Change TYPE parameter
if(co.name() == "TYPE") { setType(co.getS()); return true; }
if(mDA) mDA->cfgChange(co, pc);
if(!autoC()) modif();
return true;
}
示例2: setVal
void MTable::setVal( TCfg &cf, const string &val, bool tr )
{
if(!cf.dblVal()) {
cf.setS(val);
if(!tr && cf.fld().flg()&TCfg::TransltText && !cf.noTransl()) Mess->translReg(val, "db:"+fullDBName()+"#"+cf.name());
}
else cf.setS(val, (tr?TCfg::DblValTwo:TCfg::DblValOne));
}
示例3: cfgChange
bool TMdContr::cfgChange( TCfg &co, const TVariant &pc )
{
TController::cfgChange(co, pc);
if(startStat() && (co.name() == "CARD" || co.name() == "SMPL_RATE" || co.name() == "SMPL_TYPE")) stop();
return true;
}
示例4: fieldPrmSet
void MTable::fieldPrmSet( TCfg &e_cfg, db_str_rec &n_rec )
{
memset(&n_rec, 0, sizeof(db_str_rec));
strncpy(n_rec.name, e_cfg.name().c_str(), 10);
switch(e_cfg.fld().type())
{
case TFld::String:
n_rec.tip_fild = 'C';
n_rec.len_fild = vmin(255,e_cfg.fld().len());
n_rec.dec_field = 0;
break;
case TFld::Integer:
n_rec.tip_fild = 'N';
n_rec.len_fild = (e_cfg.fld().len() == 0) ? 5 : vmin(255,e_cfg.fld().len());
n_rec.dec_field = 0;
break;
case TFld::Real:
n_rec.tip_fild = 'N';
n_rec.len_fild = (e_cfg.fld().len() == 0) ? 7 : vmin(255,e_cfg.fld().len());
n_rec.dec_field = (e_cfg.fld().dec() == 0) ? 2 : vmin(255,e_cfg.fld().dec());
break;
case TFld::Boolean:
n_rec.tip_fild = 'L';
n_rec.len_fild = 1;
n_rec.dec_field = 0;
break;
default: break;
}
}
示例5: setVal
void MTable::setVal( TCfg &cfg, const string &val )
{
switch( cfg.fld().type() )
{
case TFld::String: cfg.setS(val); break;
case TFld::Integer: cfg.setI(atoi(val.c_str())); break;
case TFld::Real: cfg.setR(atof(val.c_str())); break;
case TFld::Boolean: cfg.setB(atoi(val.c_str())); break;
default: break;
}
}
示例6: getVal
string MTable::getVal( TCfg &cfg )
{
switch( cfg.fld().type() )
{
case TFld::String: return cfg.getS();
case TFld::Integer: return SYS->int2str(cfg.getI());
case TFld::Real: return SYS->real2str(cfg.getR());
case TFld::Boolean: return SYS->int2str(cfg.getB());
default: break;
}
return "";
}
示例7:
bool TCfg::operator==( TCfg &cfg )
{
if(fld().type() == cfg.fld().type())
switch(fld().type()) {
case TFld::String: return (getS() == cfg.getS());
case TFld::Integer: return (getI() == cfg.getI());
case TFld::Real: return (getR() == cfg.getR());
case TFld::Boolean: return (getB() == cfg.getB());
default: break;
}
return false;
}
示例8: cfgChange
bool TMdContr::cfgChange( TCfg &icfg )
{
TController::cfgChange(icfg);
try
{
if(icfg.name() == "EndPoint" && enableStat())
{
tr.at().setAddr("TCP:"+epParse());
ResAlloc res(nodeRes(), false);
SecuritySetting ss("", -1);
if(epLst.find(icfg.getS()) != epLst.end()) ss = epLst[icfg.getS()];
res.release();
if(ss.policy.size() && mSecPol.fld().values().find(ss.policy) != string::npos)
{
setSecPolicy(ss.policy);
setSecMessMode(ss.messageMode);
}
XML_N req("opc.tcp");
//> Send FindServers request for EndPoints list provide
req.setAttr("id", "FindServers");
reqService(req);
res.request(true);
epLst.clear();
for(unsigned i_s = 0; i_s < req.childSize(); i_s++)
for(unsigned i_d = 0; i_d < req.childGet(i_s)->childSize(); i_d++)
epLst[req.childGet(i_s)->childGet(i_d)->text()] = SecuritySetting();
res.release();
//> Send GetEndpoints request for EndPoints list provide
req.clear()->setAttr("id", "GetEndpoints");
reqService(req);
res.request(true);
for(unsigned i_ch = 0; i_ch < req.childSize(); i_ch++)
{
XML_N *xep = req.childGet(i_ch);
string ep = xep->attr("endpointUrl");
if(epLst.find(ep) != epLst.end()) ep += "/"+TSYS::strParse(xep->attr("securityPolicyUri"),1,"#")+"/"+xep->attr("securityMode");
epLst[ep] = SecuritySetting(TSYS::strParse(xep->attr("securityPolicyUri"),1,"#"), atoi(xep->attr("securityMode").c_str()));
}
}
else if(icfg.name() == "SecPolicy")
{
if(icfg.getS() == "None" && secMessMode() != MS_None) setSecMessMode(MS_None);
if(icfg.getS() != "None" && secMessMode() == MS_None) setSecMessMode(MS_Sign);
}
else if(icfg.name() == "SecMessMode" &&
((icfg.getI() != MS_None && secPolicy() == "None") || (icfg.getI() == MS_None && secPolicy() != "None")))
return false;
} catch(...) { }
return true;
}
示例9: setVal
void MTable::setVal( TCfg &cfg, const string &val )
{
switch(cfg.fld().type()) {
case TFld::String: {
//Remove spaces from end
int i;
for(i = val.size(); i > 0 && val[i-1] == ' '; i--) ;
cfg.setS(Mess->codeConvIn(codepage.c_str(),val.substr(0,i)));
break;
}
case TFld::Integer: cfg.setI(s2i(val)); break;
case TFld::Real: cfg.setR(s2r(val)); break;
case TFld::Boolean: cfg.setB(val.c_str()[0]=='T'); break;
default: break;
}
}
示例10: readFlg
void readFlg( TCfg& cfg, const char *name, int& flag ) throw (TException) {
const char *s;
//try {
s = cfg.getValue( name );
//} catch( TRequestExc &e ) {
// sprintf( msg, "в конфигурационном файле отсутствует параметр %s", name );
// logfile->error(msg);
// sprintf( msg, "сообщение класса:%s", e.text() );
// logfile->error(msg);
// throw;
//}
//sprintf( msg, "%s = %s", name, s );
//logfile->debug(msg);
if( s[0] == 0 || ( s[0] == '0' && s[1] == 0 ) ) {
flag = 0;
return;
}
if( s[0] == '1' && s[1] == 0 ) {
flag = 1;
return;
}
sprintf( msg, "Параметр %s должен быть 0, 1 или пустым. Его значение %s", name, s );
throw TException( 1, msg );
//logfile->error(msg);
//sprintf( msg, "Его значение %s", s );
//logfile->error(msg);
//return 1;
}
示例11: readInt
void readInt( TCfg& cfg, const char *name, int &val ) throw (TException) {
const char *s;
char *rest;
//try {
s = cfg.getValue( name );
//} catch( TRequestExc &e ) {
// sprintf( msg, "в конфигурационном файле отсутствует параметр %s", name );
// logfile->error(msg);
// sprintf( msg, "сообщение класса: %s", e.text() );
// logfile->error(msg);
// throw;
//}
//sprintf( msg, "%s = %s", name, s );
//logfile->debug(msg);
long a = strtol( s, &rest, 10 );
while( isspace(*rest) )
rest++;
if( *rest != 0 ) {
sprintf( msg, "Параметр %s должен быть целым числом. Его значение %s", name, s );
throw TException( 1, msg );
//logfile->error(msg);
//sprintf( msg, "его значение %s", s );
//logfile->error(msg);
//return 1;
}
val = a;
return;
}
示例12: getVal
string MTable::getVal( TCfg &cfg, uint8_t RqFlg )
{
string rez = cfg.getS(RqFlg);
if(rez == EVAL_STR) return "NULL";
if(cfg.fld().type() == TFld::String) {
if(Mess->translDyn() && (cfg.fld().flg()&TFld::TransltText)) rez = trL(rez, Mess->lang2Code());
string prntRes = rez;
bool isBin = false;
for(unsigned iCh = 0; !isBin && iCh < prntRes.size(); ++iCh)
switch(prntRes[iCh]) {
case 0: isBin = true; break;
case '\'': prntRes.insert(iCh, 1, prntRes[iCh]); ++iCh; break;
}
return isBin ? "X'"+TSYS::strDecode(rez, TSYS::Bin)+"'" : "'"+prntRes+"'";
}
return "'" + rez + "'";
}
示例13: at
TVariant TConfig::objFunc( const string &iid, vector<TVariant> &prms, const string &user )
{
// ElTp cfg(string nm) - config variable 'nm' get.
// nm - config variable name.
if(iid == "cfg" && prms.size() >= 1) {
TCfg *cf = at(prms[0].getS(), true);
if(!cf) return EVAL_REAL;
return *cf;
}
// ElTp cfgSet(string nm, ElTp val) - set config variable 'nm' to 'val'.
// nm - config variable name;
// val - variable value.
if(iid == "cfgSet" && prms.size() >= 2) {
TCfg *cf = at(prms[0].getS(), true);
if(!cf || (cf->fld().flg()&TFld::NoWrite)) return false;
*(TVariant*)cf = prms[1];
return true;
}
return TVariant();
}
示例14: at
TVariant TConfig::objFunc( const string &iid, vector<TVariant> &prms,
const string &user, int perm, const string &owner )
{
// ElTp cfg(string nm) - config variable 'nm' get.
// nm - config variable name.
if(iid == "cfg" && prms.size() >= 1 &&
SYS->security().at().access(user,SEC_RD,TSYS::strParse(owner,0,":"),TSYS::strParse(owner,1,":"),perm)) {
TCfg *cf = at(prms[0].getS(), true);
if(!cf) return EVAL_REAL;
return *cf;
}
// ElTp cfgSet(string nm, ElTp val) - set config variable 'nm' to 'val'.
// nm - config variable name;
// val - variable value.
if(iid == "cfgSet" && prms.size() >= 2 &&
SYS->security().at().access(user,SEC_WR,TSYS::strParse(owner,0,":"),TSYS::strParse(owner,1,":"),perm)) {
TCfg *cf = at(prms[0].getS(), true);
if(!cf || (cf->fld().flg()&TFld::NoWrite)) return false;
*(TVariant*)cf = prms[1];
return true;
}
return TVariant();
}
示例15: getVal
string MTable::getVal( TCfg &cfg, db_str_rec *fld_rec )
{
string rez;
switch(cfg.fld().type()) {
case TFld::Boolean: rez = cfg.getB() ? "T" : "F"; break;
case TFld::Integer: rez = i2s(cfg.getI()); break;
case TFld::Real: {
if(!fld_rec) { rez = r2s(cfg.getR()); break; }
char str[200];
snprintf(str, sizeof(str), "%*.*f", fld_rec->len_fild, fld_rec->dec_field, cfg.getR());
rez = str;
break;
}
default: rez = Mess->codeConvOut(codepage, cfg.getS()); break;
}
return rez;
}