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);
|
m_log.showTime(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtoIStream:: reset()
|
void ProtoIStream::reset()
|
||||||
{
|
{
|
||||||
m_infile->clear();
|
m_infile->clear();
|
||||||
m_infile->seekg(0,ios::beg);
|
m_infile->seekg(0,ios::beg);
|
||||||
@ -45,11 +45,12 @@ bool ProtoIStream::getNext(google::protobuf::Message* m)
|
|||||||
return false;
|
return false;
|
||||||
m_size = ntohl(m_size);
|
m_size = ntohl(m_size);
|
||||||
|
|
||||||
//FIXME: This could be inefficient because for each data buf is
|
// FIXME reuse buffer (efficiency)
|
||||||
//allocated each time new
|
// FIXME new[] may fail (i.e., return 0)
|
||||||
char *buf = new char[m_size];
|
char *buf = new char[m_size];
|
||||||
m_infile->read(buf, m_size);
|
m_infile->read(buf, m_size);
|
||||||
if (!m_infile->good())
|
if (!m_infile->good())
|
||||||
|
// FIXME we're leaking buf[]
|
||||||
return false;
|
return false;
|
||||||
std::string st(buf, m_size);
|
std::string st(buf, m_size);
|
||||||
m->ParseFromString(st);
|
m->ParseFromString(st);
|
||||||
|
|||||||
@ -25,8 +25,8 @@
|
|||||||
/**
|
/**
|
||||||
* \class ProtoOStream
|
* \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
|
class ProtoOStream
|
||||||
{
|
{
|
||||||
@ -42,7 +42,7 @@ class ProtoOStream
|
|||||||
/**
|
/**
|
||||||
* Writes a message to a file.
|
* Writes a message to a file.
|
||||||
* @param m The protobuf-message to be written.
|
* @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);
|
bool writeMessage(google::protobuf::Message* m);
|
||||||
};
|
};
|
||||||
@ -51,8 +51,8 @@ class ProtoOStream
|
|||||||
/**
|
/**
|
||||||
* \class ProtoIStream
|
* \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
|
class ProtoIStream
|
||||||
{
|
{
|
||||||
@ -69,14 +69,13 @@ class ProtoIStream
|
|||||||
virtual ~ProtoIStream() {};
|
virtual ~ProtoIStream() {};
|
||||||
/**
|
/**
|
||||||
* Resets the position of the get pointer. After that getNext
|
* Resets the position of the get pointer. After that getNext
|
||||||
* delivers the first message again.
|
* reads the first message again.
|
||||||
*/
|
*/
|
||||||
void reset();
|
void reset();
|
||||||
/**
|
/**
|
||||||
* Delivers the protobuf-messages sequentially from file.
|
* Reads the next protobuf message from the input stream.
|
||||||
* @param m The protobuf-message in which, the data should be
|
* @param m The output protobuf message.
|
||||||
* written.
|
* @return Returns true on success.
|
||||||
* @return Returns true if data was written to protobuf-message.
|
|
||||||
*/
|
*/
|
||||||
bool getNext(google::protobuf::Message* m);
|
bool getNext(google::protobuf::Message* m);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user