xml/xmldomandxpath/inc/xpath/xmlengxpathresult.h
changeset 0 e35f40988205
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Result of XPath expression
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @publishedAll
       
    22  @released
       
    23 */
       
    24 #ifndef XMLENGXPATHRESULT_H
       
    25 #define XMLENGXPATHRESULT_H
       
    26 
       
    27 #include <xml/dom/xmlengnodeset.h>
       
    28 
       
    29 /**
       
    30 Represents the result of a XPath expression.
       
    31 
       
    32 The result may be one of the standard types: string, boolean, number (float), 
       
    33 node set or be undefined in the case of error.
       
    34 
       
    35 The returned result should be freed after use.
       
    36 */
       
    37 class RXmlEngXPathResult
       
    38 {
       
    39 	friend class RXmlEngXPathExpression;
       
    40     friend class TXmlEngXPathEvaluationContextImpl;
       
    41 
       
    42 public:
       
    43     /**
       
    44 	Result types of a XPath expression.
       
    45 	See http://w3.org/TR/xpath#section-Introduction
       
    46     */
       
    47     enum TXmlEngXPathResultType
       
    48         {
       
    49         EUndefined = 0,
       
    50         ENodeset = 1,
       
    51         EBoolean = 2,
       
    52         ENumber = 3,
       
    53         EString = 4
       
    54         //Other node types defined in XPath are not supported.
       
    55 	    } ;
       
    56 
       
    57 public:
       
    58 	/** Default constructor */
       
    59 	IMPORT_C RXmlEngXPathResult();
       
    60 
       
    61 	/** Frees any allocated memory */
       
    62 	IMPORT_C void Free();
       
    63 
       
    64 	/** Frees any allocated memory */
       
    65 	inline void Close();
       
    66 
       
    67 	/**
       
    68 	Retrieves the type of the result (e.g. boolean, number, string, etc.).  
       
    69 	The type of a result should always be checked before using the result.
       
    70 	
       
    71 	If there was an error and no value was set, undefined is returned.
       
    72 	Otherwise nodeset is returned.	
       
    73 	
       
    74 	@return Type of result.
       
    75 	
       
    76 	@see TXmlEngXPathResultType
       
    77 	*/
       
    78 	IMPORT_C TXmlEngXPathResultType Type() const;
       
    79 	
       
    80 	/**
       
    81 	Retrieves a node-set result.  A Non-RXmlEngNodeSet result will return NULL.
       
    82 	No conversion is done from other types.
       
    83 	
       
    84 	For more information no NULL nodes:
       
    85 	@see TXmlEngNode
       
    86 	
       
    87 	@return Node-set result
       
    88 	*/
       
    89 	IMPORT_C RXmlEngNodeSet AsNodeSet() const;
       
    90 	
       
    91 	/**
       
    92 	Retrieves a string copy of result.
       
    93 	@param A buffer allocated by the caller that holds the result string
       
    94 	@leave KErrNoMemory if out of memory situation occurs.
       
    95 	@leave - Otherwise any of the system wide errors.
       
    96 	*/	
       
    97 	IMPORT_C void AsStringL(RBuf8& aOutput) const;
       
    98 
       
    99 	/**
       
   100 	Retrieves a numeric value result.  Conversion can occur from other types.
       
   101 	 
       
   102 	Node sets, strings, and booleans will be cast to numbers.  Anything else
       
   103 	will return NAN (i.e. not a number).
       
   104 	
       
   105 	@return Numeric value of the result.
       
   106 	
       
   107 	@see Math
       
   108 	*/	
       
   109 	IMPORT_C TReal AsNumber() const;
       
   110 	
       
   111 	/**
       
   112 	Retrieves a boolean result.  Conversion can occur from other types.
       
   113 	
       
   114 	Numbers will be returned as true unless it is not a number or 0.0.
       
   115 	A string of 0 length will return false, otherwise true.
       
   116 	If the node exists it will be returned as true, otherwise false.
       
   117 	
       
   118 	@return Boolean value of the result
       
   119 	*/	
       
   120 	IMPORT_C TBool AsBoolean() const;
       
   121 
       
   122 private:
       
   123 	/**
       
   124 	Constructor
       
   125 	@param aData Internal representation of XPath result
       
   126 	*/
       
   127 	RXmlEngXPathResult(void* aData);
       
   128 	
       
   129 private: 
       
   130 	void* iInternal;
       
   131     };	
       
   132 
       
   133 #include <xml/dom/xmlengxpathresult.inl>
       
   134 
       
   135 #endif /* XMLENGXPATHRESULT_H */
       
   136