CSenBaseFragment Class Reference

#include <mw/SenBaseFragment.h>

Link against: SenXML.dll

class CSenBaseFragment : public CSenFragment

Inherits from

Protected Attributes
TInt iState
RWriteStream iWs
CSenXmlReader *iXmlReader
CSenElement *ipElement
MSenFragment *ipOwner
Public Member Functions
virtual ~CSenBaseFragment()
virtual IMPORT_C CSenElement &AsElement()
virtual IMPORT_C HBufC8 *AsXmlL()
virtual IMPORT_C HBufC *AsXmlUnicodeL()
virtual IMPORT_C TIntBuildFrom(const TDesC8 &)
virtual IMPORT_C TBoolConsistsOfL(MSenFragment &)
virtual IMPORT_C TPtrC8Content()
virtual IMPORT_C voidDelegateParsingL(MSenFragment &)
virtual IMPORT_C voidDelegateParsingL(const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray &)
virtual IMPORT_C voidDetachL()
virtual IMPORT_C voidEnsureNamespace(const TDesC8 &)
virtual IMPORT_C CSenElement *ExtractElement()
virtual IMPORT_C const TDesC8 &LocalName()
virtual IMPORT_C CSenNamespace *Namespace(const TDesC8 &)
IMPORT_C CSenBaseFragment *NewL(const CSenElement &)
IMPORT_C CSenBaseFragment *NewL(const TDesC8 &)
IMPORT_C CSenBaseFragment *NewL(const TDesC8 &, const TDesC8 &)
IMPORT_C CSenBaseFragment *NewL(const TDesC8 &, const TDesC8 &, const TDesC8 &)
IMPORT_C CSenBaseFragment *NewL(const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray &)
IMPORT_C CSenBaseFragment *NewL(const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray &, CSenElement &)
virtual IMPORT_C const TDesC8 &NsPrefix()
virtual IMPORT_C const TDesC8 &NsUri()
virtual IMPORT_C voidParseL(const TDesC8 &)
virtual IMPORT_C voidParseWithL(CSenXmlReader &)
virtual IMPORT_C CSenXmlReader *Reader()
virtual IMPORT_C voidResetContentL()
virtual IMPORT_C voidResumeParsingFromL(const TDesC8 &, const TDesC8 &, const TDesC8 &)
virtual IMPORT_C voidSaveNamespacesL(const RAttributeArray &, TBool)
virtual IMPORT_C voidSetAttributesL(const RAttributeArray &)
virtual IMPORT_C voidSetOwner(MSenFragment &)
virtual IMPORT_C voidSetReader(CSenXmlReader &)
virtual IMPORT_C voidWriteAsXMLToL(RWriteStream &)
virtual IMPORT_C voidWriteEndElementL(const TDesC8 &, const TDesC8 &, const TDesC8 &)
virtual IMPORT_C voidWriteStartElementL(const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray &)
Protected Member Functions
CSenBaseFragment()
virtual IMPORT_C voidAllocContentSaverL()
IMPORT_C voidBaseConstructL(const CSenElement &)
IMPORT_C voidBaseConstructL(const TDesC8 &)
IMPORT_C voidBaseConstructL(const TDesC8 &, const TDesC8 &)
IMPORT_C voidBaseConstructL(const TDesC8 &, const TDesC8 &, const TDesC8 &)
IMPORT_C voidBaseConstructL(const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray &)
IMPORT_C voidBaseConstructL(const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray &, CSenElement &)
IMPORT_C voidBaseConstructL(CSenXmlReader &)
virtual IMPORT_C voidCharactersL(const TDesC8 &, TInt, TInt)
IMPORT_C TPtrC8ContentOf(const TDesC8 &)
virtual IMPORT_C voidEndElementL(const TDesC8 &, const TDesC8 &, const TDesC8 &)
IMPORT_C MSenElement &SetContentOfL(const TDesC8 &, const TDesC8 &)
virtual IMPORT_C voidStartElementL(const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray &)
IMPORT_C TIntStartEntity(TDesC8 &)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()

Detailed Description

