当前位置: 首页>>代码示例>>C++>>正文


C++ TConfig::noTransl方法代码示例

本文整理汇总了C++中TConfig::noTransl方法的典型用法代码示例。如果您正苦于以下问题:C++ TConfig::noTransl方法的具体用法?C++ TConfig::noTransl怎么用?C++ TConfig::noTransl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TConfig的用法示例。


在下文中一共展示了TConfig::noTransl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fieldSet

void MTable::fieldSet( TConfig &cfg )
{
    vector< vector<string> > tbl;

    if( tblStrct.empty() ) fieldFix(cfg);
    mLstUse = time(NULL);

    string sid, sval;
    bool isVarTextTransl = (!Mess->lang2CodeBase().empty() && !cfg.noTransl() && Mess->lang2Code() != Mess->lang2CodeBase());
    //> Get config fields list
    vector<string> cf_el;
    cfg.cfgList(cf_el);

    //> Check for translation present
    bool trPresent = isVarTextTransl, trDblDef = false;
    for( unsigned i_fld = 1; i_fld < tblStrct.size(); i_fld++ )
    {
	if( (trPresent || cfg.noTransl()) && (!isVarTextTransl || trDblDef) ) break;
	sid = tblStrct[i_fld][1];
	if( sid.size() > 3 )
	{
	    if( !trPresent && sid.substr(0,3) == (Mess->lang2Code()+"#") ) trPresent = true;
	    if( Mess->lang2Code() == Mess->lang2CodeBase() && !trDblDef && sid.compare(0,3,Mess->lang2CodeBase()+"#") == 0 ) trDblDef = true;
	}
    }
    if( trDblDef ) fieldFix(cfg);

    //> Get present fields list
    string req_where = "WHERE ";
    //>> Add key list to queue
    bool next = false;
    for( unsigned i_el = 0; i_el < cf_el.size(); i_el++ )
    {
	TCfg &u_cfg = cfg.cfg(cf_el[i_el]);
	if( !(u_cfg.fld().flg()&TCfg::Key) ) continue;
	req_where = req_where + (next?" AND \"":"\"") + mod->sqlReqCode(cf_el[i_el],'"') + "\"='" + mod->sqlReqCode(getVal(u_cfg)) + "' ";
	next = true;
    }

    //> Prepare query
    string req = "SELECT 1 FROM '" + mod->sqlReqCode(name()) + "' " + req_where + ";";
    try{ owner().sqlReq(req, &tbl, true); }
    catch(TError err)
    {
	if( (err.cod-100) == SQLITE_READONLY )	return;
	fieldFix(cfg); owner().sqlReq(req, NULL, true);
    }
    if( tbl.size() < 2 )
    {
	//> Add new record
	req = "INSERT INTO '" + mod->sqlReqCode(name()) + "' ";
	string ins_name, ins_value;
	next = false;
	for( unsigned i_el = 0; i_el < cf_el.size(); i_el++ )
	{
	    TCfg &u_cfg = cfg.cfg(cf_el[i_el]);
	    if( !(u_cfg.fld().flg()&TCfg::Key) && !u_cfg.view() ) continue;

	    bool isTransl = (u_cfg.fld().flg()&TCfg::TransltText && trPresent && !u_cfg.noTransl());
	    ins_name = ins_name + (next?",\"":"\"") + mod->sqlReqCode(cf_el[i_el],'"') + "\" " +
		(isTransl ? (",\"" + mod->sqlReqCode(Mess->lang2Code()+"#"+cf_el[i_el],'"') + "\" ") : "");
	    sval = getVal(u_cfg);
	    ins_value = ins_value + (next?",'":"'") + mod->sqlReqCode(sval) + "' " + 
		(isTransl ? (",'" + mod->sqlReqCode(sval) + "' ") : "");
	    next = true;
	}
	req = req + "("+ins_name+") VALUES ("+ins_value+")";
    }
    else
    {
	//> Update present record
	req = "UPDATE '" + mod->sqlReqCode(name()) + "' SET ";
	next = false;
	for( unsigned i_el = 0; i_el < cf_el.size(); i_el++ )
	{
	    TCfg &u_cfg = cfg.cfg(cf_el[i_el]);
	    if( u_cfg.fld().flg()&TCfg::Key || !u_cfg.view() ) continue;

	    bool isTransl = (u_cfg.fld().flg()&TCfg::TransltText && trPresent && !u_cfg.noTransl());
	    sid = isTransl ? (Mess->lang2Code()+"#"+cf_el[i_el]) : cf_el[i_el];
	    sval = getVal(u_cfg);
	    req = req + (next?",\"":"\"") + mod->sqlReqCode(sid,'"') + "\"='" + mod->sqlReqCode(sval) + "' ";
	    next = true;
	}
	req = req + req_where;
    }
    req += ";";

    //> Query
    try { owner().sqlReq(req, NULL, true); }
    catch(TError err)
    {
	if( (err.cod-100) == SQLITE_READONLY )	return;
	fieldFix(cfg); owner().sqlReq(req, NULL, true);
    }
}
开发者ID:careychow,项目名称:openscada,代码行数:96,代码来源:bd_sqlite.cpp


注:本文中的TConfig::noTransl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。