Convert::getFullName becomes PVField::getFullName

Compatibility wrapper using current Convert API
Allow PVField::getFieldName to be inline'd
Avoid multiple resize and copy operations
on result String.
This commit is contained in:
Michael Davidsaver
2013-04-22 14:48:59 -04:00
parent 2f8c434429
commit 704007092c
4 changed files with 38 additions and 22 deletions

View File

@@ -64,11 +64,6 @@ void PVField::message(String message,MessageType messageType)
PVField::message(message,messageType,"");
}
String PVField::getFieldName() const
{
return fieldName;
}
void PVField::setRequester(RequesterPtr const &req)
{
if(parent!=NULL) {
@@ -223,6 +218,31 @@ namespace format
}
};
String PVField::getFullName() const
{
size_t size=fieldName.size();
for(PVField *fld=getParent(); fld; fld=fld->getParent())
{
size+=fld->fieldName.size()+1;
}
String ret(size, '.');
size_t pos=size - fieldName.size();
ret.replace(pos, String::npos, fieldName);
for(PVField *fld=getParent(); fld; fld=fld->getParent())
{
const String& nref = fld->fieldName;
assert(pos >= nref.size()+1);
pos -= nref.size()+1;
ret.replace(pos, String::npos, nref);
}
assert(pos==0);
return ret;
}
void PVField::computeOffset(const PVField * pvField) {
const PVStructure * pvTop = pvField->getParent();
if(pvTop==NULL) {