Class implements basic functionality of an XML fragment Typically BaseFragment is used to parse certain part of some XML document. The element is identified by localname (or qualifiedname) and namespace. All child elements between start tag and and end tag defined this fragment will become content of this BaseFragment. In other words, BaseFragment has all data inside a single element. BaseFragment will parse only namespace (xmlns) attributes from a document and rest of the attributes are to be handled by subclasses, which should overwrite SetAttributesL() method to achieve this. The CSenXmlReader class will do the actual parsing and this class will act as content handler for XML parser SAX events.
Since
Series60 3.0

Member Attribute Documentation

iState

TInt iState[protected]

iWs

RWriteStream iWs[protected]

iXmlReader

CSenXmlReader *iXmlReader[protected]

ipElement

CSenElement *ipElement[protected]

ipOwner

MSenFragment *ipOwner[protected]

Constructor & Destructor Documentation

CSenBaseFragment ( )

IMPORT_CCSenBaseFragment()[protected]

C++ default constructor.

~CSenBaseFragment ( )

IMPORT_C~CSenBaseFragment()[virtual]

Destructor.

Member Function Documentation

AllocContentSaverL ( )

IMPORT_C voidAllocContentSaverL()[protected, virtual]
Makes the content internal stream for content saving available.
Since
Series60 3.0

AsElement ( )

IMPORT_C CSenElement &AsElement()[virtual]

Reimplemented from CSenFragment::AsElement()

Getting the fragment as an XML element. This method will panic if element has not been initialized for any reason.
Since
Series60 3.0

Returns: the current object as element. Ownership is not transferred.

AsXmlL ( )

IMPORT_C HBufC8 *AsXmlL()[virtual]

Reimplemented from CSenFragment::AsXmlL()

Gets the fragment data as an UTF-8 form XML.
Since
Series60 3.0

Returns: fragment as XML. Caller takes ownership.

AsXmlUnicodeL ( )

IMPORT_C HBufC *AsXmlUnicodeL()[virtual]
Gets the fragment data as an unicode XML.
Since
Series60 3.0

Returns: fragment as XML. Caller takes ownership.

BaseConstructL ( const CSenElement & )

IMPORT_C voidBaseConstructL(const CSenElement &aElement)[protected]
Following BaseConstructL methods should be called from ConstructL() methods of some deriving (fragment) class. BaseConstructL, where an element is given as initializer.
Since
Series60 3.0
ParameterDescription
aElementfrom which this fragment will be constructed from.

BaseConstructL ( const TDesC8 & )

IMPORT_C voidBaseConstructL(const TDesC8 &aLocalName)[protected]
BaseConstructL setting XML localname for this fragment.
Since
Series60 3.0
ParameterDescription
aLocalNameXML localname for this fragment

BaseConstructL ( const TDesC8 &, const TDesC8 & )

IMPORT_C voidBaseConstructL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName
)[protected]
BaseConstructL offering possibility to set XML namespace and localname.
Since
Series60 3.0
ParameterDescription
aNsUriXML namespace URI for this fragment
aLocalNameXML localname for this fragment

BaseConstructL ( const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C voidBaseConstructL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName
)[protected]
Base constructor
Since
Series60 3.0
ParameterDescription
aNsUriXML namespace URI for this fragment
aLocalNameXML localname for this fragment
aQNameXML qualifiedname for this fragment

BaseConstructL ( const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray & )

IMPORT_C voidBaseConstructL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName,
const RAttributeArray &aAttrs
)[protected]
Base constructor
Since
Series60 3.0
ParameterDescription
aNsUriXML namespace URI for this fragment
aLocalNameXML localname for this fragment
aQNameXML qualifiedname for this fragment
aAttrsXML attributes for this fragment

BaseConstructL ( const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray &, CSenElement & )

IMPORT_C voidBaseConstructL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName,
const RAttributeArray &aAttrs,
CSenElement &aParent
)[protected]
Base constructor
Since
Series60 3.0
ParameterDescription
aNsUriXML namespace URI for this fragment
aLocalNameXML localname for this fragment
aQNameXML qualifiedname for this fragment
aAttrsXML attributes for this fragment
aParentparent to be set for this fragmemt

BaseConstructL ( CSenXmlReader & )

