0024023: Revamp the OCCT Handle -- general
[occt.git] / src / LDOM / LDOMString.hxx
CommitLineData
b311480e 1// Created on: 2001-06-25
2// Created by: Alexander GRIGORIEV
973c2be1 3// Copyright (c) 2001-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#ifndef LDOMString_HeaderFile
17#define LDOMString_HeaderFile
18
19#include <LDOMBasicString.hxx>
7fd59977 20
c04c30b3 21class LDOM_MemManager;
22
7fd59977 23// Class LDOMString
24// Represents various object types which can be mapped to XML strings
7fd59977 25// LDOMString is not an independent type: you must be sure that the owner
26// LDOM_Document is never lost during the lifetime of its LDOMStrings - for
27// that it is necessary to keep at least one LDOM_Document or LDOM_Node alive
28// before all LDOMString's (LDOM_AsciiDoc type) are destroyed.
29
30class LDOMString : public LDOMBasicString
31{
32 public:
33 // ---------- PUBLIC METHODS ----------
34
35 LDOMString () : myPtrDoc (NULL) {}
36 // Empty constructor
37
38 LDOMString (const LDOMString& anOther)
39 : LDOMBasicString (anOther), myPtrDoc (anOther.myPtrDoc) {}
40 // Copy constructor
41
42 LDOMString (const Standard_Integer aValue)
43 : LDOMBasicString (aValue), myPtrDoc (NULL) {}
44 // Integer => LDOMString
45
46// Standard_EXPORT LDOMString (const Standard_Real aValue);
47
48 LDOMString (const char * aValue)
49 : LDOMBasicString (aValue), myPtrDoc (NULL) {}
50 // Create LDOM_AsciiFree
51
52 const LDOM_MemManager& getOwnerDocument () const
53 { return * myPtrDoc; }
54
55 LDOMString& operator = (const LDOM_NullPtr * aNull)
56 { LDOMBasicString::operator= (aNull); return *this; }
57
58 LDOMString& operator = (const LDOMString& anOther)
59 {
60 myPtrDoc = anOther.myPtrDoc;
61 LDOMBasicString::operator= (anOther);
62 return * this;
63 }
64
65 private:
66 friend class LDOM_Document;
67 friend class LDOM_Node;
68 friend class LDOM_Element;
69 friend class LDOM_BasicElement;
70 friend class LDOM_BasicAttribute;
71 friend class LDOM_BasicText;
72
73 static LDOMString CreateDirectString
74 (const char * aValue,
75 const LDOM_MemManager& aDoc);
76
77 LDOMString (const LDOMBasicString& anOther,
78 const LDOM_MemManager& aDoc)
79 : LDOMBasicString (anOther), myPtrDoc (&aDoc) {}
80 // Plain copy from LDOMBasicString
81
82 LDOMString (const LDOMBasicString& anOther,
83 const Handle(LDOM_MemManager)& aDoc);
84 // Copy from another string with allocation in the document space
85
86 private:
87 // ---------- PRIVATE FIELDS -------------
88 const LDOM_MemManager * myPtrDoc;
89};
90
91#endif