Text.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // Text.h
  3. //
  4. // Library: XML
  5. // Package: DOM
  6. // Module: DOM
  7. //
  8. // Definition of the DOM Text class.
  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 DOM_Text_INCLUDED
  16. #define DOM_Text_INCLUDED
  17. #include "Poco/XML/XML.h"
  18. #include "Poco/DOM/CharacterData.h"
  19. #include "Poco/XML/XMLString.h"
  20. namespace Poco {
  21. namespace XML {
  22. class XML_API Text: public CharacterData
  23. /// The Text interface inherits from CharacterData and represents the textual
  24. /// content (termed character data in XML) of an Element or Attr. If there is
  25. /// no markup inside an element's content, the text is contained in a single
  26. /// object implementing the Text interface that is the only child of the element.
  27. /// If there is markup, it is parsed into the information items (elements, comments,
  28. /// etc.) and Text nodes that form the list of children of the element.
  29. ///
  30. /// When a document is first made available via the DOM, there is only one Text
  31. /// node for each block of text. Users may create adjacent Text nodes that represent
  32. /// the contents of a given element without any intervening markup, but should
  33. /// be aware that there is no way to represent the separations between these
  34. /// nodes in XML or HTML, so they will not (in general) persist between DOM
  35. /// editing sessions. The normalize() method on Element merges any such adjacent
  36. /// Text objects into a single node for each block of text.
  37. {
  38. public:
  39. Text* splitText(unsigned long offset);
  40. /// Breaks this node into two nodes at the specified offset, keeping both in
  41. /// the tree as siblings. This node then only contains all the content up to
  42. /// the offset point. A new node of the same type, which is inserted as the
  43. /// next sibling of this node, contains all the content at and after the offset
  44. /// point. When the offset is equal to the length of this node, the new node
  45. /// has no data.
  46. // Node
  47. const XMLString& nodeName() const;
  48. unsigned short nodeType() const;
  49. // Non-standard extensions
  50. XMLString innerText() const;
  51. protected:
  52. Text(Document* pOwnerDocument, const XMLString& data);
  53. Text(Document* pOwnerDocument, const Text& text);
  54. ~Text();
  55. Node* copyNode(bool deep, Document* pOwnerDocument) const;
  56. private:
  57. static const XMLString NODE_NAME;
  58. friend class Document;
  59. };
  60. } } // namespace Poco::XML
  61. #endif // DOM_Text_INCLUDED