Commit d8f29d6c authored by Pavel Vainerman's avatar Pavel Vainerman

minor refactoring: const string used when possible

parent 102c7dfd
......@@ -208,7 +208,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf);
ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : "";
const string name = ( optarg ) ? optarg : "";
return setValue(name, ui);
}
break;
......@@ -243,7 +243,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf);
ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : "";
const string name = ( optarg ) ? optarg : "";
return getValue(name, ui);
}
break;
......@@ -254,7 +254,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf);
ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : "";
const string name = ( optarg ) ? optarg : "";
return getRawValue(name, ui);
}
break;
......@@ -264,7 +264,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf);
ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : "";
const string name = ( optarg ) ? optarg : "";
return getTimeChange(name, ui);
}
break;
......@@ -310,7 +310,7 @@ int main(int argc, char** argv)
UInterface ui(conf);
ui.initBackId(uniset::AdminID);
std::string query = string(argv[optind]);
const std::string query = string(argv[optind]);
return apiRequest(optarg, ui, query);
}
......@@ -354,7 +354,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf);
ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : "";
const string name = ( optarg ) ? optarg : "";
return configure(name, ui);
}
break;
......@@ -384,7 +384,7 @@ int main(int argc, char** argv)
UInterface ui(conf);
ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : "";
const string name = ( optarg ) ? optarg : "";
return logRotate(name, ui);
}
break;
......@@ -395,7 +395,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf);
ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : "";
const string name = ( optarg ) ? optarg : "";
return getCalibrate(name, ui);
}
break;
......@@ -428,7 +428,7 @@ int main(int argc, char** argv)
}
int mtype = uni_atoi(argv[optind]);
std::string consumers(optarg);
const std::string consumers(optarg);
ostringstream txt;
if( checkArg(optind + 1, argc, argv) == 0 )
......
......@@ -385,7 +385,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
if( it == flist.end() )
return ModbusRTU::erBadDataValue;
std::string fname(it->second);
const std::string fname(it->second);
int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK );
......
......@@ -363,7 +363,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
if( it == flist.end() )
return ModbusRTU::erBadDataValue;
std::string fname(it->second);
const std::string fname(it->second);
int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK );
......
......@@ -257,15 +257,15 @@ int main( int argc, char** argv )
{
if( (argv[optind + 1])[0] == 'b' )
{
string v(argv[optind + 1]);
string sb(v, 1);
const string v(argv[optind + 1]);
const string sb(v, 1);
ModbusRTU::DataBits d(sb);
val = d.mbyte();
}
else if( (argv[optind + 1])[0] == 'm' )
{
string v(argv[optind + 1]);
string sb(v, 1);
const string v(argv[optind + 1]);
const string sb(v, 1);
val = -1 * ModbusRTU::str2mbData(sb);
}
else
......
......@@ -253,23 +253,23 @@ int main( int argc, char** argv )
if( arg[0] == 'b' )
{
dval.type = 'i';
string v(arg);
string sb(v, 1);
const string v(arg);
const string sb(v, 1);
ModbusRTU::DataBits d(sb);
dval.d.v = d.mbyte();
}
else if( arg[0] == 'm' )
{
dval.type = 'i';
string v(arg);
string sb(v, 1);
const string v(arg);
const string sb(v, 1);
dval.d.v = -1 * ModbusRTU::str2mbData(sb);
}
else if( arg[0] == 'f' || arg[0] == 'r' )
{
dval.type = arg[0];
string v(arg);
string sb(v, 1);
const string v(arg);
const string sb(v, 1);
dval.d.f = atof(sb.c_str());
}
else
......
......@@ -67,10 +67,10 @@ int main(int argc, char** argv)
askfile = conf->getConfFileName();
// определяем фильтр
string s_field = conf->getArgParam("--s-filter-field");
string s_fvalue = conf->getArgParam("--s-filter-value");
string c_field = conf->getArgParam("--c-filter-field");
string c_fvalue = conf->getArgParam("--c-filter-value");
const string s_field = conf->getArgParam("--s-filter-field");
const string s_fvalue = conf->getArgParam("--s-filter-value");
const string c_field = conf->getArgParam("--c-filter-field");
const string c_fvalue = conf->getArgParam("--c-filter-value");
// надо ли писать изменения в БД
bool dbDumping = conf->getArgInt("--dbDumping");
......
......@@ -42,7 +42,7 @@ int main( int argc, char** argv )
auto conf = uniset_init(argc, argv, "configure.xml" );
UInterface ui(conf);
string sid(conf->getArgParam("--sid"));
const string sid(conf->getArgParam("--sid"));
if( sid.empty() )
{
......
......@@ -26,7 +26,7 @@ int main( int argc, const char** argv )
auto conf = uniset_init(argc, argv, "configure.xml");
ObjectId ID(DefaultObjectId);
string name = conf->getArgParam("--name", "TestProc");
const string name = conf->getArgParam("--name", "TestProc");
ID = conf->getObjectID(name);
......
......@@ -63,7 +63,7 @@ void ComPort::openPort()
if( fd == -1 )
{
string strErr = "Unable to open " + dev + " [Error: " + strerror(errno) + "]";
const string strErr = "Unable to open " + dev + " [Error: " + strerror(errno) + "]";
throw uniset::SystemError(strErr.c_str());
}
......
......@@ -285,7 +285,7 @@ namespace uniset
transientIOR = false;
localIOR = false;
string lnode( getArgParam("--localNode") );
const string lnode( getArgParam("--localNode") );
if( !lnode.empty() )
setLocalNode(lnode);
......@@ -321,7 +321,7 @@ namespace uniset
{
for(; omniIt.getCurrent(); omniIt++ )
{
std::string p(omniIt.getProp("name"));
const std::string p(omniIt.getProp("name"));
if( p.empty() )
{
......@@ -431,7 +431,7 @@ namespace uniset
// "где мы выделяли, а где не мы"
// делать delete[]
omni_options[i][0] = uni_strdup("InitRef");
string defPort( getPort( getProp(nsnode, "port") ) );
const string defPort( getPort( getProp(nsnode, "port") ) );
ostringstream param;
param << this << "NameService=corbaname::" << getProp(nsnode, "host") << ":" << defPort;
......@@ -565,7 +565,7 @@ namespace uniset
{
if( localNode == uniset::DefaultObjectId )
{
string nodename( it.getProp("name") );
const string nodename( it.getProp("name") );
setLocalNode(nodename);
}
}
......@@ -573,7 +573,7 @@ namespace uniset
{
name = it.getProp("name");
//DBServer
string secDB( getServicesSection() + "/" + name);
const string secDB( getServicesSection() + "/" + name);
localDBServer = oind->getIdByName(secDB);
if( localDBServer == DefaultObjectId )
......@@ -1024,7 +1024,7 @@ namespace uniset
string add_level("--" + debname + "-add-levels");
string del_level("--" + debname + "-del-levels");
string show_msec("--" + debname + "-show-milliseconds");
string show_usec("--" + debname + "-show-microseconds");
const string show_usec("--" + debname + "-show-microseconds");
// смотрим командную строку
for (int i = 1; i < (_argc - 1); i++)
......@@ -1149,7 +1149,7 @@ namespace uniset
// Определение конфигурационного файла
// в порядке убывания приоритета
string tmp( getArgParam("--confile") );
const string tmp( getArgParam("--confile") );
if( !tmp.empty() )
{
......@@ -1461,7 +1461,7 @@ namespace uniset
// atexit( UniSetActivator::normalexit );
// set_terminate( UniSetActivator::normalterminate ); // ловушка для неизвестных исключений
string confile = uniset::getArgParam( "--confile", argc, argv, xmlfile );
const string confile = uniset::getArgParam( "--confile", argc, argv, xmlfile );
uniset::uconf = make_shared<Configuration>(argc, argv, confile);
return uniset::uconf;
......
......@@ -958,7 +958,7 @@ namespace uniset
{
ostringstream s;
s << uconf << oind->getNodeName(node);
string nodeName(s.str());
const string nodeName(s.str());
if( CORBA::is_nil(orb) )
{
......
......@@ -264,7 +264,7 @@ std::vector<std::string> uniset::explode_str( const std::string& str, char sep )
if( pos == string::npos )
{
string s(str.substr(prev, sz - prev));
const string s(str.substr(prev, sz - prev));
if( !s.empty() )
v.emplace_back( std::move(s) );
......@@ -278,7 +278,7 @@ std::vector<std::string> uniset::explode_str( const std::string& str, char sep )
continue;
}
string s(str.substr(prev, pos - prev));
const string s(str.substr(prev, pos - prev));
if( !s.empty() )
{
......@@ -340,7 +340,7 @@ std::list<uniset::ParamSInfo> uniset::getSInfoList( const string& str, std::shar
if( t.size() == 1 )
{
std::string s_id = *(t.begin());
const std::string s_id = *(t.begin());
if( is_digit(s_id) || !conf )
item.si.id = uni_atoi(s_id);
......@@ -351,8 +351,8 @@ std::list<uniset::ParamSInfo> uniset::getSInfoList( const string& str, std::shar
}
else if( t.size() == 2 )
{
std::string s_id = *(t.begin());
std::string s_node = *(++t.begin());
const std::string s_id = *(t.begin());
const std::string s_node = *(++t.begin());
if( is_digit(s_id) || !conf )
item.si.id = uni_atoi(s_id);
......@@ -393,7 +393,7 @@ std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std::
if( t.size() == 1 )
{
std::string s_id(*(t.begin()));
const std::string s_id(*(t.begin()));
if( is_digit(s_id) )
item.id = uni_atoi(s_id);
......@@ -412,8 +412,8 @@ std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std::
}
else if( t.size() == 2 )
{
std::string s_id = *(t.begin());
std::string s_node = *(++t.begin());
const std::string s_id = *(t.begin());
const std::string s_node = *(++t.begin());
if( is_digit(s_id) )
item.id = uni_atoi(s_id);
......
......@@ -205,7 +205,7 @@ namespace uniset
ostringstream s;
s << setw(tab_width) << "." << g_tab;
string s_tab(s.str());
const string s_tab(s.str());
uniset::ios_fmt_restorer ifs(os);
......
......@@ -399,7 +399,7 @@ void LogReader::readlogs( const std::string& _addr, int _port, LogServerTypes::C
line << endl;
std::string s(line.str());
const std::string s(line.str());
if( std::regex_search(s, rule) )
outlog->any(false) << s;
......
......@@ -165,14 +165,14 @@ namespace uniset
{
auto c = v[i];
string arg1 = checkArg(i + 1, v);
const string arg1 = checkArg(i + 1, v);
if( arg1.empty() )
continue;
i++;
std::string filter = checkArg(i + 2, v);
const std::string filter = checkArg(i + 2, v);
if( !filter.empty() )
i++;
......
......@@ -425,7 +425,7 @@ namespace uniset
if( mylog.is_info() )
mylog.info() << peername << "(LogSession::readEvent): receive command: '" << (LogServerTypes::Command)msg.cmd << "'" << endl;
string cmdLogName(msg.logname);
const string cmdLogName(msg.logname);
try
{
......@@ -570,7 +570,7 @@ namespace uniset
try
{
std::string ret( m_command_sig.emit(this, LogServerTypes::Command(msg.cmd), cmdLogName) );
const std::string ret( m_command_sig.emit(this, LogServerTypes::Command(msg.cmd), cmdLogName) );
if( !ret.empty() )
{
......
......@@ -38,7 +38,7 @@ IORFile::~IORFile()
// -----------------------------------------------------------------------------------------
string IORFile::getIOR( const ObjectId id )
{
string fname( getFileName(id) );
const string fname( getFileName(id) );
ifstream ior_file(fname.c_str());
string sior;
ior_file >> sior;
......@@ -48,7 +48,7 @@ string IORFile::getIOR( const ObjectId id )
// -----------------------------------------------------------------------------------------
void IORFile::setIOR( const ObjectId id, const string& sior )
{
string fname( getFileName(id) );
const string fname( getFileName(id) );
ofstream ior_file(fname.c_str(), ios::out | ios::trunc);
if( !ior_file )
......@@ -60,7 +60,7 @@ void IORFile::setIOR( const ObjectId id, const string& sior )
// -----------------------------------------------------------------------------------------
void IORFile::unlinkIOR( const ObjectId id )
{
string fname( getFileName(id) );
const string fname( getFileName(id) );
unlink(fname.c_str());
}
// -----------------------------------------------------------------------------------------
......
......@@ -143,7 +143,7 @@ namespace uniset
if (CORBA::is_nil(initServ))
{
string err("ORepHelpers: fail resolve_initial_references '" + nsName + "'");
const string err("ORepHelpers: fail resolve_initial_references '" + nsName + "'");
throw ORepFailed(err.c_str());
}
......@@ -151,7 +151,7 @@ namespace uniset
if (CORBA::is_nil(rootContext))
{
string err("ORepHelpers: Не удалось преобразовать ссылку к нужному типу.");
const string err("ORepHelpers: Не удалось преобразовать ссылку к нужному типу.");
throw ORepFailed(err.c_str());
}
......@@ -172,12 +172,12 @@ namespace uniset
}
catch( const omniORB::fatalException& )
{
string err("ORepHelpers(getRootNamingContext): Caught Fatal Exception");
const string err("ORepHelpers(getRootNamingContext): Caught Fatal Exception");
throw ORepFailed(err);
}
catch (...)
{
string err("ORepHelpers(getRootNamingContext): Caught a system exception while resolving the naming service.");
const string err("ORepHelpers(getRootNamingContext): Caught a system exception while resolving the naming service.");
throw ORepFailed(err);
}
......
......@@ -141,7 +141,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
}
catch( const ORepFailed& ex )
{
string er("ObjectRepository(registration): (getContext) не смог зарегистрировать " + name);
const string er("ObjectRepository(registration): (getContext) не смог зарегистрировать " + name);
throw ORepFailed(er);
}
catch( const CosNaming::NamingContext::NotFound& )
......@@ -185,8 +185,8 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
void ObjectRepository::registration( const std::string& fullName, const uniset::ObjectPtr oRef, bool force ) const
{
// string n(ORepHelpers::getShortName(fullName));
string n( uconf->oind->getBaseName(fullName) );
string s(ORepHelpers::getSectionName(fullName));
const string n( uconf->oind->getBaseName(fullName) );
const string s(ORepHelpers::getSectionName(fullName));
registration(n, oRef, s, force);
}
// --------------------------------------------------------------------------
......@@ -241,8 +241,8 @@ void ObjectRepository::unregistration( const string& name, const string& section
void ObjectRepository::unregistration(const string& fullName) const
{
// string n(ORepHelpers::getShortName(fullName));
string n(uconf->oind->getBaseName(fullName));
string s(ORepHelpers::getSectionName(fullName));
const string n(uconf->oind->getBaseName(fullName));
const string s(ORepHelpers::getSectionName(fullName));
unregistration(n, s);
}
// --------------------------------------------------------------------------
......@@ -477,8 +477,8 @@ bool ObjectRepository::createSection(const string& name, const string& in_sectio
*/
bool ObjectRepository::createSectionF( const string& fullName ) const
{
string name(ObjectIndex::getBaseName(fullName));
string sec(ORepHelpers::getSectionName(fullName));
const string name(ObjectIndex::getBaseName(fullName));
const string sec(ORepHelpers::getSectionName(fullName));
ulogrep << name << endl;
ulogrep << sec << endl;
......@@ -636,7 +636,7 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c
if( recursive )
{
ulogrep << "ORepFactory: удаляем рекурсивно..." << endl;
string rctx = fullName + "/" + omniURI::nameToString(bl[i].binding_name);
const string rctx = fullName + "/" + omniURI::nameToString(bl[i].binding_name);
ulogrep << rctx << endl;
if ( !removeSection(rctx))
......@@ -659,9 +659,9 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c
if( rem )
{
// Получаем имя контекста содержащего удаляемый
string in_sec(ORepHelpers::getSectionName(fullName));
const string in_sec(ORepHelpers::getSectionName(fullName));
//Получаем имя удаляемого контекста
string name(ObjectIndex::getBaseName(fullName));
const string name(ObjectIndex::getBaseName(fullName));
try
{
......@@ -698,12 +698,12 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c
*/
bool ObjectRepository::renameSection( const string& newFName, const string& oldFName ) const
{
string newName(ObjectIndex::getBaseName(newFName));
string oldName(ObjectIndex::getBaseName(oldFName));
const string newName(ObjectIndex::getBaseName(newFName));
const string oldName(ObjectIndex::getBaseName(oldFName));
CosNaming::Name_var ctxNewName = omniURI::stringToName(newName.c_str());
CosNaming::Name_var ctxOldName = omniURI::stringToName(oldName.c_str());
string in_sec(ORepHelpers::getSectionName(newFName));
const string in_sec(ORepHelpers::getSectionName(newFName));
try
{
......
......@@ -115,7 +115,7 @@ namespace uniset
bool IOConfig_XML::getBaseInfo( xmlNode* node, IOController_i::SensorInfo& si ) const
{
UniXML::iterator it(node);
string sname( it.getProp("name"));
const string sname( it.getProp("name"));
if( sname.empty() )
{
......@@ -126,7 +126,7 @@ namespace uniset
// преобразуем в полное имя
ObjectId sid = uniset::DefaultObjectId;
string id(it.getProp("id"));
const string id(it.getProp("id"));
if( !id.empty() )
sid = uni_atoi( id );
......@@ -142,7 +142,7 @@ namespace uniset
}
ObjectId snode = conf->getLocalNode();
string snodename(it.getProp("node"));
const string snodename(it.getProp("node"));
if( !snodename.empty() )
snode = conf->getNodeID(snodename);
......@@ -167,7 +167,7 @@ namespace uniset
UniXML::iterator it(node);
inf->priority = Message::Medium;
string prior(it.getProp("priority"));
const string prior(it.getProp("priority"));
if( prior == "Low" )
inf->priority = Message::Low;
......@@ -216,7 +216,7 @@ namespace uniset
if( !it.getProp("undefined_value").empty() )
inf->undef_value = it.getIntProp("undefined_value");
string d_txt( it.getProp("depend") );
const string d_txt( it.getProp("depend") );
if( !d_txt.empty() )
{
......@@ -392,7 +392,7 @@ namespace uniset
{
UniXML::iterator uit(node);
string sid_name = uit.getProp("sid");
const string sid_name = uit.getProp("sid");
if( !sid_name.empty() )
{
......@@ -480,7 +480,7 @@ namespace uniset
return false;
}
string otype(it.getProp("type"));
const string otype(it.getProp("type"));
if( otype == "controllers" )
cname = uniset_conf()->getControllersSection() + "/" + cname;
......@@ -504,7 +504,7 @@ namespace uniset
return false;
}
string cnodename(it.getProp("node"));
const string cnodename(it.getProp("node"));
if( !cnodename.empty() )
cnode = uniset_conf()->oind->getIdByName(cnodename);
......
......@@ -370,7 +370,7 @@ SimpleInfo* IONotifyController::getInfo( const char* userparam )
//! \todo Назвать параметры нормально
//!
std::string param(userparam);
const std::string param(userparam);
ostringstream inf;
......
......@@ -38,7 +38,7 @@ PassiveObject::PassiveObject( uniset::ObjectId id ):
mngr(0),
id(id)
{
string myfullname = uniset_conf()->oind->getNameById(id);
const string myfullname = uniset_conf()->oind->getNameById(id);
myname = ORepHelpers::getShortName(myfullname);
}
......@@ -46,7 +46,7 @@ PassiveObject::PassiveObject( ObjectId id, ProxyManager* mngr ):
mngr(mngr),
id(id)
{
string myfullname = uniset_conf()->oind->getNameById(id);
const string myfullname = uniset_conf()->oind->getNameById(id);
myname = ORepHelpers::getShortName(myfullname);
if( mngr )
......
......@@ -35,7 +35,7 @@ SMonitor::SMonitor(ObjectId id):
UniSetObject(id),
script("")
{
string sid(uniset_conf()->getArgParam("--sid"));
const string sid(uniset_conf()->getArgParam("--sid"));
lst = uniset::getSInfoList(sid, uniset_conf());
......
......@@ -103,7 +103,7 @@ void SViewer::readSection( const string& section, const string& secRoot )
}
else
{
string secName(curSection);
const string secName(curSection);
ListObjectName lstObj;
ListObjectName::const_iterator li;
......@@ -132,8 +132,8 @@ void SViewer::readSection( const string& section, const string& secRoot )
{
try
{
string ob(*li);
string fname(curSection + "/" + ob);
const string ob(*li);
const string fname(curSection + "/" + ob);
ObjectId id = uniset_conf()->oind->getIdByName( fname );
if( id == DefaultObjectId )
......@@ -203,7 +203,7 @@ void SViewer::getInfo( ObjectId id )
// ---------------------------------------------------------------------------
void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::ObjectId oid )
{
string owner = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid));
const string owner = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid));
cout << "\n======================================================\n"
<< ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid))
<< "\t Датчики"
......@@ -225,7 +225,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::Ob
if( amap[i].supplier == uniset::AdminID )
supplier = "uniset-admin";
string txtname( uniset_conf()->oind->getTextName(amap[i].si.id) );
const string txtname( uniset_conf()->oind->getTextName(amap[i].si.id) );
printInfo( amap[i].si.id, name, amap[i].value, supplier, txtname, (amap[i].type == UniversalIO::AI ? "AI" : "DI") );
}
}
......@@ -250,7 +250,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::Ob
if( amap[i].supplier == uniset::AdminID )
supplier = "uniset-admin";
string txtname( uniset_conf()->oind->getTextName(amap[i].si.id) );
const string txtname( uniset_conf()->oind->getTextName(amap[i].si.id) );
printInfo( amap[i].si.id, name, amap[i].value, supplier, txtname, (amap[i].type == UniversalIO::AO ? "AO" : "DO"));
}
}
......@@ -262,7 +262,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::Ob
void SViewer::updateThresholds( IONotifyController_i::ThresholdsListSeq_var& tlst, uniset::ObjectId oid )
{
int size = tlst->length();
string owner = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid));
const string owner = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid));
cout << "\n======================================================\n" << owner;
cout << "\t Пороговые датчики";
cout << "\n------------------------------------------------------" << endl;
......
......@@ -144,7 +144,7 @@ string UniXML::getProp2(const xmlNode* node, const string& name, const string& d
// формально при конструировании строки может быть exception
try
{
string s(getProp(node, name));
const string s(getProp(node, name));
if( !s.empty() )
return s;
......@@ -184,7 +184,7 @@ int UniXML::getIntProp(const xmlNode* node, const string& name ) noexcept
// -----------------------------------------------------------------------------
int UniXML::getPIntProp(const xmlNode* node, const string& name, int def ) noexcept
{
string param( getProp(node, name) );
const string param( getProp(node, name) );
if( param.empty() )
return def;
......@@ -288,7 +288,7 @@ bool UniXML::save( const string& filename, int level )
fn = this->filename;
// Если файл уже существует, переименовываем его в *.xml.bak
string bakfilename(fn + ".bak");
const string bakfilename(fn + ".bak");
(void)rename(fn.c_str(), bakfilename.c_str());
// int res = ::xmlSaveFormatFileEnc(fn.c_str(), doc, ExternalEncoding.c_str(), level);
// Write in UTF-8 without XML encoding in the header */
......@@ -584,7 +584,7 @@ int UniXML_iterator::getIntProp( const string& name ) const noexcept
int UniXML_iterator::getPIntProp( const string& name, int def ) const noexcept
{
string param( getProp(name) );
const string param( getProp(name) );
if( param.empty() )
return def;
......
......@@ -12,7 +12,7 @@ TEST_CASE("UInterface", "[UInterface]")
auto conf = uniset_conf();
CHECK( conf != nullptr );
std::string sidName("Input1_S");
const std::string sidName("Input1_S");
ObjectId testOID = conf->getObjectID("TestProc");
CHECK( testOID != DefaultObjectId );
......@@ -63,7 +63,7 @@ TEST_CASE("UInterface", "[UInterface]")
CHECK_FALSE( ui.waitWorking(sid, -1, 50) );
CHECK_FALSE( ui.waitWorking(sid, 100, -1) );
std::string longName("UNISET_PLC/Sensors/" + sidName);
const std::string longName("UNISET_PLC/Sensors/" + sidName);
CHECK( ui.getIdByName(longName) == sid );
CHECK( ui.getNameById(sid) == longName );
CHECK( ui.getTextName(sid) == "Команда 1" );
......
......@@ -94,7 +94,7 @@ class MyClass2
}
protected:
std::string nm;
const std::string nm;
TCPCheck tcp;
void thread()
......
......@@ -132,7 +132,7 @@ long UModbus::mbread(int mbaddr, int mbreg, int mbfunc, const string& s_vtype, i
using namespace uniset;
using namespace uniset::VTypes;
string n_ip( ( new_ip.empty() ? ip : new_ip ) );
const string n_ip( ( new_ip.empty() ? ip : new_ip ) );
int n_port = ( new_port > 0 ) ? new_port : port;
connect(n_ip, n_port);
......@@ -293,7 +293,7 @@ long UModbus::data2value( uniset::VTypes::VType vtype, uniset::ModbusRTU::Modbus
//---------------------------------------------------------------------------
void UModbus::mbwrite( int mbaddr, int mbreg, int val, int mbfunc, const std::string& new_ip, int new_port )throw(UException)
{
std::string n_ip( ( new_ip.empty() ? ip : new_ip ) );
const std::string n_ip( ( new_ip.empty() ? ip : new_ip ) );
int n_port = ( new_port > 0 ) ? new_port : port;
connect(n_ip, n_port);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment