Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

XObject.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(XOBJECT_HEADER_GUARD_1357924680)
17 #define XOBJECT_HEADER_GUARD_1357924680
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
27 
28 
29 
33 
34 
35 
37 
38 
39 
42 
43 
44 
45 XALAN_CPP_NAMESPACE_BEGIN
46 
47 
48 
49 class MutableNodeRefList;
50 class NodeRefListBase;
52 class XObjectFactory;
55 
56 
57 
62 {
63 public:
64 
65  friend class XObjectPtr;
66 
70  enum eObjectType { eTypeNull = 0,
71  eTypeUnknown = 1,
72  eTypeBoolean = 2,
73  eTypeNumber = 3,
74  eTypeString = 4,
75  eTypeNodeSet = 5,
76  eTypeResultTreeFrag = 6,
77  eTypeUserDefined = 7,
78  // These next types are implementation-specific, and
79  // are never returned by getType().
80  eTypeStringReference = 8,
81  eTypeStringAdapter = 9,
82  eTypeStringCached = 10,
83  eTypeXTokenNumberAdapter = 11,
84  eTypeXTokenStringAdapter = 12,
85  eTypeNodeSetNodeProxy = 13,
86  eUnknown
87  };
88 
92  static void
93  initialize(MemoryManagerType& theManager);
94 
98  static void
99  terminate();
100 
106  XObject(eObjectType theObjectType);
107 
108  XObject(const XObject& source);
109 
110 
117  virtual const XalanDOMString&
118  getTypeString() const = 0;
119 
125  virtual double
126  num() const;
127 
133  virtual bool
134  boolean() const;
135 
141  virtual const XalanDOMString&
142  str() const;
143 
144  typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int);
145 
153  virtual void
154  str(
155  FormatterListener& formatterListener,
156  MemberFunctionPtr function) const = 0;
157 
163  virtual double
164  stringLength() const = 0;
165 
171  virtual void
172  str(XalanDOMString& theBuffer) const;
173 
179  virtual const XalanDocumentFragment&
180  rtree() const;
181 
187  virtual const NodeRefListBase&
188  nodeset() const;
189 
195  virtual void
196  ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) = 0;
197 
203  virtual void
204  ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const = 0;
205 
213  bool
214  equals(
215  const XObject& theRHS,
216  XPathExecutionContext& executionContext) const;
217 
225  bool
226  notEquals(
227  const XObject& theRHS,
228  XPathExecutionContext& executionContext) const;
229 
236  bool
237  lessThan(
238  const XObject& theRHS,
239  XPathExecutionContext& executionContext) const;
240 
248  bool
249  lessThanOrEquals(
250  const XObject& theRHS,
251  XPathExecutionContext& executionContext) const;
252 
259  bool
260  greaterThan(
261  const XObject& theRHS,
262  XPathExecutionContext& executionContext) const;
263 
271  bool
272  greaterThanOrEquals(
273  const XObject& theRHS,
274  XPathExecutionContext& executionContext) const;
275 
282  getType() const
283  {
284  return m_objectType;
285  }
286 
292  static bool
293  boolean(double theNumber)
294  {
295  return !DoubleSupport::isNaN(theNumber) && !DoubleSupport::equal(theNumber, 0.0);
296  }
297 
303  static bool
304  boolean(const XalanDOMString& theString)
305  {
306  return theString.length() == 0 ? false : true;
307  }
308 
314  static bool
315  boolean(const NodeRefListBase& theNodeList)
316  {
317  return theNodeList.getLength() == 0 ? false : true;
318  }
319 
325  static const XalanDOMString&
326  string(bool theBool)
327  {
328  return theBool == true ? s_trueString : s_falseString;
329  }
330 
331  static void
333  bool theBool,
334  FormatterListener& formatterListener,
335  MemberFunctionPtr function)
336  {
337  if(theBool == true)
338  {
339  (formatterListener.*function)(s_trueString.c_str(), s_trueString.length());
340  }
341  else
342  {
343  (formatterListener.*function)(s_falseString.c_str(), s_falseString.length());
344  }
345  }
346 
352  static void
354  double theNumber,
355  XalanDOMString& theString)
356  {
357  DoubleToDOMString(theNumber, theString);
358  }
359 
360  static void
362  double theNumber,
363  FormatterListener& formatterListener,
364  MemberFunctionPtr function)
365  {
366  DOMStringHelper::DoubleToCharacters(theNumber, formatterListener, function);
367  }
368 
374  static void
376  const XalanNode& theNode,
377  XalanDOMString& theString)
378  {
379  DOMServices::getNodeData(theNode, theString);
380  }
381 
382  static void
384  const XalanNode& theNode,
385  FormatterListener& formatterListener,
386  MemberFunctionPtr function)
387  {
388  DOMServices::getNodeData(theNode, formatterListener, function);
389  }
390 
396  static void
398  const NodeRefListBase& theNodeList,
399  XalanDOMString& theString)
400  {
401  if (theNodeList.getLength() > 0)
402  {
403  assert(theNodeList.item(0) != 0);
404 
405  string(*theNodeList.item(0), theString);
406  }
407  }
408 
409  static void
411  const NodeRefListBase& theNodeList,
412  FormatterListener& formatterListener,
413  MemberFunctionPtr function)
414  {
415  if (theNodeList.getLength() > 0)
416  {
417  assert(theNodeList.item(0) != 0);
418 
419  DOMServices::getNodeData(*theNodeList.item(0), formatterListener, function);
420  }
421  }
422 
428  static double
429  number(bool theBoolean)
430  {
431  return theBoolean == true ? 1.0 : 0.0;
432  }
433 
434  static double
435  number(const XalanDOMString& theString,
436  MemoryManagerType& theManager)
437  {
438  return DoubleSupport::toDouble(theString, theManager);
439  }
440 
446  static double
447  number(
448  XPathExecutionContext& executionContext,
449  const NodeRefListBase& theNodeList);
450 
456  static double
457  number(
458  XPathExecutionContext& executionContext,
459  const XalanNode& theNode);
460 
461 
462  // All XObject instances are controlled by an instance of an XObjectFactory.
463  friend class XObjectFactory;
464 
465  void
467  {
468  m_factory = theFactory;
469  }
470 
471  // Base class for all XObject exceptions...
473  {
474  public:
475 
476  explicit
480 
481  XObjectException( const XObjectException& other) ;
482 
483  virtual
484  ~XObjectException();
485 
486  virtual const XalanDOMChar*
487  getType() const
488  {
489  return m_type;
490  }
491  private:
492 
493  static const XalanDOMChar m_type[];
494  };
495 
497  {
498  public:
499 
501  eObjectType fromType,
502  eObjectType toType);
503 
504 
506 
507  virtual
509 
510  virtual const XalanDOMChar*
511  getType() const
512  {
513  return m_type;
514  }
515 
516 
517  private:
518 
519  static const XalanDOMChar m_type[];
520 
521  static const XalanDOMString&
522  formatErrorString(
523  const XalanDOMString& fromType,
524  const XalanDOMString& toType,
525  XalanDOMString& theResult);
526 
527 
528  const eObjectType m_from;
529 
530  const eObjectType m_to;
531  };
532 
533 protected:
534 
540  virtual eObjectType
541  getRealType() const;
542 
543  virtual void
544  referenced();
545 
546  virtual void
547  dereferenced();
548 
549  virtual
550  ~XObject();
551 
553 
555 
557 
559 
561 
563 
565 
567 
568 private:
569 
570  // Not implemented...
571  XObject&
572  operator=(const XObject&);
573 
574  const eObjectType m_objectType;
575 
576  XObjectFactory* m_factory;
577 };
578 
579 
580 
585 {
586 public:
587 
588  friend bool operator==(const XObjectPtr&, const XObjectPtr&);
589  friend bool operator<(const XObjectPtr&, const XObjectPtr&);
590 
594  explicit
595  XObjectPtr(XObject* theXObject = 0) :
596  m_xobjectPtr(theXObject)
597  {
599  }
600 
601  XObjectPtr(const XObjectPtr& theSource) :
602  m_xobjectPtr(theSource.m_xobjectPtr)
603  {
605  };
606 
607  XObjectPtr&
608  operator=(const XObjectPtr& theRHS)
609  {
610  if (m_xobjectPtr != theRHS.m_xobjectPtr)
611  {
613 
614  m_xobjectPtr = theRHS.m_xobjectPtr;
615 
617  }
618 
619  return *this;
620  }
621 
623  {
625  };
626 
627  void
629  {
630  XObject* const xobjectPtr = m_xobjectPtr;
631 
632  m_xobjectPtr = 0;
633 
635  }
636 
637  bool
638  null() const
639  {
640  return m_xobjectPtr == 0 ? true : false;
641  }
642 
643  const XObject&
644  operator*() const
645  {
646  return *m_xobjectPtr;
647  };
648 
649  XObject&
651  {
652  return *m_xobjectPtr;
653  };
654 
655  const XObject*
656  operator->() const
657  {
658  return m_xobjectPtr;
659  };
660 
661  XObject*
663  {
664  return m_xobjectPtr;
665  };
666 
667  const XObject*
668  get() const
669  {
670  return m_xobjectPtr;
671  };
672 
673  XObject*
674  get()
675  {
676  return m_xobjectPtr;
677  };
678 
679 private:
680 
681  XObject* m_xobjectPtr;
682 };
683 
684 
685 
686 inline bool
688  const XObjectPtr& theLHS,
689  const XObjectPtr& theRHS)
690 {
691  return theLHS.m_xobjectPtr == theRHS.m_xobjectPtr;
692 }
693 
694 
695 
696 inline bool
698  const XObjectPtr& theLHS,
699  const XObjectPtr& theRHS)
700 {
701  return !(theLHS == theRHS);
702 }
703 
704 
705 
706 inline bool
708  const XObjectPtr& theLHS,
709  const XObjectPtr& theRHS)
710 {
711  return theLHS.m_xobjectPtr < theRHS.m_xobjectPtr;
712 }
713 
714 
715 
716 XALAN_CPP_NAMESPACE_END
717 
718 
719 
720 #endif // XOBJECT_HEADER_GUARD_1357924680
eObjectType getType() const
Tell what kind of class this is.
Definition: XObject.hpp:282
static void string(double theNumber, XalanDOMString &theString)
Static conversion function.
Definition: XObject.hpp:353
XObjectPtr(XObject *theXObject=0)
Create an XObjectPtr.
Definition: XObject.hpp:595
Definition: XalanNode.hpp:44
size_type length() const
Definition: XalanDOMString.hpp:209
The purpose of this class is to provide a way to get the "preferred" or closest matching type for XOb...
Definition: XObjectTypeCallback.hpp:51
Class to hold reference count information.
Definition: XalanReferenceCountedObject.hpp:33
Local implementation of MutableNodeRefList.
Definition: MutableNodeRefList.hpp:44
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager MemoryManagerType
Definition: XalanMemoryManagement.hpp:39
static const XalanDOMString & s_falseString
Definition: XObject.hpp:556
eObjectType
Enumeration of possible object types.
Definition: XObject.hpp:70
static void string(const XalanNode &theNode, FormatterListener &formatterListener, MemberFunctionPtr function)
Definition: XObject.hpp:383
virtual void dereferenced()=0
static const XalanDOMString & string(bool theBool)
Static conversion function.
Definition: XObject.hpp:326
Definition: XalanDocumentFragment.hpp:38
Definition: XObject.hpp:472
static const XalanDOMString & s_resultTreeFragmentString
Definition: XObject.hpp:562
void release()
Definition: XObject.hpp:628
DoubleToDOMString(double theValue, XalanDOMString &theResult)
Converts a double value into a XalanDOMString.
virtual size_type getLength() const =0
Determine the number of nodes in the list.
virtual void referenced()=0
static void getNodeData(const XalanNode &node, XalanDOMString &data)
Retrieves data for node.
static const XalanDOMString & s_trueString
Definition: XObject.hpp:566
Class to hold XObjectPtr return types.
Definition: XObject.hpp:584
virtual XalanNode * item(size_type index) const =0
Returns the indexth item in the collection.
Definition: XPathExecutionContext.hpp:72
const XObject * operator->() const
Definition: XObject.hpp:656
XObject * operator->()
Definition: XObject.hpp:662
Local implementation of NodeRefList.
Definition: NodeRefListBase.hpp:42
static double number(const XalanDOMString &theString, MemoryManagerType &theManager)
Definition: XObject.hpp:435
XObjectPtr(const XObjectPtr &theSource)
Definition: XObject.hpp:601
static bool boolean(const NodeRefListBase &theNodeList)
Static conversion function.
Definition: XObject.hpp:315
A SAX-based formatter interface for the XSL processor.
Definition: FormatterListener.hpp:62
static void addReference(XalanReferenceCountedObject *theInstance)
Increment reference count.
static const XalanDOMString & s_numberString
Definition: XObject.hpp:560
static MemoryManager & getDummyMemMgr()
bool operator!=(const XObjectPtr &theLHS, const XObjectPtr &theRHS)
Definition: XObject.hpp:697
static void string(const NodeRefListBase &theNodeList, XalanDOMString &theString)
Static conversion function.
Definition: XObject.hpp:397
static void removeReference(XalanReferenceCountedObject *theInstance)
Decrement reference count.
bool operator==(const XObjectPtr &theLHS, const XObjectPtr &theRHS)
Definition: XObject.hpp:687
static void string(bool theBool, FormatterListener &formatterListener, MemberFunctionPtr function)
Definition: XObject.hpp:332
static const XalanDOMString s_emptyString
Definition: XObject.hpp:552
static void string(const NodeRefListBase &theNodeList, FormatterListener &formatterListener, MemberFunctionPtr function)
Definition: XObject.hpp:410
Class to hold XPath return types.
Definition: XObject.hpp:61
static bool boolean(double theNumber)
Static conversion function.
Definition: XObject.hpp:293
void setFactory(XObjectFactory *theFactory)
Definition: XObject.hpp:466
bool operator<(const XObjectPtr &theLHS, const XObjectPtr &theRHS)
Definition: XObject.hpp:707
static void string(double theNumber, FormatterListener &formatterListener, MemberFunctionPtr function)
Definition: XObject.hpp:361
static void DoubleToCharacters(double theDouble, FormatterListener &formatterListener, MemberFunctionPtr function)
static bool boolean(const XalanDOMString &theString)
Static conversion function.
Definition: XObject.hpp:304
static bool isNaN(double theNumber)
Determine if target is not a number.
Definition: DoubleSupport.hpp:73
virtual const XalanDOMChar * getType() const
Retrieve type of exception.
Definition: XObject.hpp:511
~XObjectPtr()
Definition: XObject.hpp:622
const XObject & operator*() const
Definition: XObject.hpp:644
virtual const XalanDOMChar * getType() const
Retrieve type of exception.
Definition: XObject.hpp:487
Definition: XalanDOMString.hpp:42
static double number(bool theBoolean)
Static conversion function.
Definition: XObject.hpp:429
XObject & operator*()
Definition: XObject.hpp:650
XObjectPtr & operator=(const XObjectPtr &theRHS)
Definition: XObject.hpp:608
static const XalanDOMString & s_booleanString
Definition: XObject.hpp:554
static double toDouble(const XalanDOMString &theString, MemoryManager &theManager)
Convert a string to a double value.
static void string(const XalanNode &theNode, XalanDOMString &theString)
Static conversion function.
Definition: XObject.hpp:375
bool null() const
Definition: XObject.hpp:638
#define XALAN_XPATH_EXPORT
Definition: XPathDefinitions.hpp:33
static const XalanDOMString & s_stringString
Definition: XObject.hpp:564
equals(const XalanDOMChar *theLHS, const XalanDOMChar *theRHS, XalanDOMString::size_type theLength)
Compare the contents of two arrays for equality.
This class handles the creation of XObjects and manages their lifetime.
Definition: XObjectFactory.hpp:51
static bool equal(double theLHS, double theRHS)
Compare two double values, taking into account the fact that we must support IEEE 754...
Definition: XalanXPathException.hpp:44
static const XalanDOMString & s_nodesetString
Definition: XObject.hpp:558

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo