BDataSource.h

Go to the documentation of this file.
00001 #ifndef _B_XML_DATA_SOURCE_H
00002 #define _B_XML_DATA_SOURCE_H
00003 
00004 #include <SupportDefs.h>
00005 
00006 
00007 // Forward References not in namespace B::XML
00008 // =====================================================================
00009 class BDataIO;
00010 
00011 namespace B {
00012 namespace XML {
00013 
00014 // BXMLDataSource
00015 // =====================================================================
00016 // Allows you to get some data to parse with minimal copying
00017 class BXMLDataSource
00018 {
00019 public:
00020     // GetNextBuffer is the same idea as DataIO, except it doesn't require
00021     // a data copy.  It will be provided with a buffer in *data, so if you
00022     // have to copy data, then copy into that, but if you have your own
00023     // buffer, then just replace *data with your pointer.
00024     // You should return how much data there is in size, and
00025     // if this is the last iteration, then return a non-zero value in done.
00026     virtual status_t    GetNextBuffer(size_t * size, uchar ** data, int * done) = 0;
00027     virtual             ~BXMLDataSource();
00028 };
00029 
00030 
00031 
00032 // BXMLDataIOSource
00033 // =====================================================================
00034 // Subclass of BBXMLDataSource that uses a BDataIO to get the data
00035 class BXMLDataIOSource : public BXMLDataSource
00036 {
00037 public:
00038                         BXMLDataIOSource(BDataIO * data);
00039     virtual             ~BXMLDataIOSource();
00040     virtual status_t    GetNextBuffer(size_t * size, uchar ** data, int * done);
00041 
00042 private:
00043                         // Illegal
00044                         BXMLDataIOSource();
00045                         BXMLDataIOSource(const BXMLDataIOSource & );
00046     BDataIO     * _data;
00047 };
00048 
00049 
00050 
00051 // BXMLBufferSource
00052 // =====================================================================
00053 // Subclass of BBXMLDataSource that uses a buffer you give it to get the data
00054 class BXMLBufferSource : public BXMLDataSource
00055 {
00056 public:
00057                         // If len < 0, it is null terminated, so do strlen
00058                         BXMLBufferSource(const char * buffer, int32 len = -1);
00059     virtual             ~BXMLBufferSource();
00060     virtual status_t    GetNextBuffer(size_t * size, uchar ** data, int * done);
00061 
00062 private:
00063                         // Illegal
00064                         BXMLBufferSource();
00065                         BXMLBufferSource(const BXMLBufferSource & copy);
00066     const char  * _data;
00067     int32       _length;
00068 };
00069 
00070 
00071 }; // namespace XML
00072 }; // namespace B
00073 
00074 
00075 #endif // _B_XML_DATA_SOURCE_H

Copyright 2005 by yellowTAB GmbH, Be Inc., Palm Source Inc. and their respective legal successors
All rights reserved.