00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XOBJECT_HEADER_GUARD_1357924680) 00019 #define XOBJECT_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/XPath/XPathDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00029 00030 00031 00032 #include <xalanc/PlatformSupport/DoubleSupport.hpp> 00033 #include <xalanc/PlatformSupport/FormatterListener.hpp> 00034 #include <xalanc/PlatformSupport/XalanReferenceCountedObject.hpp> 00035 00036 00037 00038 #include <xalanc/DOMSupport/DOMServices.hpp> 00039 00040 00041 00042 #include <xalanc/XPath/NodeRefListBase.hpp> 00043 #include <xalanc/XPath/XalanXPathException.hpp> 00044 #include <xalanc/XPath/XPathExecutionContext.hpp> 00045 00046 00047 00048 XALAN_CPP_NAMESPACE_BEGIN 00049 00050 00051 00052 class MutableNodeRefList; 00053 class NodeRefListBase; 00054 class XalanDocumentFragment; 00055 class XObjectFactory; 00056 class XObjectTypeCallback; 00057 00058 00059 00060 /** 00061 * Class to hold XPath return types. 00062 */ 00063 class XALAN_XPATH_EXPORT XObject : protected XalanReferenceCountedObject 00064 { 00065 public: 00066 00067 friend class XObjectPtr; 00068 00069 typedef XPathExecutionContext::GetCachedString GetCachedString; 00070 00071 /** 00072 * Enumeration of possible object types 00073 */ 00074 enum eObjectType { eTypeNull = 0, 00075 eTypeUnknown = 1, 00076 eTypeBoolean = 2, 00077 eTypeNumber = 3, 00078 eTypeString = 4, 00079 eTypeNodeSet = 5, 00080 eTypeResultTreeFrag = 6, 00081 eTypeUserDefined = 7, 00082 // These next types are implementation-specific, and 00083 // are never returned by getType(). 00084 eTypeStringReference = 8, 00085 eTypeStringAdapter = 9, 00086 eTypeStringCached = 10, 00087 eTypeXTokenNumberAdapter = 11, 00088 eTypeXTokenStringAdapter = 12, 00089 eTypeNodeSetNodeProxy = 13, 00090 eUnknown 00091 }; 00092 00093 /** 00094 * Perform static initialization. See class XPathInit. 00095 * 00096 * @param theMemoryManager The MemoryManager instance. 00097 */ 00098 static void 00099 initialize(MemoryManager& theMemoryManager); 00100 00101 /** 00102 * Perform static shut down. See class XPathInit. 00103 */ 00104 static void 00105 terminate(); 00106 00107 /** 00108 * Create an XObject. 00109 * 00110 * @param theObjectType The enum for the type of the object. 00111 * @param theMemoryManager The MemoryManager instance. 00112 */ 00113 XObject( 00114 eObjectType theObjectType, 00115 MemoryManager& theMemoryManager); 00116 00117 /** 00118 * Given a request type, return the equivalent string. 00119 * For diagnostic purposes. 00120 * 00121 * @return string for type 00122 */ 00123 virtual const XalanDOMString& 00124 getTypeString() const = 0; 00125 00126 /** 00127 * Cast result object to a number. 00128 * 00129 * @param executionContext The current XPathExecutionContext 00130 * @return numeric value 00131 */ 00132 virtual double 00133 num(XPathExecutionContext& executionContext) const; 00134 00135 /** 00136 * Cast result object to a number. 00137 * 00138 * This function does not have access to the current 00139 * XPathExecutionContext, so the result may contain data 00140 * from whitespace text nodes that might have been stripped 00141 * otherwise. 00142 * 00143 * @return numeric value 00144 */ 00145 virtual double 00146 num() const; 00147 00148 /** 00149 * Cast result object to a boolean. 00150 * 00151 * @param executionContext The current XPathExecutionContext 00152 * @return boolean value 00153 */ 00154 virtual bool 00155 boolean(XPathExecutionContext& executionContext) const = 0; 00156 00157 /** 00158 * Cast result object to a string. 00159 * 00160 * @param executionContext The current XPathExecutionContext 00161 * @return string value 00162 */ 00163 virtual const XalanDOMString& 00164 str(XPathExecutionContext& executionContext) const = 0; 00165 00166 /** 00167 * Cast result object to a string. 00168 * 00169 * This function does not have access to the current 00170 * XPathExecutionContext, so the result may contain data 00171 * from whitespace text nodes that might have been stripped 00172 * otherwise. 00173 * 00174 * @param executionContext The current XPathExecutionContext 00175 * @return string value 00176 */ 00177 virtual const XalanDOMString& 00178 str() const = 0; 00179 00180 typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const FormatterListener::size_type); 00181 00182 /** 00183 * Send the string value to a FormatterListener instance. 00184 * 00185 * @param executionContext The current XPathExecutionContext 00186 * @param formatterListener The FormatterListener instance 00187 * @param function A pointer to the member function of FormatterListener to call 00188 */ 00189 virtual void 00190 str( 00191 XPathExecutionContext& executionContext, 00192 FormatterListener& formatterListener, 00193 MemberFunctionPtr function) const = 0; 00194 00195 /** 00196 * Send the string value to a FormatterListener instance. 00197 * 00198 * This function does not have access to the current 00199 * XPathExecutionContext, so the result may contain data 00200 * from whitespace text nodes that might have been stripped 00201 * otherwise. 00202 * 00203 * @param formatterListener The FormatterListener instance 00204 * @param function A pointer to the member function of FormatterListener to call 00205 */ 00206 virtual void 00207 str( 00208 FormatterListener& formatterListener, 00209 MemberFunctionPtr function) const = 0; 00210 00211 /** 00212 * Append the string value directly a string 00213 * 00214 * @param executionContext The current XPathExecutionContext 00215 * @param theBuffer The buffer for the data 00216 */ 00217 virtual void 00218 str( 00219 XPathExecutionContext& executionContext, 00220 XalanDOMString& theBuffer) const = 0; 00221 00222 /** 00223 * Append the string value directly a string 00224 * 00225 * This function does not have access to the current 00226 * XPathExecutionContext, so the result may contain data 00227 * from whitespace text nodes that might have been stripped 00228 * otherwise. 00229 * 00230 * @param theBuffer The buffer for the data 00231 */ 00232 virtual void 00233 str(XalanDOMString& theBuffer) const = 0; 00234 00235 /** 00236 * Get the length of the string value of the instance. 00237 * 00238 * @return The length of the string value 00239 */ 00240 virtual double 00241 stringLength(XPathExecutionContext& executionContext) const = 0; 00242 00243 /** 00244 * Cast result object to a result tree fragment. 00245 * 00246 * @param executionContext The current XPathExecutionContext 00247 * @return result tree fragment 00248 */ 00249 virtual const XalanDocumentFragment& 00250 rtree() const; 00251 00252 /** 00253 * Cast result object to a nodelist 00254 * 00255 * This function does not have access to the current 00256 * XPathExecutionContext, so the result may contain data 00257 * from whitespace text nodes that might have been stripped 00258 * otherwise. 00259 * 00260 * @param executionContext The current XPathExecutionContext 00261 * @return node list 00262 */ 00263 virtual const NodeRefListBase& 00264 nodeset() const; 00265 00266 /** 00267 * Process a callback request for preferred type information. 00268 * 00269 * @param theCallbackObject object to call back 00270 */ 00271 virtual void 00272 ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) = 0; 00273 00274 /** 00275 * Process a callback request for preferred type information. 00276 * 00277 * @param theCallbackObject object to call back 00278 */ 00279 virtual void 00280 ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const = 0; 00281 00282 /** 00283 * Tell if two objects are functionally equal. 00284 * 00285 * @param theRHS object to compare 00286 * @param executionContext the current execution context 00287 * @return true if they are equal 00288 */ 00289 bool 00290 equals( 00291 const XObject& theRHS, 00292 XPathExecutionContext& executionContext) const; 00293 00294 /** 00295 * Tell if two objects are functionally not equal. 00296 * 00297 * @param theRHS object to compare 00298 * @param executionContext the current execution context 00299 * @return true if they are equal 00300 */ 00301 bool 00302 notEquals( 00303 const XObject& theRHS, 00304 XPathExecutionContext& executionContext) const; 00305 00306 /** 00307 * Tell if one object is less than the other. 00308 * 00309 * @param theRHS object to compare 00310 * @return true if they are equal 00311 */ 00312 bool 00313 lessThan( 00314 const XObject& theRHS, 00315 XPathExecutionContext& executionContext) const; 00316 00317 /** 00318 * Tell if one object is less than or equal 00319 * the other. 00320 * 00321 * @param theRHS object to compare 00322 * @return true if they are equal 00323 */ 00324 bool 00325 lessThanOrEquals( 00326 const XObject& theRHS, 00327 XPathExecutionContext& executionContext) const; 00328 00329 /** 00330 * Tell if one object is greater than the other. 00331 * 00332 * @param theRHS object to compare 00333 * @return true if they are equal 00334 */ 00335 bool 00336 greaterThan( 00337 const XObject& theRHS, 00338 XPathExecutionContext& executionContext) const; 00339 00340 /** 00341 * Tell if one object is greater than or equal 00342 * the other. 00343 * 00344 * @param theRHS object to compare 00345 * @return true if they are equal 00346 */ 00347 bool 00348 greaterThanOrEquals( 00349 const XObject& theRHS, 00350 XPathExecutionContext& executionContext) const; 00351 00352 /** 00353 * Tell what kind of class this is. 00354 * 00355 * @return numeric type value 00356 */ 00357 eObjectType 00358 getType() const 00359 { 00360 return m_objectType; 00361 } 00362 00363 /** 00364 * Static conversion function. Returns the boolean value 00365 * of the supplied double. 00366 * 00367 * @param theString The double to convert. 00368 * 00369 * @return bool value 00370 */ 00371 static bool 00372 boolean(double theNumber) 00373 { 00374 return !DoubleSupport::isNaN(theNumber) && !DoubleSupport::equal(theNumber, 0.0); 00375 } 00376 00377 /** 00378 * Static conversion function. Returns the boolean value 00379 * of the supplied XalanDOMString. 00380 * 00381 * @param theString The XalanDOMString to convert. 00382 * @return bool value 00383 */ 00384 static bool 00385 boolean(const XalanDOMString& theString) 00386 { 00387 return theString.length() == 0 ? false : true; 00388 } 00389 00390 /** 00391 * Static conversion function. Returns the boolean value 00392 * of the supplied NodeRefListBase. 00393 * 00394 * @param theNodeList The NodeRefListBase to convert. 00395 * @return bool value 00396 */ 00397 static bool 00398 boolean(const NodeRefListBase& theNodeList) 00399 { 00400 return theNodeList.getLength() == 0 ? false : true; 00401 } 00402 00403 /** 00404 * Static conversion function. Returns a reference to a 00405 * XalanDOMString instance with the string value of the 00406 * boolean. 00407 * 00408 * @param theBool The boolean value to convert. 00409 * @return The string value of the boolean 00410 */ 00411 static const XalanDOMString& 00412 string(bool theBool) 00413 { 00414 return theBool == true ? s_trueString : s_falseString; 00415 } 00416 00417 /** 00418 * Static conversion function. Appends the supplied boolean 00419 * value to a string. 00420 * 00421 * @param theBool The boolean value to convert. 00422 * @param theString The string value of the provided boolean value. 00423 */ 00424 static void 00425 string( 00426 bool theBool, 00427 XalanDOMString& theString) 00428 { 00429 theString.append(theBool == true ? s_trueString : s_falseString); 00430 } 00431 00432 /** 00433 * Static conversion function. Calls the supplied FormatterListener 00434 * member function with the string value of the boolean. 00435 * 00436 * @param theBool The boolean value to convert. 00437 * @param formatterListener The FormatterListener instance. 00438 * @param function The FormatterListener member function to call. 00439 */ 00440 static void 00441 string( 00442 bool theBool, 00443 FormatterListener& formatterListener, 00444 MemberFunctionPtr function) 00445 { 00446 if(theBool == true) 00447 { 00448 (formatterListener.*function)(s_trueString.c_str(), s_trueString.length()); 00449 } 00450 else 00451 { 00452 (formatterListener.*function)(s_falseString.c_str(), s_falseString.length()); 00453 } 00454 } 00455 00456 /** 00457 * Static conversion function. Append the string value of the 00458 * double to the supplied XalanDOMString parameter. 00459 * 00460 * @param theNumber The double to convert. 00461 * @param theString The output XalanDOMString. 00462 */ 00463 static void 00464 string( 00465 double theNumber, 00466 XalanDOMString& theString) 00467 { 00468 NumberToDOMString(theNumber, theString); 00469 } 00470 00471 /** 00472 * Static conversion function. Calls the supplied FormatterListener 00473 * member function with the string value of the double. 00474 * 00475 * @param theNumber The double to convert. 00476 * @param formatterListener The FormatterListener instance. 00477 * @param function The FormatterListener member function to call. 00478 */ 00479 static void 00480 string( 00481 double theNumber, 00482 FormatterListener& formatterListener, 00483 MemberFunctionPtr function) 00484 { 00485 DOMStringHelper::NumberToCharacters(theNumber, formatterListener, function); 00486 } 00487 00488 /** 00489 * Static conversion function. Append the string value of the 00490 * XalanNode to the supplied XalanDOMString parameter. 00491 * 00492 * @deprecated This function is deprecated and should not be used. 00493 * 00494 * @param theNode The XalanNode to convert. 00495 * @param theString The output XalanDOMString. 00496 */ 00497 static void 00498 string( 00499 const XalanNode& theNode, 00500 XalanDOMString& theString) 00501 { 00502 DOMServices::getNodeData(theNode, theString); 00503 } 00504 00505 /** 00506 * Static conversion function. Calls the supplied FormatterListener 00507 * member function with the string value of the XalanNode. 00508 * 00509 * @deprecated This function is deprecated and should not be used. 00510 * 00511 * @param theNode The XalanNode to convert. 00512 * @param formatterListener The FormatterListener instance. 00513 * @param function The FormatterListener member function to call. 00514 */ 00515 static void 00516 string( 00517 const XalanNode& theNode, 00518 FormatterListener& formatterListener, 00519 MemberFunctionPtr function) 00520 { 00521 DOMServices::getNodeData(theNode, formatterListener, function); 00522 } 00523 00524 /** 00525 * Static conversion function. Append the string value of the 00526 * NodeRefListBase to the supplied XalanDOMString parameter. 00527 * 00528 * @deprecated This function is deprecated and should not be used. 00529 * 00530 * @param theNodeList The NodeRefListBase to convert. 00531 * @param theString The output XalanDOMString. 00532 */ 00533 static void 00534 string( 00535 const NodeRefListBase& theNodeList, 00536 XalanDOMString& theString) 00537 { 00538 if (theNodeList.getLength() > 0) 00539 { 00540 assert(theNodeList.item(0) != 0); 00541 00542 string(*theNodeList.item(0), theString); 00543 } 00544 } 00545 00546 /** 00547 * Static conversion function. Calls the supplied FormatterListener 00548 * member function with the string value of the NodeRefListBase. 00549 * 00550 * @deprecated This function is deprecated and should not be used. 00551 * 00552 * @param theNodeList The NodeRefListBase to convert. 00553 * @param formatterListener The FormatterListener instance. 00554 * @param function The FormatterListener member function to call. 00555 */ 00556 static void 00557 string( 00558 const NodeRefListBase& theNodeList, 00559 FormatterListener& formatterListener, 00560 MemberFunctionPtr function) 00561 { 00562 if (theNodeList.getLength() > 0) 00563 { 00564 assert(theNodeList.item(0) != 0); 00565 00566 DOMServices::getNodeData(*theNodeList.item(0), formatterListener, function); 00567 } 00568 } 00569 00570 /** 00571 * Static conversion function. Append the string value of the 00572 * XalanNode to the supplied XalanDOMString parameter. 00573 * 00574 * @param theNode The XalanNode to convert. 00575 * @param theExecutionContext The current XPathExecutionContext. 00576 * @param theString The output XalanDOMString. 00577 */ 00578 static void 00579 string( 00580 const XalanNode& theNode, 00581 XPathExecutionContext& theExecutionContext, 00582 XalanDOMString& theString) 00583 { 00584 DOMServices::getNodeData(theNode, theExecutionContext, theString); 00585 } 00586 00587 /** 00588 * Static conversion function. Calls the supplied FormatterListener 00589 * member function with the string value of the XalanNode. 00590 * 00591 * @param theNode The XalanNode to convert. 00592 * @param theExecutionContext The current XPathExecutionContext. 00593 * @param formatterListener The FormatterListener instance. 00594 * @param function The FormatterListener member function to call. 00595 */ 00596 static void 00597 string( 00598 const XalanNode& theNode, 00599 XPathExecutionContext& theExecutionContext, 00600 FormatterListener& formatterListener, 00601 MemberFunctionPtr function) 00602 { 00603 DOMServices::getNodeData( 00604 theNode, 00605 theExecutionContext, 00606 formatterListener, 00607 function); 00608 } 00609 00610 /** 00611 * Static conversion function. Append the string value of the 00612 * NodeRefListBase to the supplied XalanDOMString parameter. 00613 * 00614 * @param theNodeList The NodeRefListBase to convert. 00615 * @param theExecutionContext The current XPathExecutionContext. 00616 * @param theString The output XalanDOMString. 00617 */ 00618 static void 00619 string( 00620 const NodeRefListBase& theNodeList, 00621 XPathExecutionContext& theExecutionContext, 00622 XalanDOMString& theString) 00623 { 00624 if (theNodeList.getLength() > 0) 00625 { 00626 assert(theNodeList.item(0) != 0); 00627 00628 string(*theNodeList.item(0), theExecutionContext, theString); 00629 } 00630 } 00631 00632 /** 00633 * Static conversion function. Calls the supplied FormatterListener 00634 * member function with the string value of the NodeRefListBase. 00635 * 00636 * @param theNodeList The NodeRefListBase to convert. 00637 * @param theExecutionContext The current XPathExecutionContext. 00638 * @param formatterListener The FormatterListener instance. 00639 * @param function The FormatterListener member function to call. 00640 */ 00641 static void 00642 string( 00643 const NodeRefListBase& theNodeList, 00644 XPathExecutionContext& theExecutionContext, 00645 FormatterListener& formatterListener, 00646 MemberFunctionPtr function) 00647 { 00648 if (theNodeList.getLength() > 0) 00649 { 00650 assert(theNodeList.item(0) != 0); 00651 00652 DOMServices::getNodeData( 00653 *theNodeList.item(0), 00654 theExecutionContext, 00655 formatterListener, 00656 function); 00657 } 00658 } 00659 00660 /** 00661 * Calls the supplied FormatterListener member function with 00662 * the string. 00663 * 00664 * @param theString The XalanDOMString to convert. 00665 * @param formatterListener The FormatterListener instance. 00666 * @param function The FormatterListener member function to call. 00667 */ 00668 static void 00669 string( 00670 const XalanDOMString& theString, 00671 FormatterListener& formatterListener, 00672 MemberFunctionPtr function) 00673 { 00674 const XalanDOMString::size_type theLength = 00675 theString.length(); 00676 00677 if (theLength != 0) 00678 { 00679 assert(theLength == static_cast<FormatterListener::size_type>(theLength)); 00680 00681 (formatterListener.*function)( 00682 theString.c_str(), 00683 static_cast<FormatterListener::size_type>(theLength)); 00684 } 00685 } 00686 00687 /** 00688 * Static conversion function. 00689 * 00690 * @return bool value 00691 */ 00692 static double 00693 number(bool theBoolean) 00694 { 00695 return theBoolean == true ? 1.0 : 0.0; 00696 } 00697 00698 static double 00699 number( 00700 const XalanDOMString& theString, 00701 MemoryManager& theManager) 00702 { 00703 return DoubleSupport::toDouble(theString, theManager); 00704 } 00705 00706 /** 00707 * Static conversion function. 00708 * 00709 * @return The number value of the node list 00710 */ 00711 static double 00712 number( 00713 XPathExecutionContext& executionContext, 00714 const NodeRefListBase& theNodeList); 00715 00716 /** 00717 * Static conversion function. 00718 * 00719 * @return The number value of the node 00720 */ 00721 static double 00722 number( 00723 XPathExecutionContext& executionContext, 00724 const XalanNode& theNode); 00725 00726 00727 // All XObject instances are controlled by an instance of an XObjectFactory. 00728 friend class XObjectFactory; 00729 00730 void 00731 setFactory(XObjectFactory* theFactory) 00732 { 00733 m_factory = theFactory; 00734 } 00735 00736 // Base class for all XObject exceptions... 00737 class XObjectException : public XalanXPathException 00738 { 00739 public: 00740 00741 XObjectException( 00742 const XalanDOMString& theMessage, 00743 MemoryManager& theManager); 00744 00745 XObjectException( 00746 const XalanDOMString& theMessage, 00747 MemoryManager& theManager, 00748 const Locator* theLocator); 00749 00750 XObjectException(const XObjectException& other) ; 00751 00752 virtual 00753 ~XObjectException(); 00754 00755 virtual const XalanDOMChar* 00756 getType() const; 00757 00758 private: 00759 00760 static const XalanDOMChar s_type[]; 00761 }; 00762 00763 class XObjectInvalidConversionException : public XObjectException 00764 { 00765 public: 00766 00767 XObjectInvalidConversionException( 00768 MemoryManager& memoryManager, 00769 const XalanDOMString& fromType, 00770 const XalanDOMString& toType, 00771 XalanDOMString& buffer); 00772 00773 XObjectInvalidConversionException(const XObjectInvalidConversionException& other); 00774 00775 virtual 00776 ~XObjectInvalidConversionException(); 00777 00778 virtual const XalanDOMChar* 00779 getType() const; 00780 00781 private: 00782 00783 static const XalanDOMChar s_type[]; 00784 00785 static const XalanDOMString& 00786 formatErrorString( 00787 const XalanDOMString& fromType, 00788 const XalanDOMString& toType, 00789 XalanDOMString& theResult); 00790 }; 00791 00792 protected: 00793 00794 /** 00795 * Create an XObject from another XObject. 00796 * 00797 * The recommended copy constructor is the next 00798 * overload, that accepts an explicit MemoryManager 00799 * instance. 00800 * 00801 * @param source The source for the copy 00802 */ 00803 XObject(const XObject&); 00804 00805 /** 00806 * Create an XObject from another XObject. 00807 * 00808 * @param source The source for the copy 00809 * @param theMemoryManager The MemoryManager instance. 00810 */ 00811 XObject( 00812 const XObject& source, 00813 MemoryManager& theManager); 00814 00815 /** 00816 * Get the MemoryManager for this instance. 00817 * 00818 * @return The MemoryManager. 00819 */ 00820 MemoryManager& 00821 getMemoryManager() const 00822 { 00823 assert(m_memoryManager != 0); 00824 00825 return *m_memoryManager; 00826 } 00827 00828 void 00829 throwInvalidConversionException(const XalanDOMString& theTargetType) const; 00830 00831 /** 00832 * Tell what kind of class this is. 00833 * 00834 * @return numeric type value 00835 */ 00836 virtual eObjectType 00837 getRealType() const; 00838 00839 virtual void 00840 referenced(); 00841 00842 virtual void 00843 dereferenced(); 00844 00845 virtual 00846 ~XObject(); 00847 00848 static const XalanDOMString s_emptyString; 00849 00850 static const XalanDOMString& s_booleanString; 00851 00852 static const XalanDOMString& s_falseString; 00853 00854 static const XalanDOMString& s_nodesetString; 00855 00856 static const XalanDOMString& s_numberString; 00857 00858 static const XalanDOMString& s_resultTreeFragmentString; 00859 00860 static const XalanDOMString& s_stringString; 00861 00862 static const XalanDOMString& s_trueString; 00863 00864 private: 00865 00866 // Not implemented... 00867 XObject& 00868 operator=(const XObject&); 00869 00870 00871 eObjectType m_objectType; 00872 00873 XObjectFactory* m_factory; 00874 00875 mutable MemoryManager* m_memoryManager; 00876 }; 00877 00878 00879 00880 /** 00881 * Class to hold XObjectPtr return types. 00882 */ 00883 class XALAN_XPATH_EXPORT XObjectPtr 00884 { 00885 public: 00886 00887 friend bool operator==(const XObjectPtr&, const XObjectPtr&); 00888 friend bool operator<(const XObjectPtr&, const XObjectPtr&); 00889 00890 /** 00891 * Create an XObjectPtr. 00892 */ 00893 explicit 00894 XObjectPtr(XObject* theXObject = 0) : 00895 m_xobjectPtr(theXObject) 00896 { 00897 XalanReferenceCountedObject::addReference(theXObject); 00898 } 00899 00900 XObjectPtr(const XObjectPtr& theSource) : 00901 m_xobjectPtr(theSource.m_xobjectPtr) 00902 { 00903 XalanReferenceCountedObject::addReference(m_xobjectPtr); 00904 }; 00905 00906 XObjectPtr& 00907 operator=(const XObjectPtr& theRHS) 00908 { 00909 if (m_xobjectPtr != theRHS.m_xobjectPtr) 00910 { 00911 XalanReferenceCountedObject::removeReference(m_xobjectPtr); 00912 00913 m_xobjectPtr = theRHS.m_xobjectPtr; 00914 00915 XalanReferenceCountedObject::addReference(m_xobjectPtr); 00916 } 00917 00918 return *this; 00919 } 00920 00921 ~XObjectPtr() 00922 { 00923 XalanReferenceCountedObject::removeReference(m_xobjectPtr); 00924 }; 00925 00926 void 00927 release() 00928 { 00929 XObject* const xobjectPtr = m_xobjectPtr; 00930 00931 m_xobjectPtr = 0; 00932 00933 XalanReferenceCountedObject::removeReference(xobjectPtr); 00934 } 00935 00936 bool 00937 null() const 00938 { 00939 return m_xobjectPtr == 0 ? true : false; 00940 } 00941 00942 const XObject& 00943 operator*() const 00944 { 00945 return *m_xobjectPtr; 00946 }; 00947 00948 XObject& 00949 operator*() 00950 { 00951 return *m_xobjectPtr; 00952 }; 00953 00954 const XObject* 00955 operator->() const 00956 { 00957 return m_xobjectPtr; 00958 }; 00959 00960 XObject* 00961 operator->() 00962 { 00963 return m_xobjectPtr; 00964 }; 00965 00966 const XObject* 00967 get() const 00968 { 00969 return m_xobjectPtr; 00970 }; 00971 00972 XObject* 00973 get() 00974 { 00975 return m_xobjectPtr; 00976 }; 00977 00978 private: 00979 00980 XObject* m_xobjectPtr; 00981 }; 00982 00983 00984 00985 inline bool 00986 operator==( 00987 const XObjectPtr& theLHS, 00988 const XObjectPtr& theRHS) 00989 { 00990 return theLHS.m_xobjectPtr == theRHS.m_xobjectPtr; 00991 } 00992 00993 00994 00995 inline bool 00996 operator!=( 00997 const XObjectPtr& theLHS, 00998 const XObjectPtr& theRHS) 00999 { 01000 return !(theLHS == theRHS); 01001 } 01002 01003 01004 01005 inline bool 01006 operator<( 01007 const XObjectPtr& theLHS, 01008 const XObjectPtr& theRHS) 01009 { 01010 return theLHS.m_xobjectPtr < theRHS.m_xobjectPtr; 01011 } 01012 01013 01014 01015 XALAN_CPP_NAMESPACE_END 01016 01017 01018 01019 #endif // XOBJECT_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|