ProtoStream: comments, FIXMEs
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1315 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -32,7 +32,7 @@ ProtoIStream::ProtoIStream(std::istream *infile) : m_infile(infile)
|
||||
m_log.showTime(false);
|
||||
}
|
||||
|
||||
void ProtoIStream:: reset()
|
||||
void ProtoIStream::reset()
|
||||
{
|
||||
m_infile->clear();
|
||||
m_infile->seekg(0,ios::beg);
|
||||
@ -45,11 +45,12 @@ bool ProtoIStream::getNext(google::protobuf::Message* m)
|
||||
return false;
|
||||
m_size = ntohl(m_size);
|
||||
|
||||
//FIXME: This could be inefficient because for each data buf is
|
||||
//allocated each time new
|
||||
// FIXME reuse buffer (efficiency)
|
||||
// FIXME new[] may fail (i.e., return 0)
|
||||
char *buf = new char[m_size];
|
||||
m_infile->read(buf, m_size);
|
||||
if (!m_infile->good())
|
||||
// FIXME we're leaking buf[]
|
||||
return false;
|
||||
std::string st(buf, m_size);
|
||||
m->ParseFromString(st);
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
/**
|
||||
* \class ProtoOStream
|
||||
*
|
||||
* This class can be used to write messages in a file.
|
||||
*
|
||||
* This class can be used to sequentially write a large number of protocol
|
||||
* buffer messages to a std::ostream.
|
||||
*/
|
||||
class ProtoOStream
|
||||
{
|
||||
@ -42,7 +42,7 @@ class ProtoOStream
|
||||
/**
|
||||
* Writes a message to a file.
|
||||
* @param m The protobuf-message to be written.
|
||||
* @return Returns true if data was written.
|
||||
* @return Returns true on success.
|
||||
*/
|
||||
bool writeMessage(google::protobuf::Message* m);
|
||||
};
|
||||
@ -51,8 +51,8 @@ class ProtoOStream
|
||||
/**
|
||||
* \class ProtoIStream
|
||||
*
|
||||
* This class can be used to read messages sequentially from a file.
|
||||
*
|
||||
* This class can be used to read protocol buffer messages sequentially from a
|
||||
* std::istream.
|
||||
*/
|
||||
class ProtoIStream
|
||||
{
|
||||
@ -69,14 +69,13 @@ class ProtoIStream
|
||||
virtual ~ProtoIStream() {};
|
||||
/**
|
||||
* Resets the position of the get pointer. After that getNext
|
||||
* delivers the first message again.
|
||||
* reads the first message again.
|
||||
*/
|
||||
void reset();
|
||||
/**
|
||||
* Delivers the protobuf-messages sequentially from file.
|
||||
* @param m The protobuf-message in which, the data should be
|
||||
* written.
|
||||
* @return Returns true if data was written to protobuf-message.
|
||||
* Reads the next protobuf message from the input stream.
|
||||
* @param m The output protobuf message.
|
||||
* @return Returns true on success.
|
||||
*/
|
||||
bool getNext(google::protobuf::Message* m);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user