toString replaced with <<operator

This commit is contained in:
Matej Sekoranja
2014-06-20 08:38:54 +02:00
parent 8ce42ebb9a
commit 0447441cfa
2 changed files with 13 additions and 27 deletions

View File

@ -107,12 +107,12 @@ public:
* Get the name of the record.
* @return The name.
*/
std::string getRecordName();
std::string getRecordName() const;
/**
* Get the top level PVStructure.
* @return The shared pointer.
*/
PVRecordStructurePtr getPVRecordStructure();
PVRecordStructurePtr getPVRecordStructure() const;
/**
* Find the PVRecordField for the PVField.
* @param pvField The PVField.
@ -183,19 +183,6 @@ public:
* Ends a group of puts.
*/
void endGroupPut();
/**
* Calls the next method with indentLevel = 0.
* @param buf String Builder.
*/
// TODO
void toString(std::string* buf);
/**
* Dumps the data from the top level PVStructure.
* @param buf String Builder.
* @param indentLevel The indentation level.
*/
// TODO
void toString(std::string* buf,int indentLevel);
/**
* get trace level (0,1,2) means (nothing,lifetime,process)
* @return the level
@ -244,6 +231,8 @@ private:
bool isDestroyed;
};
epicsShareExtern std::ostream& operator<<(std::ostream& o, const PVRecord& record);
/**
* Interface for a field of a record.
* One exists for each field of the top level PVStructure.

View File

@ -103,9 +103,9 @@ void PVRecord::destroy()
}
}
string PVRecord::getRecordName() {return recordName;}
string PVRecord::getRecordName() const {return recordName;}
PVRecordStructurePtr PVRecord::getPVRecordStructure() {return pvRecordStructure;}
PVRecordStructurePtr PVRecord::getPVRecordStructure() const {return pvRecordStructure;}
PVStructurePtr PVRecord::getPVStructure() {return pvStructure;}
@ -346,17 +346,14 @@ void PVRecord::endGroupPut()
}
}
void PVRecord::toString(string* buf)
std::ostream& operator<<(std::ostream& o, const PVRecord& record)
{
toString(buf,0);
}
void PVRecord::toString(string* buf,int indentLevel)
{
std::ostringstream oss;
// TODO indent ignored
oss << endl << recordName << ' ' << *pvRecordStructure->getPVStructure();
*buf += oss.str();
o << format::indent() << "record " << record.getRecordName() << endl;
{
format::indent_scope s(o);
o << *record.getPVRecordStructure()->getPVStructure();
}
return o;
}
PVRecordField::PVRecordField(