Locator.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // Locator.h
  3. //
  4. // Library: XML
  5. // Package: SAX
  6. // Module: SAX
  7. //
  8. // SAX Locator Interface.
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef SAX_Locator_INCLUDED
  16. #define SAX_Locator_INCLUDED
  17. #include "Poco/XML/XML.h"
  18. #include "Poco/XML/XMLString.h"
  19. namespace Poco {
  20. namespace XML {
  21. class XML_API Locator
  22. /// Interface for associating a SAX event with a document location.
  23. ///
  24. /// If a SAX parser provides location information to the SAX application, it does so by
  25. /// implementing this interface and then passing an instance to the application using the
  26. /// content handler's setDocumentLocator method. The application can use the object to obtain
  27. /// the location of any other SAX event in the XML source document.
  28. ///
  29. /// Note that the results returned by the object will be valid only during the scope of each
  30. /// callback method: the application will receive unpredictable results if it attempts to use
  31. /// the locator at any other time, or after parsing completes.
  32. ///
  33. /// SAX parsers are not required to supply a locator, but they are very strongly encouraged to
  34. /// do so. If the parser supplies a locator, it must do so before reporting any other document
  35. /// events. If no locator has been set by the time the application receives the startDocument event,
  36. /// the application should assume that a locator is not available.
  37. {
  38. public:
  39. virtual XMLString getPublicId() const = 0;
  40. /// Return the public identifier for the current document event.
  41. ///
  42. /// The return value is the public identifier of the document entity or of the external
  43. /// parsed entity in which the markup triggering the event appears.
  44. virtual XMLString getSystemId() const = 0;
  45. /// Return the system identifier for the current document event.
  46. ///
  47. /// The return value is the system identifier of the document entity or of the external
  48. /// parsed entity in which the markup triggering the event appears.
  49. ///
  50. /// If the system identifier is a URL, the parser must resolve it fully before passing
  51. /// it to the application. For example, a file name must always be provided as a
  52. /// file:... URL, and other kinds of relative URI are also resolved against their bases.
  53. virtual int getLineNumber() const = 0;
  54. /// Return the line number where the current document event ends.
  55. /// Lines are delimited by line ends, which are defined in the XML specification.
  56. ///
  57. /// Warning: The return value from the method is intended only as an approximation for
  58. /// the sake of diagnostics; it is not intended to provide sufficient information to
  59. /// edit the character content of the original XML document. In some cases, these "line"
  60. /// numbers match what would be displayed as columns, and in others they may not match the
  61. /// source text due to internal entity expansion.
  62. ///
  63. /// The return value is an approximation of the line number in the document entity or external
  64. /// parsed entity where the markup triggering the event appears.
  65. ///
  66. /// If possible, the SAX driver should provide the line position of the first character after
  67. /// the text associated with the document event. The first line is line 1.
  68. virtual int getColumnNumber() const = 0;
  69. /// Return the column number where the current document event ends.
  70. /// This is one-based number of characters since the last line end.
  71. ///
  72. /// Warning: The return value from the method is intended only as an approximation
  73. /// for the sake of diagnostics; it is not intended to provide sufficient information
  74. /// to edit the character content of the original XML document. For example, when lines
  75. /// contain combining character sequences, wide characters, surrogate pairs, or bi-directional
  76. /// text, the value may not correspond to the column in a text editor's display.
  77. ///
  78. /// The return value is an approximation of the column number in the document entity or external
  79. /// parsed entity where the markup triggering the event appears.
  80. ///
  81. /// If possible, the SAX driver should provide the line position of the first character after
  82. /// the text associated with the document event. The first column in each line is column 1.
  83. protected:
  84. virtual ~Locator();
  85. };
  86. } } // namespace Poco::XML
  87. #endif // SAX_Locator_INCLUDED