IMPORT_C voidBaseConstructL(CSenXmlReader &aReader)[protected]
BaseConstructL() setting the XML reader for this fragment
Since
Series60 3.0
ParameterDescription
aReaderis the XML reader for this fragment

BuildFrom ( const TDesC8 & )

IMPORT_C TIntBuildFrom(const TDesC8 &aXml)[virtual]
Same as ParseL() except that it doesn't leave in case of an error. Instead errors are trapped and error is returned. SetReader() must be called before this method can be used.
Since
Series60 3.0

Returns: KErrNone or other system-wide Symbian error codes.

CharactersL ( const TDesC8 &, TInt, TInt )

IMPORT_C voidCharactersL(const TDesC8 &aChars,
TIntaStart,
TIntaLength
)[protected, virtual]
Function which implement the XML content handler interface. Inheriting classes can override these. This one is called when content is starting.
Since
Series60 3.0
ParameterDescription
aCharsThe content characters.
aStartThe starting index
aLengthThe length of the characters.

ConsistsOfL ( MSenFragment & )

IMPORT_C TBoolConsistsOfL(MSenFragment &aCandidate)[virtual]
Checks if fragment matches to another fragment by its content and child elements. Fragment can contain more data than the given candidate.
Since
Series60 3.0
ParameterDescription
aCandidateThe pattern to be matched. Must contain same or less data for match to come true.

Returns: ETrue if content and possible children match exactly to given pattern. EFalse otherwise.

Content ( )

IMPORT_C TPtrC8Content()[virtual]

Reimplemented from CSenFragment::Content()

Getter for the content,which is returned as UTF-8 form XML.
Since
Series60 3.0

Returns: content as UTF-8 form XML.

ContentOf ( const TDesC8 & )

IMPORT_C TPtrC8ContentOf(const TDesC8 &aLocalName)[protected]
Gets the content of a given element.
Since
Series60 3.0
ParameterDescription
aLocalNameThe local name of the element which content is asked

Returns: the content which was asked

DelegateParsingL ( MSenFragment & )

IMPORT_C voidDelegateParsingL(MSenFragment &aDelegate)[virtual]
Leave codes: KErrSenXmlReaderNotSet if XML reader has not been set. Let the delegate MSenFragment handle the following SAX events. This fragment is made the owner of the delegate and the delegate is expected to make this MSenFragment the receiver of SAX events once it has seen the end element for itself.
Since
Series60 3.0
ParameterDescription
aDelegateis the fragment to start handling the SAX events.

DelegateParsingL ( const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray & )

IMPORT_C voidDelegateParsingL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName,
const RAttributeArray &aAttrs
)[virtual]
Leave codes: KErrSenXmlReaderNotSet if XML reader has not been set. Creates a new fragment and lets the created MSenFragment handle the following SAX events. This fragment is made the owner of the delegate and the delegate is expected to make this MSenFragment act as receiver for SAX events (callbacks) once it has seen the end element for itself.
Since
Series60 3.0
ParameterDescription
aNsUriThe XML namespace URI for the delegate to be created
aLocalNameThe XML localname for the delegate to be created
aQNameThe XML qualifiedname for the delegate to be created

DetachL ( )

IMPORT_C voidDetachL()[virtual]
Since
Series60 3.0

Returns: Detaches this fragment from its owner. All namespace references from possible parent fragments are declared in the scope of this fragment prior detaching.

EndElementL ( const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C voidEndElementL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName
)[protected, virtual]
Callback function which implement the XML content handler interface. Inheriting classes can override these.
Since
Series60 3.0
ParameterDescription
aNsUriThe namespace URI of the new element
aLocalNameThe local name of the new element
aQNameThe qualified name of the new element

EnsureNamespace ( const TDesC8 & )

IMPORT_C voidEnsureNamespace(const TDesC8 &aPrefix)[virtual]
Since
Series60 3.0
ParameterDescription
aPrefixis the XML namespace prefix

ExtractElement ( )

IMPORT_C CSenElement *ExtractElement()[virtual]
Etracts the XML element from the fragment, leaving the fragment empty. Note(!): the return value (CSenElement) STRONGLY suggests that subclasses INHERIT CSenFragment in order properly comply the requirement of the ExtractElement() implementation.
Since
Series60 3.0

