Coverage Report

Created: 2025-07-12 06:36

/src/poco/XML/include/Poco/DOM/CharacterData.h
Line
Count
Source (jump to first uncovered line)
1
//
2
// CharacterData.h
3
//
4
// Library: XML
5
// Package: DOM
6
// Module:  DOM
7
//
8
// Definition of the DOM CharacterData 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
16
17
#ifndef DOM_CharacterData_INCLUDED
18
#define DOM_CharacterData_INCLUDED
19
20
21
#include "Poco/XML/XML.h"
22
#include "Poco/DOM/AbstractNode.h"
23
#include "Poco/XML/XMLString.h"
24
25
26
namespace Poco {
27
namespace XML {
28
29
30
class XML_API CharacterData: public AbstractNode
31
  /// The CharacterData interface extends Node with a set of attributes and methods
32
  /// for accessing character data in the DOM. For clarity this set is defined
33
  /// here rather than on each object that uses these attributes and methods.
34
  /// No DOM objects correspond directly to CharacterData, though Text and others
35
  /// do inherit the interface from it. All offsets in this interface start from 0.
36
  ///
37
  /// Text strings in the DOM are represented in either UTF-8 (if XML_UNICODE_WCHAR_T is
38
  /// not defined) or in UTF-16 (if XML_UNICODE_WCHAR_T is defined).
39
  /// Indexing on character data is done in XMLChar units.
40
{
41
public:
42
  const XMLString& data() const;
43
    /// Returns the character data of the node that
44
    /// implements the interface.
45
46
  const XMLString& getData() const;
47
    /// Returns the character data of the node that
48
    /// implements the interface.
49
50
  void setData(const XMLString& data);
51
    /// Sets the character data of the node that
52
    /// implements the interface.
53
54
  unsigned long length() const;
55
    /// Returns the number of XMLChars that are available
56
    /// through getData and substringData. This may have the
57
    /// value zero.
58
59
  XMLString substringData(unsigned long offset, unsigned long count) const;
60
    /// Extracts a range of data from the node.
61
    /// If offset and count exceeds the length, then all
62
    /// the characters to the end of the data are returned.
63
64
  void appendData(const XMLString& arg);
65
    /// Append the string to the end of the character data
66
    /// of the node.
67
68
  void insertData(unsigned long offset, const XMLString& arg);
69
    /// Insert a string at the specified character offset.
70
71
  void deleteData(unsigned long offset, unsigned long count);
72
    /// Remove a range of characters from the node.
73
74
  void replaceData(unsigned long offset, unsigned long count, const XMLString& arg);
75
    /// Replace the characters starting at the specified character
76
    /// offset with the specified string.
77
78
  // Non-standard extensions
79
  XMLString trimmedData() const;
80
    /// Returns the character data of that node with
81
    /// all surrounding whitespace removed.
82
    ///
83
    /// This method is an extension to the W3C Document Object Model.
84
85
  // Node
86
  const XMLString& getNodeValue() const;
87
  void setNodeValue(const XMLString& value);
88
89
protected:
90
  CharacterData(Document* pOwnerDocument, const XMLString& data);
91
  CharacterData(Document* pOwnerDocument, const CharacterData& data);
92
  ~CharacterData();
93
94
private:
95
  XMLString _data;
96
};
97
98
99
//
100
// inlines
101
//
102
inline const XMLString& CharacterData::data() const
103
0
{
104
0
  return _data;
105
0
}
106
107
108
inline const XMLString& CharacterData::getData() const
109
0
{
110
0
  return _data;
111
0
}
112
113
114
inline unsigned long CharacterData::length() const
115
0
{
116
0
  return (unsigned long) _data.length();
117
0
}
118
119
120
} } // namespace Poco::XML
121
122
123
#endif // DOM_CharacterData_INCLUDED