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:
@@ -421,21 +421,6 @@ Convert::Convert()
|
||||
|
||||
Convert::~Convert(){}
|
||||
|
||||
void Convert::getFullName(StringBuilder buf,PVFieldPtr const & pvField)
|
||||
{
|
||||
buf->empty();
|
||||
*buf += pvField->getFieldName();
|
||||
PVStructure *parent;
|
||||
while((parent=pvField->getParent())!=0) {
|
||||
parent = pvField->getParent();
|
||||
String name = parent->getFieldName();
|
||||
if(name.length()>0) {
|
||||
buf->insert(0,".");
|
||||
buf->insert(0,name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Convert::equals(PVFieldPtr const &a,PVFieldPtr const &b)
|
||||
{
|
||||
return convertEquals(a.get(),b.get());
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -77,7 +77,11 @@ public:
|
||||
* @param builder The builder that will have the result.
|
||||
* @param pvField The pvField.
|
||||
*/
|
||||
void getFullName(StringBuilder buf,PVFieldPtr const & pvField);
|
||||
void getFullName(StringBuilder buf,PVFieldPtr const & pvField)
|
||||
{
|
||||
*buf = pvField->getFullName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do fields have the same definition.
|
||||
*
|
||||
|
||||
@@ -244,7 +244,13 @@ public:
|
||||
* Get the fieldName for this field.
|
||||
* @return The name or empty string if top level field.
|
||||
*/
|
||||
String getFieldName() const ;
|
||||
inline const String& getFieldName() const {return fieldName;}
|
||||
/**
|
||||
* Fully expand the name of this field using the
|
||||
* names of its parent fields with a dot '.' seperating
|
||||
* each name.
|
||||
*/
|
||||
String getFullName() const;
|
||||
/**
|
||||
* Register the message requester.
|
||||
* At most one requester can be registered.
|
||||
@@ -343,6 +349,7 @@ public:
|
||||
*/
|
||||
virtual std::ostream& dumpValue(std::ostream& o) const = 0;
|
||||
|
||||
|
||||
protected:
|
||||
PVField::shared_pointer getPtrSelf()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user