ubit
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | List of all members
ubit::UDocFactory Class Reference

Document Factory: use this class to read documents. More...

#include <udoc.hpp>

Classes

struct  Comp
 

Public Member Functions

virtual UDoccreate (const UStr &name)
 creates an empty document. More...
 
virtual UDocload (const UStr &name, const UStr &buffer)
 loads a document from a buffer in memory. More...
 
virtual UDocread (const UStr &filename)
 reads a document from a file. More...
 
virtual int getStatus () const
 status of the last (read/load/create) operation. More...
 
virtual void saveErrors (bool)
 
virtual UStrgetErrors () const
 return last errors messages if saveErrors() was set to true. More...
 
virtual UDocCreatorgetCreator (const UStr &type)
 returns the creator for this type (if any, null otherwise). More...
 
virtual UDocCreatorgetDefaultCreator ()
 returns the default document creator.
 
virtual void addCreator (const UStr &type, UDocCreator &)
 adds a document creator.
 
virtual void setDefaultCreator (UDocCreator &)
 changes the creator that is used when the document type is unknown.
 

Static Public Member Functions

static UDocFactorygetDefaultFactory ()
 returns the default factory for reading/creating documents.
 

Protected Types

typedef std::map< const UStr *, UDocCreator *, CompMap
 

Protected Attributes

Map rmap
 
UDocCreatordefault_creator
 
int stat
 
uptr< UStrerrors
 

Detailed Description

Document Factory: use this class to read documents.

See class UDoc for info on "documents".

Member Function Documentation

§ create()

UDoc * ubit::UDocFactory::create ( const UStr name)
virtual

creates an empty document.

creates an instance of the appropriate UDoc subclass depending on 'name' suffix.

§ getCreator()

UDocCreator * ubit::UDocFactory::getCreator ( const UStr type)
virtual

returns the creator for this type (if any, null otherwise).

by convention, the 'type' is the suffix of the file (e.g. "html", "txt", "cpp" ...)

Note: certains creators (such as the HTML or XML creators) have specific options. This function provides a mean to retrieve the actual creator and to change its options.

§ getErrors()

UStr * ubit::UDocFactory::getErrors ( ) const
virtual

return last errors messages if saveErrors() was set to true.

errors are printed on stderr otherwise.

§ getStatus()

int ubit::UDocFactory::getStatus ( ) const
virtual

status of the last (read/load/create) operation.

value is:

  • > 0 if the document could be created
  • < 0 if the file cant be read (see UFilestat)
  • = 0 if the type of the document is unknown (see getCreator, addCreator)

§ load()

UDoc * ubit::UDocFactory::load ( const UStr name,
const UStr buffer 
)
virtual

loads a document from a buffer in memory.

creates an instance of the appropriate UDoc subclass depending on 'name' suffix.

§ read()

UDoc * ubit::UDocFactory::read ( const UStr filename)
virtual

reads a document from a file.

reads and creates an instance of the appropriate UDoc subclass depending on 'filename' suffix.


The documentation for this class was generated from the following files: