This weekend I wrote a GIF parser, and refactored it a bit to use these classes (I do have a life--I did other things, too!). I've renamed some things and added some things (like setByteOrder() and BYTE_ORDER_MACHINE) and spent a couple hours writing an invisible buffering mechanism before determining that it actually made performance worse. :-D
Currently, and this is by no means finalized, but this is the structure: Zend_Parser_Interface Zend_Parser_DataSource_Interface Zend_File implements Zend_Parser_DataSource_Interface Zend_File_Parser_Abstract implements Zend_Parser_Interface My_Image_Gif extends Zend_File My_Image_Gif_Parser extends Zend_File_Parser_Abstract Theoretically, if there were something like Zend_String, it could implement Zend_Parser_DataSource_Interface and Zend_String_Parser could implement Zend_Parser_Interface. If you have suggestions on a better structure, I'd like to hear your thoughts. -Matt On Mon, April 2, 2007 3:26 am, Pádraic Brady wrote: > Spent part of the weekend implementing a file buffer class and parser for > yet another format (string, not binary). So I'm reading this email topic > with a lot of interest. > > It would be good to see some general interface/abstract for file/string > reading and parsing. I just looked at the StringParser and other files > briefly (would just note the lack of Unicode string parsing ;)) and they > all bear similarities to a parser I spent some hours mocking a partial > implementation of. > > There's a lot of re-useable code under the Zend/Pdf location that could be > generalised, moved as suggested, and improved and I'd love to see that > happen. I have a chunk of ideas that could use it! As it stands I have to > give some though to using the current code (even if it's another non-PDF > file, it's all plain text) in favour of what I might write - general or > not it's better than reinventing something already in the framework. If > nothing else it might help cut down development time even if I have to > make minor changes via subclasses. > > ++1 to a proposal. :) > > Pádraic Brady > http://blog.astrumfutura.com > http://www.patternsforphp.com > > > ----- Original Message ---- > From: Matthew Ratzloff <[EMAIL PROTECTED]> > To: Kevin McArthur <[EMAIL PROTECTED]> > Cc: fw-general@lists.zend.com > Sent: Saturday, March 31, 2007 11:39:13 PM > Subject: Re: [fw-general] Zend_File_Parser, Zend_String, etc. > (was: Operating with file system: OO approach) > > On second thought, it makes more sense to have > > Zend_Parser_Interface > Zend_Parser_DataSource_Interface* > > Neither with concrete classes (like SPL). Then Zend_File can implement > Zend_Parser_DataSource_Interface and Zend_File_Parser can implement > Zend_Parser_Interface. > > I'll look into this more thoroughly tonight. I can see all kinds of > applications for it. > > -Matt > > * There's probably a better name for this. > > On Sat, March 31, 2007 2:42 pm, Kevin McArthur wrote: >> We suggested this when it was written (and I'm yet to have fully >> translated >> the image parsers to use the new one, open issue yadayada) so if you're >> going to create a proper fileparser class, do it soon and we can update >> the >> outstanding changes to use the new class. >> >> Willie wrote this class when getting the font support for zpdf going and >> its >> quite robust. >> >> We suggested a generalized parser, but we've barely got the time to >> handle >> our own backyard let alone push through a full proposal etc. However, >> that >> was our intent for this stuff; after we wrote 4 or 5 specific format >> parsers >> and said *wtf* =P >> >> So ya, proposal sounds good, push it through n such. >> >> Kevin >> >> >> >> ----- Original Message ----- >> From: "Matthew Ratzloff" <[EMAIL PROTECTED]> >> To: "Kevin McArthur" <[EMAIL PROTECTED]> >> Cc: <fw-general@lists.zend.com> >> Sent: Saturday, March 31, 2007 2:15 PM >> Subject: Re: [fw-general] Zend_File_Parser, Zend_String, etc. (was: >> Operating with file system: OO approach) >> >> >>> LOL >>> >>> Naturally, you post this after I spend part of my weekend writing a >>> byte >>> parser with similar functionality. :-D >>> >>> This needs to split off into its own component ASAP. Additional >>> functionality can get filled in as it comes. Some really useful stuff >>> in >>> there for file parsing. >>> >>> The current files: >>> >>> Zend_Pdf_FileParser >>> Zend_Pdf_FileParserDataSource (abstract) >>> Zend_Pdf_FileParserDataSource_File extends >>> Zend_Pdf_FileParserDataSource >>> Zend_Pdf_FileParserDataSource_String extends >>> Zend_Pdf_FileParserDataSource >>> >>> Zend_Pdf_FileParser_DataSource can pretty easily become an interface >>> instead. Perhaps: >>> >>> Zend_File_Parser >>> Zend_File_Interface >>> Zend_File implements Zend_File_Interface >>> Zend_String implements Zend_File_Interface >>> >>> I have one or two ideas for a Zend_String class. The first is a method >>> for converting "stringified" string literals (for instance, '\x00', as >>> opposed to "\x00") to their literal value. This is necessary when >>> parsing >>> magic files (see my Zend_Mime_Magic proposal). I'm sure others can >>> think >>> of ideas for that as well. >>> >>> -Matt >>> >>> On Sat, March 31, 2007 1:33 pm, Kevin McArthur wrote: >>>> There is also an excellent binary file parser in Zend_Pdf if you need >>>> to >>>> parse a binary file format. >>>> >>>> Kevin >>>> ----- Original Message ----- >>>> From: "Ralph Schindler" <[EMAIL PROTECTED]> >>>> To: "Ivan Ruiz Gallego" <[EMAIL PROTECTED]> >>>> Cc: <fw-general@lists.zend.com> >>>> Sent: Saturday, March 31, 2007 1:25 PM >>>> Subject: Re: [fw-general] Operating with file system: OO approach >>>> >>>> >>>>> Have you looked into the SPL? >>>>> >>>>> http://www.php.net/~helly/php/ext/spl/ >>>>> >>>>> Specifically: DirectoryIterator, SPLFileInfo, SplFileObject >>>>> >>>>> You might find some useful information and File/Directory patterns in >>>>> there. >>>>> >>>>> -ralph >>>>> >>>>> Ivan Ruiz Gallego wrote: >>>>>> Hello Matt, >>>>>> >>>>>> Well. In first instance I am thinking about the basic file system >>>>>> related >>>>>> operations like: create, remove, rename, move, copy or find >>>>>> directories >>>>>> and files. Basically, what we can already do, but in an >>>>>> object-oriented >>>>>> manner. In addition to this, I have been also thinking about a >>>>>> something >>>>>> like a recycle bin. >>>>>> >>>>>> Regards, >>>>>> Ivan. >>>>>> >>>>>> Matthew Ratzloff schrieb: >>>>>>> There has been some light discussion in this area. Do you have any >>>>>>> suggestions for what a component like this should be capable of >>>>>>> doing? >>>>>>> >>>>>>> -Matt >>>>>>> >>>>>>> On Sat, March 31, 2007 9:31 am, Ivan Ruiz Gallego wrote: >>>>>>> >>>>>>>> Hello, >>>>>>>> >>>>>>>> I am looking for a class or a set of classes that allow an >>>>>>>> object-oriented operation with the file system. I am working now >>>>>>>> with >>>>>>>> SPL and I have also taken a look to PEAR, but I haven't so far >>>>>>>> found >>>>>>>> a >>>>>>>> comprehensive solution. As far as I know is such a library not >>>>>>>> included >>>>>>>> in Zend Framework. >>>>>>>> >>>>>>>> Here my questions: >>>>>>>> - Is the inclusion of such functionality planed within Zend >>>>>>>> Framework? >>>>>>>> - Does anyone know about such a library? >>>>>>>> >>>>>>>> Thanks. >>>>>>>> >>>>>>>> Best regards, >>>>>>>> Ivan. >>>>>>>> >>>>>>>> -- >>>>>>>> Loglan GmbH >>>>>>>> Ivan Ruiz Gallego >>>>>>>> >>>>>>>> Binzmühlestrasse 210 >>>>>>>> 8050 Zürich >>>>>>>> Switzerland >>>>>>>> >>>>>>>> Office +41 44 310 19 20 >>>>>>>> Mobile +41 76 321 23 68 >>>>>>>> Net www.loglan.net >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Loglan GmbH >>>>>> Ivan Ruiz Gallego >>>>>> >>>>>> Binzmühlestrasse 210 >>>>>> 8050 Zürich >>>>>> Switzerland >>>>>> >>>>>> Office +41 44 310 19 20 >>>>>> Mobile +41 76 321 23 68 >>>>>> Net www.loglan.net >>>>>> >>>>> >>>> >>>> >>> >>> >> >> > > > > > > > > > > > ____________________________________________________________________________________ > Finding fabulous fares is fun. > Let Yahoo! FareChase search your favorite travel sites to find flight and > hotel bargains. > http://farechase.yahoo.com/promo-generic-14795097