1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
// File: LDOMBasicString.hxx
// Created: 26.06.01 16:41:14
// Author: Alexander GRIGORIEV
// Copyright: OpenCascade 2001
#ifndef LDOMBasicString_HeaderFile
#define LDOMBasicString_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_Macro.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
class Handle(LDOM_MemManager);
class LDOM_NullPtr;
class TCollection_AsciiString;
class TCollection_ExtendedString;
// Block of comments describing class LDOMBasicString
//
class LDOMBasicString
{
friend class LDOM_MemManager;
friend class LDOM_Node;
public:
enum StringType {
LDOM_NULL = 0,
LDOM_Integer,
// LDOM_Real,
LDOM_AsciiFree, // String not connected to any container
LDOM_AsciiDoc, // String connected to LDOM_Document (container)
LDOM_AsciiDocClear, // --"--"--, consists of only XML-valid chars
LDOM_AsciiHashed // String connected to hash table
};
Standard_EXPORT ~LDOMBasicString ();
StringType Type () const { return myType; }
Standard_EXPORT Standard_Boolean
GetInteger (Standard_Integer& aResult) const;
// Conversion to Integer (only for LDOM_Integer)
const char *
GetString () const { return myType == LDOM_Integer ||
myType == LDOM_NULL ?
"" : (const char *) myVal.ptr; }
// Conversion to char * (only for LDOM_Ascii*)
Standard_EXPORT Standard_Boolean
equals (const LDOMBasicString& anOther) const;
// Compare two strings by content
Standard_EXPORT LDOMBasicString&
operator = (const LDOM_NullPtr *);
Standard_EXPORT LDOMBasicString&
operator = (const LDOMBasicString& anOther);
Standard_Boolean
operator == (const LDOM_NullPtr *) const
{ return myType==LDOM_NULL; }
Standard_Boolean
operator != (const LDOM_NullPtr *) const
{ return myType!=LDOM_NULL; }
Standard_Boolean
operator == (const LDOMBasicString& anOther) const
{
return myType==anOther.myType && myVal.i==anOther.myVal.i;
}
Standard_Boolean
operator != (const LDOMBasicString& anOther) const
{
return myType!=anOther.myType || myVal.i!=anOther.myVal.i;
}
// AGV auxiliary API
Standard_EXPORT operator TCollection_AsciiString () const;
Standard_EXPORT operator TCollection_ExtendedString () const;
LDOMBasicString ()
: myType (LDOM_NULL) { myVal.ptr = NULL; }
// Empty constructor
Standard_EXPORT LDOMBasicString (const LDOMBasicString& anOther);
// Copy constructor
LDOMBasicString (const Standard_Integer aValue)
: myType (LDOM_Integer) { myVal.i = aValue; }
Standard_EXPORT LDOMBasicString (const char * aValue);
// Create LDOM_AsciiFree
Standard_EXPORT LDOMBasicString (const char * aValue,
const Handle(LDOM_MemManager)& aDoc);
// Create LDOM_AsciiDoc
Standard_EXPORT LDOMBasicString (const char * aValue,
const Standard_Integer aLen,
const Handle(LDOM_MemManager)& aDoc);
// Create LDOM_AsciiDoc
protected:
// ---------- PROTECTED METHODS ----------
void SetDirect (const StringType aType, const char * aValue)
{ myType = aType; myVal.ptr = (void *) aValue; }
protected:
// ---------- PROTECTED FIELDS ----------
StringType myType;
union {
int i;
void * ptr;
} myVal;
friend char * db_pretty_print (const LDOMBasicString *, int, char *);
};
#endif
|