7fd59977 |
1 | // File: LDOM_CharReference.hxx |
2 | // Created: 08.02.02 19:53:39 |
3 | // Author: Alexander GRIGORIEV |
4 | // Copyright: Open Cascade 2001 |
5 | |
6 | |
7 | #ifndef LDOM_CharReference_HeaderFile |
8 | #define LDOM_CharReference_HeaderFile |
9 | |
10 | #include <Standard_TypeDef.hxx> |
11 | |
12 | // Class LDOM_CharReference: treatment of character reference and internal |
13 | // entities in input and output streams |
14 | // |
15 | // On output all 256 characters are classified as this: |
16 | // For string values of attributes: |
17 | // 0x09,0x0a,0x0d,0x20,0x21,0x23-0x25,0x27-0x3b,0x3d,0x3f-0x7f,0xc0-0xff |
18 | // are treated as normal characters (no relacement) |
19 | // 0x22("e;), 0x26(&), 0x3c(<), 0x3e(>) |
20 | // are replaced by predefined entity reference. |
21 | // 0x01-0x08,0x0b,0x0c,0x0e-0x1f,0x80-0xbf |
22 | // are replaced by character references |
23 | // For other strings (text): |
24 | // 0x09,0x0a,0x0d,0x20-0x25,0x27-0x3b,0x3d,0x3f-0x7f,0xc0-0xff |
25 | // are treated as normal characters (no relacement) |
26 | // 0x26(&), 0x3c(<), 0x3e(>) |
27 | // are replaced by predefined entity reference. |
28 | // 0x01-0x08,0x0b,0x0c,0x0e-0x1f,0x80-0xbf |
29 | // are replaced by character references |
30 | // For CDATA, element tag names and attribute names no replacements are made |
31 | // Note that apostrophe (\') is not treated as markup on output (all relevant |
32 | // markup is produced by quote characters (\")). |
33 | |
34 | class LDOM_CharReference |
35 | { |
36 | public: |
37 | // ---------- PUBLIC METHODS ---------- |
38 | |
39 | static char * Decode (char * theSrc, Standard_Integer& theLen); |
40 | |
41 | static char * Encode (const char * theSrc, Standard_Integer& theLen, |
42 | const Standard_Boolean isAttribute); |
43 | // Encodes the string theSrc containing any byte characters 0x00-0xFF |
44 | // Returns the encoded string. If (return value) != theSrc the returned |
45 | // string should be deleted in caller routine (via delete[]). |
46 | // The output parameter theLen gives the length of the encoded string |
47 | // With isAttribute==True additionally encodes to $quot; for attr values |
48 | |
49 | private: |
50 | // ---------- PRIVATE FIELDS ---------- |
51 | |
52 | static int myTab [256]; |
53 | }; |
54 | |
55 | #endif |