Commit 1add5ffe authored by Pavel Vainerman's avatar Pavel Vainerman

Продолжение избавления от char*

parent 60139882
......@@ -379,7 +379,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository
try
{
ListObjectName ls;
rep->list(section.c_str(), &ls);
rep->list(section, &ls);
if( ls.empty() )
{
......@@ -401,7 +401,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository
{
string ob(*li);
buf = section + "/" + ob;
fullName = buf.c_str();
fullName = buf;
try
{
......
......@@ -143,11 +143,11 @@ namespace UniSetTypes
{
ObjectInfo():
id(DefaultObjectId),
repName(0), textName(0), data(0) {}
repName(""), textName(""), data(0) {}
ObjectId id; /*!< идентификатор */
char* repName; /*!< текстовое имя для регистрации в репозитории */
char* textName; /*!< текстовое имя */
std::string repName; /*!< текстовое имя для регистрации в репозитории */
std::string textName; /*!< текстовое имя */
void* data;
inline bool operator < ( const ObjectInfo& o ) const
......
......@@ -864,7 +864,7 @@ throw(ResolveNameError, UniSetTypes::TimeOut )
if( CORBA::is_nil(orb) )
orb = uconf->getORB();
ctx = ORepHelpers::getRootNamingContext( orb, nodeName.c_str() );
ctx = ORepHelpers::getRootNamingContext( orb, nodeName );
break;
}
// catch( const CORBA::COMM_FAILURE& ex )
......
......@@ -43,7 +43,7 @@ ObjectIndex_Array::ObjectIndex_Array( const ObjectInfo* objectInfo ):
{
for (numOfObject = 0;; numOfObject++)
{
if (!objectInfo[numOfObject].repName)
if( objectInfo[numOfObject].repName.empty() )
break;
assert (numOfObject == objectInfo[numOfObject].id);
......@@ -93,7 +93,7 @@ std::ostream& ObjectIndex_Array::printMap( std::ostream& os )
for( auto i = 0;; i++)
{
if( !objectInfo[i].repName )
if( objectInfo[i].repName.empty() )
break;
assert (i == objectInfo[i].id);
......
......@@ -48,11 +48,6 @@ ObjectIndex_XML::ObjectIndex_XML( const std::shared_ptr<UniXML>& xml, int minSiz
// -----------------------------------------------------------------------------------------
ObjectIndex_XML::~ObjectIndex_XML()
{
for( auto& it : omap )
{
delete[] it.repName;
delete[] it.textName;
}
}
// -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_XML::getIdByName( const string& name )
......@@ -92,7 +87,7 @@ std::ostream& ObjectIndex_XML::printMap( std::ostream& os )
for( auto it = omap.begin(); it != omap.end(); ++it )
{
if( it->repName == NULL )
if( it->repName.empty() )
continue;
os << setw(5) << it->id << " "
......@@ -186,9 +181,8 @@ unsigned int ObjectIndex_XML::read_section( const std::shared_ptr<UniXML>& xml,
// name
ostringstream n;
n << secname << xml->getProp(it, "name");
delete[] omap[ind].repName;
const string name(n.str());
omap[ind].repName = uni_strdup(name);
omap[ind].repName = name;
// mok
mok[name] = ind; // mok[omap[ind].repName] = ind;
......@@ -199,8 +193,7 @@ unsigned int ObjectIndex_XML::read_section( const std::shared_ptr<UniXML>& xml,
if( textname.empty() )
textname = xml->getProp(it, "name");
delete[] omap[ind].textName;
omap[ind].textName = uni_strdup(textname);
omap[ind].textName = textname;
omap[ind].data = (void*)(xmlNode*)it;
......@@ -255,8 +248,7 @@ unsigned int ObjectIndex_XML::read_nodes( const std::shared_ptr<UniXML>& xml, co
omap[ind].id = ind;
string nodename(xml->getProp(it, "name"));
delete[] omap[ind].repName;
omap[ind].repName = uni_strdup(nodename);
omap[ind].repName = nodename;
// textname
string textname(xml->getProp(it, "textname"));
......@@ -264,8 +256,7 @@ unsigned int ObjectIndex_XML::read_nodes( const std::shared_ptr<UniXML>& xml, co
if( textname.empty() )
textname = nodename;
delete[] omap[ind].textName;
omap[ind].textName = uni_strdup(textname);
omap[ind].textName = textname;
omap[ind].data = (void*)(xmlNode*)(it);
//
mok[omap[ind].repName] = ind;
......
......@@ -26,11 +26,6 @@ ObjectIndex_idXML::ObjectIndex_idXML( const shared_ptr<UniXML>& xml )
// -----------------------------------------------------------------------------------------
ObjectIndex_idXML::~ObjectIndex_idXML()
{
for( auto& it : omap )
{
delete[] it.second.repName;
delete[] it.second.textName;
}
}
// -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_idXML::getIdByName( const string& name )
......@@ -74,7 +69,7 @@ std::ostream& ObjectIndex_idXML::printMap( std::ostream& os )
for( auto it = omap.begin(); it != omap.end(); ++it )
{
if( it->second.repName == NULL )
if( it->second.repName.empty() )
continue;
os << setw(5) << it->second.id << " "
......@@ -158,14 +153,14 @@ void ObjectIndex_idXML::read_section( const std::shared_ptr<UniXML>& xml, const
ostringstream n;
n << secname << it.getProp("name");
const string name(n.str());
inf.repName = uni_strdup(name);
inf.repName = name;
string textname(xml->getProp(it, "textname"));
if( textname.empty() )
textname = xml->getProp(it, "name");
inf.textName = uni_strdup(textname);
inf.textName = textname;
inf.data = (void*)(xmlNode*)(it);
mok.emplace(name, inf.id);
......@@ -209,7 +204,7 @@ void ObjectIndex_idXML::read_nodes( const std::shared_ptr<UniXML>& xml, const st
}
string name(it.getProp("name"));
inf.repName = uni_strdup(name);
inf.repName = name;
// textname
string textname(xml->getProp(it, "textname"));
......@@ -217,7 +212,7 @@ void ObjectIndex_idXML::read_nodes( const std::shared_ptr<UniXML>& xml, const st
if( textname.empty() )
textname = name;
inf.textName = uni_strdup(textname);
inf.textName = textname;
inf.data = (void*)(xmlNode*)(it);
omap.emplace(inf.id, inf);
......
......@@ -42,7 +42,7 @@ PassiveObject::PassiveObject( UniSetTypes::ObjectId id ):
id(id)
{
string myfullname = uniset_conf()->oind->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str());
myname = ORepHelpers::getShortName(myfullname);
}
PassiveObject::PassiveObject( ObjectId id, ProxyManager* mngr ):
......@@ -50,7 +50,7 @@ PassiveObject::PassiveObject( ObjectId id, ProxyManager* mngr ):
id(id)
{
string myfullname = uniset_conf()->oind->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str());
myname = ORepHelpers::getShortName(myfullname);
if( mngr )
mngr->attachObject(this, id);
......
......@@ -85,8 +85,8 @@ UniSetObject::UniSetObject( ObjectId id ):
if (myid >= 0)
{
string myfullname = ui->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str());
section = ORepHelpers::getSectionName(myfullname.c_str());
myname = ORepHelpers::getShortName(myfullname);
section = ORepHelpers::getSectionName(myfullname);
}
else
{
......@@ -196,8 +196,8 @@ void UniSetObject::setID( UniSetTypes::ObjectId id )
throw ObjectNameAlready("ObjectId already set(setID)");
string myfullname = ui->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str());
section = ORepHelpers::getSectionName(myfullname.c_str());
myname = ORepHelpers::getShortName(myfullname);
section = ORepHelpers::getSectionName(myfullname);
myid = id;
ui->initBackId(myid);
}
......@@ -347,7 +347,7 @@ void UniSetObject::registered()
{
uwarn << myname << "(registered): unknown my manager" << endl;
string err(myname + ": unknown my manager");
throw ORepFailed(err.c_str());
throw ORepFailed(err);
}
{
......@@ -390,13 +390,13 @@ void UniSetObject::registered()
catch( ORepFailed )
{
string err(myname + ": don`t registration in object reposotory");
throw ORepFailed(err.c_str());
throw ORepFailed(err);
}
catch( const Exception& ex )
{
uwarn << myname << "(registered): " << ex << endl;
string err(myname + ": don`t registration in object reposotory");
throw ORepFailed(err.c_str());
throw ORepFailed(err);
}
regOK = true;
......@@ -741,7 +741,7 @@ bool UniSetObject::activate()
if( poa == NULL || CORBA::is_nil(poa) )
{
string err(myname + ": не задан менеджер");
throw ORepFailed(err.c_str());
throw ORepFailed(err);
}
if( uniset_conf()->isTransientIOR() )
......
......@@ -366,7 +366,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& ainf, bool forc
ostringstream err;
err << "(IOCOntroller::ioRegistration): КОНТРОЛЛЕРУ НЕ ЗАДАН ObjectId. Регистрация невозможна.";
uwarn << err.str() << endl;
throw ResolveNameError(err.str().c_str());
throw ResolveNameError(err.str());
}
{
......@@ -382,7 +382,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& ainf, bool forc
ostringstream err;
err << "Попытка повторной регистрации датчика(" << ainf->si.id << "). имя: "
<< uniset_conf()->oind->getNameById(ainf->si.id);
throw ObjectNameAlready(err.str().c_str());
throw ObjectNameAlready(err.str());
}
}
......
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