[Alephmodular-devel] Random rumblings on files and errors
Status: Pre-Alpha
Brought to you by:
brefin
From: Br'fin <br...@ma...> - 2003-01-30 04:44:27
|
I've been mucking with a spare copy of AM, actually trying to implement what I have described in my draft so far. Which is of course turning up more areas to work upon. Like, most files are going to be opened in binary mode. So this makes a reasonable default, however, some files in the future are going to be text based, so we should support that as well. I was thinking of exposing the iostream openmode flags as part of the open_file_for_reading/writing business. And just have it default to binary. You could clear it of course by passing 0 for the mode (or a suitably equivalent definition) The other two aspects I found myself leaning towards were calling conventions and error feedback. By calling conventions I was thinking of calls like this: virtual bool get_named_child(const char *name, IFileSystemDesc* &out_desc) const = 0; This is a method to specify a file or directory within a directory. The name of that desc would be the string name. If the function was successful, then it would return true, and the IFileSystemDesc* would point to a newly acquired class. (Which the caller would need to free currently) If the function failed, then it would return false, and the IFileSystemDesc* would remain untouched. And the reason for failure? Well, after a little bit of thinking, I realized that there should be an IError interface with three methods. A protected set_state, a public get_state and a public clear_state. And in thinking of it, it's possible that the state itself could be verbose enough to display/log when dumped to a stream. Why not exceptions? I have not been sold on exception handling in C++ under some warnings of exception handling being there, but less than optimal under C++ (Less practical in terms of speed, doing extra work with stuff too low level for me really to be thinking about :) ) and a simple lack of knowledge on how one is supposed to do it in C++. (Java is at least clear on what things you should be throwing around) Admittedly a nice clear document that counters these perceptions as myth might change my mind. -Jeremy Parsons |