This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFA] ui-file.[ch]: tell(), mem_filebuf()


On 15-Dec-2000, Andrew Cagney wrote:

>>   1. Adds a tell method to the ui_file interface.

>Um, it might be useful if you expanded a little on what you're trying to
>do and why it isn't currently possible.

What I'm trying to do: add a tell() method analogous to ftell() that
returns the current position in a ui_file.

Why it isn't currently possible: because there isn't a ui_file tell
method.  Right now we have isatty, write, fputs, flush, delete, rewind,
and put.

I forget why I needed it, because in fact I don't use it now.  But it
provides an obvious missing piece in the file abstraction provided by
ui_file, so I'm posting it in case it's needed by someone else in the
future.

>>   3. Defines a new function, char *mem_filebuf (struct ui_file *file), to
>>      return the buffer currently used for storing FILE's contents.

>Is it a good idea to expose the internal workings of a specific ui_file
>implementation?

It doesn't expose the internal workings of anything.  It simply adds a
memory-file method returning a read-only buffer that needn't be freed
by the caller and that takes O(1) time to create.

In object-oriented parlance, the memory ui_file class is derived from the
null ui_file class.  There's nothing unusual about derived classes having
extra methods that wouldn't make sense in their base classes.

Nick

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]