00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file LocatorImpl.h 00006 * 00007 * LocatorImpl.h,v 1.8 2003/07/19 19:04:10 dhinton Exp 00008 * 00009 * @author Nanbor Wang <nanbor@cs.wustl.edu> 00010 * @author Krishnakumar Balasubramanian <kitty@cs.wustl.edu> 00011 */ 00012 //============================================================================= 00013 00014 #ifndef ACEXML_LOCALTORIMPL_H 00015 #define ACEXML_LOCALTORIMPL_H 00016 00017 #include /**/ "ace/pre.h" 00018 #include "ACEXML/common/ACEXML_Export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 #pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "ACEXML/common/Locator.h" 00025 00026 /** 00027 * @class ACEXML_LocatorImpl LocatorImpl.h "ACEXML/common/LocatorImpl.h" 00028 * 00029 * @brief ACEXML_LocatorImpl is an implementation of ACEXML_Locator. 00030 * 00031 * This class is available mainly for application writers, who can 00032 * use it to make a persistent snapshot of a locator at any point 00033 * during a document parse: 00034 * 00035 * @code 00036 * ACEXML_Locator locator; 00037 * ACEXML_Locator startloc; 00038 * 00039 * public void setLocator (ACEXML_Locator locator) 00040 * { 00041 * // note the locator 00042 * this.locator = locator; 00043 * } 00044 * 00045 * public void startDocument () 00046 * { 00047 * // save the location of the start of the document 00048 * // for future use. 00049 * ACEXML_Locator startloc = new ACEXML_LocatorImpl(locator); 00050 * } 00051 * @endcode 00052 * 00053 * Normally, parser writers will not use this class, since it is more 00054 * efficient to provide location information only when requested, 00055 * rather than constantly updating a Locator object. 00056 * 00057 * @todo ACEXML parser doesn't support the use of Locator yet. 00058 * 00059 * @sa ACEXML_Locator 00060 */ 00061 class ACEXML_Export ACEXML_LocatorImpl : public ACEXML_Locator 00062 { 00063 public: 00064 /* 00065 * Default constructor. 00066 */ 00067 ACEXML_LocatorImpl (void); 00068 00069 /** 00070 * Construct a locator with systemId and publicId 00071 * 00072 */ 00073 ACEXML_LocatorImpl (const ACEXML_Char* systemId, 00074 const ACEXML_Char* publicId); 00075 /** 00076 * Copy constructor. Create a persistent copy of the current state 00077 * of a locator. When the original locator changes, this copy will 00078 * still keep the original values (and it can be used outside the 00079 * scope of DocumentHandler methods). 00080 */ 00081 ACEXML_LocatorImpl (const ACEXML_Locator& locator); 00082 00083 /* 00084 * Destructor. 00085 */ 00086 virtual ~ACEXML_LocatorImpl (void); 00087 00088 /* 00089 * Return the column number where the current document event ends. 00090 */ 00091 virtual int getColumnNumber (void) const; 00092 00093 /* 00094 * Return the line number where the current document event ends. 00095 */ 00096 virtual int getLineNumber (void) const; 00097 00098 /* 00099 * Return the public identifier for the current document event. 00100 */ 00101 virtual const ACEXML_Char *getPublicId (void) const; 00102 00103 /* 00104 * Return the system identifier for the current document event. 00105 */ 00106 virtual const ACEXML_Char *getSystemId (void) const; 00107 00108 /* 00109 * Set the column number of this locator. 00110 */ 00111 void setColumnNumber (int cn); 00112 00113 /* 00114 * Set the line number of this locator. 00115 */ 00116 void setLineNumber (int ln); 00117 00118 /* 00119 * Set the public identifier of this locator. 00120 */ 00121 void setPublicId (const ACEXML_Char *id); 00122 00123 /* 00124 * Set the system identifier of this locator. 00125 */ 00126 void setSystemId (const ACEXML_Char *id); 00127 00128 /* 00129 * Increment the line number. 00130 */ 00131 void incrLineNumber (); 00132 00133 /* 00134 * Increment the column number. 00135 */ 00136 void incrColumnNumber (); 00137 00138 /* 00139 * Reset the Locator information. This is necessary because one might 00140 * want to use the same parser to parse multiple files. In that case, 00141 * tying the life of the Locator with the parser is not appropriate. The 00142 * parser calls this method as soon as issuing an endDocument() call. 00143 */ 00144 void reset (void); 00145 00146 private: 00147 ACEXML_Char *publicId_; 00148 ACEXML_Char *systemId_; 00149 int lineNumber_; 00150 int columnNumber_; 00151 }; 00152 00153 #if defined (__ACEXML_INLINE__) 00154 # include "ACEXML/common/LocatorImpl.i" 00155 #endif /* __ACEXML_INLINE__ */ 00156 00157 #include /**/ "ace/post.h" 00158 00159 #endif /* ACEXML_LOCALTORIMPL_H */