1 // Created on: 2002-02-08
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef LDOM_CharReference_HeaderFile
17 #define LDOM_CharReference_HeaderFile
19 #include <Standard_TypeDef.hxx>
21 // Class LDOM_CharReference: treatment of character reference and internal
22 // entities in input and output streams
23 // On output all 256 characters are classified as this:
24 // For string values of attributes:
25 // 0x09,0x0a,0x0d,0x20,0x21,0x23-0x25,0x27-0x3b,0x3d,0x3f-0x7f,0xc0-0xff
26 // are treated as normal characters (no relacement)
27 // 0x22("e;), 0x26(&), 0x3c(<), 0x3e(>)
28 // are replaced by predefined entity reference.
29 // 0x01-0x08,0x0b,0x0c,0x0e-0x1f,0x80-0xbf
30 // are replaced by character references
31 // For other strings (text):
32 // 0x09,0x0a,0x0d,0x20-0x25,0x27-0x3b,0x3d,0x3f-0x7f,0xc0-0xff
33 // are treated as normal characters (no relacement)
34 // 0x26(&), 0x3c(<), 0x3e(>)
35 // are replaced by predefined entity reference.
36 // 0x01-0x08,0x0b,0x0c,0x0e-0x1f,0x80-0xbf
37 // are replaced by character references
38 // For CDATA, element tag names and attribute names no replacements are made
39 // Note that apostrophe (\') is not treated as markup on output (all relevant
40 // markup is produced by quote characters (\")).
42 class LDOM_CharReference
45 // ---------- PUBLIC METHODS ----------
47 static char * Decode (char * theSrc, Standard_Integer& theLen);
49 static char * Encode (const char * theSrc, Standard_Integer& theLen,
50 const Standard_Boolean isAttribute);
51 // Encodes the string theSrc containing any byte characters 0x00-0xFF
52 // Returns the encoded string. If (return value) != theSrc the returned
53 // string should be deleted in caller routine (via delete[]).
54 // The output parameter theLen gives the length of the encoded string
55 // With isAttribute==True additionally encodes to $quot; for attr values
58 // ---------- PRIVATE FIELDS ----------
60 static int myTab [256];