Returns: the current object as element. May return NULL. Ownership IS TRANSFERRED to the caller.

LocalName ( )

IMPORT_C const TDesC8 &LocalName()const [virtual]
Since
Series60 3.0

Returns: the localname of this fragment as UTF-8 form descriptor

Namespace ( const TDesC8 & )

IMPORT_C CSenNamespace *Namespace(const TDesC8 &aPrefix)[virtual]
Gets the namespace object with a given prefix.
Since
Series60 3.0

Returns: namespace with the given prefix. If not found or given prefix is zero length, will return NULL.

NewL ( const CSenElement & )

IMPORT_C CSenBaseFragment *NewL(const CSenElement &aElement)[static]
Standard 2 phase constructor.
Since
Series60 3.0
ParameterDescription
aElementis the element where construction data will be copied from.

NewL ( const TDesC8 & )

IMPORT_C CSenBaseFragment *NewL(const TDesC8 &aLocalName)[static]
Standard 2 phase constructor. Leave codes: KErrSenInvalidCharacters if aLocalName contains illegal characters. KErrSenZeroLengthDescriptor if aLocalName is zero length.
Since
Series60 3.0

NewL ( const TDesC8 &, const TDesC8 & )

IMPORT_C CSenBaseFragment *NewL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName
)[static]
Standard 2 phase constructor. Leave codes: KErrSenInvalidCharacters if aLocalName contains illegal characters. KErrSenZeroLengthDescriptor if aLocalName is zero length.
Since
Series60 3.0

NewL ( const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C CSenBaseFragment *NewL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName
)[static]
Standard 2 phase constructor. Leave codes: KErrSenInvalidCharacters if aLocalName or aQName contains illegal characters. KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
Since
Series60 3.0

NewL ( const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray & )

IMPORT_C CSenBaseFragment *NewL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName,
const RAttributeArray &apAttrs
)[static]
Standard 2 phase constructor. Leave codes: KErrSenInvalidCharacters if aLocalName or aQName contains illegal characters. KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
Since
Series60 3.0

NewL ( const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray &, CSenElement & )

IMPORT_C CSenBaseFragment *NewL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName,
const RAttributeArray &apAttrs,
CSenElement &aParent
)[static]
Standard 2 phase constructor.
Since
Series60 3.0

NsPrefix ( )

IMPORT_C const TDesC8 &NsPrefix()const [virtual]
Getter for namespace prefix of this fragment.
Since
Series60 3.0

Returns: namespace prefix or KNullDesC if not set.

NsUri ( )

IMPORT_C const TDesC8 &NsUri()const [virtual]

Reimplemented from CSenFragment::NsUri()const

Getter for Fragment's namespace URI..
Since
Series60 3.0

Returns: Namespace URI or KNullDesC if not set.

ParseL ( const TDesC8 & )

IMPORT_C voidParseL(const TDesC8 &aXml)[virtual]
Leave codes: KErrSenXmlReaderNotSet if XML reader has not been set. Method to invoke parsing of a XML data. Note that SetReader() must be called before this method can be used. Note that CSenBaseFragment does not parse any other attributes, but XML namespace attributes only. This is due to allow subclasses to process only those attributes they are interested in, and not others.
Since
Series60 3.0

ParseWithL ( CSenXmlReader & )

IMPORT_C voidParseWithL(CSenXmlReader &aReader)[virtual]
Sets the reader for this fragment and sets this to be the content handler of the following SAX events.
Since
Series60 3.0
ParameterDescription
aReaderis the XML parser to be used.

Reader ( )

IMPORT_C CSenXmlReader *Reader()[virtual]

Reimplemented from CSenFragment::Reader()

Gets the XML reader which this fragment uses for parsing.
Since
Series60 3.0

Returns: the XML reader. Ownerships is not transferred, due even this class does not own the XML reader instance.

ResetContentL ( )

IMPORT_C voidResetContentL()[virtual]
Resets the content of the fragment, and resets the namespaces.
Since
Series60 3.0

