XmlCharRef.d.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * Copyright (C) 2016-2019 Michael Kourlas
  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. /**
  17. * The options used to create a new character reference.
  18. */
  19. export interface IXmlCharRefOptions {
  20. /**
  21. * The character to represent using the reference.
  22. */
  23. char: string;
  24. /**
  25. * Whether to use the hexadecimal or decimal representation for the
  26. * reference. Defaults to false.
  27. */
  28. hex?: boolean;
  29. }
  30. /**
  31. * Represents a character reference.
  32. *
  33. * A character reference is structured as follows, where `{dec}` is the
  34. * decimal representation code point corresponding to a particular Unicode
  35. * character:
  36. *
  37. * ```xml
  38. * &#{dec};
  39. * ```
  40. *
  41. * The corresponding hexadecimal version is structured as follows, where
  42. * `{hex}` is the hexadecimal representation code point corresponding to a
  43. * particular Unicode character:
  44. *
  45. * ```xml
  46. * &#x{hex};
  47. * ```
  48. *
  49. * Unicode characters outside of the Basic Multilingual Plane are represented
  50. * using a surrogate pair consisting of two character references.
  51. *
  52. * The `{dec}` and `{hex}` values are defined by the `char` and `hex`
  53. * properties of this node; the former is the character to be represented while
  54. * the latter indicates whether the decimal or hexadecimal representation
  55. * should be used.
  56. */
  57. export default class XmlCharRef<Parent> {
  58. private readonly _validation;
  59. private readonly _parent;
  60. private _char;
  61. private _hex;
  62. constructor(parent: Parent, validation: boolean, options: IXmlCharRefOptions);
  63. /**
  64. * Gets the character of this character reference.
  65. */
  66. get char(): string;
  67. /**
  68. * Sets the character of this character reference.
  69. */
  70. set char(char: string);
  71. /**
  72. * Gets whether the decimal or hexadecimal representation should be used
  73. * for this character reference.
  74. */
  75. get hex(): boolean;
  76. /**
  77. * Sets whether the decimal or hexadecimal representation should be used
  78. * for this character reference.
  79. */
  80. set hex(hex: boolean);
  81. /**
  82. * Returns an XML string representation of this character reference.
  83. */
  84. toString(): string;
  85. /**
  86. * Returns the parent of this character reference.
  87. */
  88. up(): Parent;
  89. }