M
MSP
Hello everybody,
I am reading a text file (in a format created by myself), which
contains inline-data maintained by a third party library. Say, there
is a class, with some read-method as follows:
class CForeignClass
{
public:
bool Read(std::istream& is);
}
To read the file, I open a std::ifstream and whenever I encounter the
foreign data, I simply hand the istream reference over to the foreign
class.
std::ifstream f(path);
// read data owned by me
...
if (bForeignDataEncountered)
{
// read foreign data
CForeignClass foreignClass;
foreignClass.Read(f);
}
// read more data owned by me
While doing this, I would like to keep track of the number of lines
read by the foreign class. Is there a portable or recommended way to
do this by deriving my own class from std::ifstream and overwriting
some virtual method (or similar by replacing the standard input buffer
by a modified one) ?
Thanks in advance,
Matthias
I am reading a text file (in a format created by myself), which
contains inline-data maintained by a third party library. Say, there
is a class, with some read-method as follows:
class CForeignClass
{
public:
bool Read(std::istream& is);
}
To read the file, I open a std::ifstream and whenever I encounter the
foreign data, I simply hand the istream reference over to the foreign
class.
std::ifstream f(path);
// read data owned by me
...
if (bForeignDataEncountered)
{
// read foreign data
CForeignClass foreignClass;
foreignClass.Read(f);
}
// read more data owned by me
While doing this, I would like to keep track of the number of lines
read by the foreign class. Is there a portable or recommended way to
do this by deriving my own class from std::ifstream and overwriting
some virtual method (or similar by replacing the standard input buffer
by a modified one) ?
Thanks in advance,
Matthias