Subject: Re: xp stat needed
From: Hubert Figuiere (hfiguiere@teaser.fr)
Date: Mon Nov 12 2001 - 06:11:38 CST
According to Andrew Dunbar <hippietrail@yahoo.com>:
> Just a reminder that the importers and exporters do
> not only deal with files. They also deal with the
> clipboard. In the future there may be a case for
> importing a file over HTTP from a URL like MSWord can
> do as well. So we better keep this sort of thing in
> mind if we can.
That is one more argument for abstraction.
XAP_IOStream ----> XAP_IOClipboard
|---> XAP_IOFile
|---> XAP_IOInternetResource
XAP_IOStream implements typing, and defines IO.
XAP_File ----> XAP_MacFile
|---> XAP_UnixFile
|---> XAP_WinFile
XAP_File implements file stuff and is platform dependent. This class is not
supposed to be instanciated directly but rather instantied by te XAP_IOFile
to "delegate" file operations. If we could use multiple inheritance, we
would just have XAP_IOFile inherits from XAP_IOStream and XAP_<FE>File (but
that would require some compile time trickery).
Example (but far from complete):
class XAP_IOStream
{
public:
UT_Error open (perm) = 0;
UT_Error close () = 0;
bool isOpen () { return m_open; };
UT_Error read (char * buf, size_t sizeToRead, size_t *sizeRead) = 0; // possibly use UT_buf
UT_Error write (const char * buf, size_t sizeToRead, size_t *sizeRead) = 0; // possibly use UT_buf
protected:
void setOpen (bool state) { m_open = state; };
private:
bool m_open;
}
class XAP_IOFile
: public XAP_IOStream
{
public:
XAP_IOFile () { m_delegate = newPlatformFileClass(); };
const char * getPath ()
{ return m_delegate->getPath() };
UT_Error stat()
{ return m_delegate->stat(); };
private:
XAP_File * m_delegate;
}
class XAP_File
{
public:
XAP_File ();
static XAP_File *newPlatformFileClass (); // implement in paltform code
}
BTW, given the short timeframe, I suggest that we restrict to the minimum
usage of that otherwise we may break to much things with the AbiWord codebase.
Hub
This archive was generated by hypermail 2b25 : Mon Nov 12 2001 - 06:11:38 CST