UNPKG

1.35 kBTypeScriptView Raw
1import { IToXmlOptions } from './options';
2import { IElement } from './util';
3/**
4 * Value object.
5 */
6export declare abstract class Value {
7 /**
8 * Value type.
9 */
10 static readonly TYPE: string;
11 /**
12 * Tag names.
13 */
14 static readonly TAG_NAMES: string[];
15 /**
16 * Value constructor.
17 */
18 constructor();
19 /**
20 * Value type.
21 *
22 * @returns Type string.
23 */
24 get type(): string;
25 /**
26 * Cast to specific type or null.
27 *
28 * @param Type Type constructor.
29 * @returns This object or null.
30 */
31 castTo<T extends typeof Value>(Type: T): T['prototype'] | null;
32 /**
33 * Cast to specific type or throw.
34 *
35 * @param Type Type constructor.
36 * @returns This object.
37 */
38 castAs<T extends typeof Value>(Type: T): T['prototype'];
39 /**
40 * Decode document from string.
41 *
42 * @param xml XML string.
43 */
44 fromXml(xml: string): void;
45 /**
46 * Decode value from element.
47 *
48 * @param element XML element.
49 */
50 abstract fromXmlElement(element: Readonly<IElement>): void;
51 /**
52 * Encode Value to string.
53 *
54 * @param options Options object.
55 * @param depth Indent depth.
56 * @returns Xml string.
57 */
58 abstract toXml(options?: Readonly<IToXmlOptions> | null, depth?: number): string;
59}