ResumeParsingFromL ( const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C voidResumeParsingFromL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName
)[virtual]
Leave codes: KErrSenXmlReaderNotSet if XML reader has not been set. Resumes parsing to be handled by this fragment. Usually called by some delegate fragment which was set to be content handler because this fragment called DelegateParsingL().
Since
Series60 3.0
ParameterDescription
aNsUriThe namespace URI of the current element
aLocalNameThe local name of the current element
aQNameThe qualified name of the current element

SaveNamespacesL ( const RAttributeArray &, TBool )

IMPORT_C voidSaveNamespacesL(const RAttributeArray &aAttrs,
TBoolaEnsure
)[virtual]
Since
Series60 3.0
ParameterDescription
aAttrsare the attributes from which the namespaces are searched from.
aEnsureif set to TRUE, the namespaces are copied into this fragment. If FALSE, then the namespaces are only referenced, but not copied and owned by this class.

SetAttributesL ( const RAttributeArray & )

IMPORT_C voidSetAttributesL(const RAttributeArray &aAttrs)[virtual]
Sets the attributes for the fragment. BaseFragment parses only namespace (xmlns) attributes from the document. Subclasses should override this method if they are intrested of handling any other XML attributes and their corresponding values.
Since
Series60 3.0

SetContentOfL ( const TDesC8 &, const TDesC8 & )

IMPORT_C MSenElement &SetContentOfL(const TDesC8 &aLocalName,
const TDesC8 &aContent
)[protected]
Sets content to a child element. If no element with given local name is not found, new one is added and content is set to that one.
Since
Series60 3.0
ParameterDescription
aLocalNameThe local name of element which content is about to be set
aContentContent to be set.

Returns: the element where content was set. Leave codes: KErrSenInvalidCharacters if aLocalName contains illegal characters. KErrSenZeroLengthDescriptor if aLocalName is zero length.

SetOwner ( MSenFragment & )

IMPORT_C voidSetOwner(MSenFragment &aFragment)[virtual]
Sets a new parent for this fragment.
Since
Series60 3.0

SetReader ( CSenXmlReader & )

IMPORT_C voidSetReader(CSenXmlReader &aReader)[virtual]
Sets the XML reader to be used for parsing for the fragment.
Since
Series60 3.0

StartElementL ( const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray & )

IMPORT_C voidStartElementL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName,
const RAttributeArray &aAttrs
)[protected, virtual]
Callback function implementing the XML content handler interface. Inheriting classes can override these.
Since
Series60 3.0
ParameterDescription
aNsUriThe namespace URI of the new element
aLocalNameThe local name of the new element
aQNameThe qualified name of the new element
aAttrsThe attributes of the new element

StartEntity ( TDesC8 & )

IMPORT_C TIntStartEntity(TDesC8 &aName)[protected]

Callback function which implement the XML content handler interface. Inheriting classes can override these. Note that overrides should return TRUE (1) on success and FALSE (0) on failure to parser.

Since
Series60 3.0
ParameterDescription
aNameThe entity name

WriteAsXMLToL ( RWriteStream & )

IMPORT_C voidWriteAsXMLToL(RWriteStream &aWs)[virtual]
Invokes AsElement()->WriteAsXMLToL(aWs);
Since
Series60 3.0
ParameterDescription
aWsis the stream into which the UTF-8 form XML will be written.

WriteEndElementL ( const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C voidWriteEndElementL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName
)[virtual]
Writes the end element tag to the content stream. Derivants can override the basic usage used in BaseFragment.
Since
Series60 3.0
ParameterDescription
aNsUriThe namespace URI of the current element
aLocalNameThe local name of the current element
aQNameThe qualified name of the current element

WriteStartElementL ( const TDesC8 &, const TDesC8 &, const TDesC8 &, const RAttributeArray & )

IMPORT_C voidWriteStartElementL(const TDesC8 &aNsUri,
const TDesC8 &aLocalName,
const TDesC8 &aQName,
const RAttributeArray &aAttrs
)[virtual]
Writes the start element tag to the content stream. Derivants can override the basic usage used in BaseFragment.
Since
Series60 3.0
ParameterDescription
aNsUriThe namespace URI of the current element
aLocalNameThe local name of the current element
aQNameThe qualified name of the current element
aAttrsis the array of attributes.