Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:25:25

0001 // Created on: 2001-06-26
0002 // Created by: Alexander GRIGORIEV
0003 // Copyright (c) 2001-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef LDOMBasicString_HeaderFile
0017 #define LDOMBasicString_HeaderFile
0018 
0019 #include <Standard_Macro.hxx>
0020 #include <TCollection_AsciiString.hxx>
0021 #include <TCollection_ExtendedString.hxx>
0022 
0023 class LDOM_MemManager;
0024 class LDOM_NullPtr;
0025 class TCollection_AsciiString;
0026 class TCollection_ExtendedString;
0027 
0028 //  Block of comments describing class LDOMBasicString
0029 //
0030 
0031 class LDOMBasicString
0032 {
0033   friend class LDOM_MemManager;
0034   friend class LDOM_Node;
0035 
0036 public:
0037   enum StringType
0038   {
0039     LDOM_NULL = 0,
0040     LDOM_Integer,
0041     //    LDOM_Real,
0042     LDOM_AsciiFree,     // String not connected to any container
0043     LDOM_AsciiDoc,      // String connected to LDOM_Document (container)
0044     LDOM_AsciiDocClear, // --"--"--, consists of only XML-valid chars
0045     LDOM_AsciiHashed    // String connected to hash table
0046   };
0047 
0048   Standard_EXPORT ~LDOMBasicString();
0049 
0050   StringType Type() const { return myType; }
0051 
0052   Standard_EXPORT Standard_Boolean GetInteger(Standard_Integer& aResult) const;
0053 
0054   //    Conversion to Integer (only for LDOM_Integer)
0055 
0056   const char* GetString() const
0057   {
0058     return myType == LDOM_Integer || myType == LDOM_NULL ? "" : (const char*)myVal.ptr;
0059   }
0060 
0061   //    Conversion to char * (only for LDOM_Ascii*)
0062 
0063   Standard_EXPORT Standard_Boolean equals(const LDOMBasicString& anOther) const;
0064   //    Compare two strings by content
0065 
0066   Standard_EXPORT LDOMBasicString& operator=(const LDOM_NullPtr*);
0067 
0068   Standard_EXPORT LDOMBasicString& operator=(const LDOMBasicString& anOther);
0069 
0070   Standard_Boolean operator==(const LDOM_NullPtr*) const { return myType == LDOM_NULL; }
0071 
0072   Standard_Boolean operator!=(const LDOM_NullPtr*) const { return myType != LDOM_NULL; }
0073 
0074   Standard_Boolean operator==(const LDOMBasicString& anOther) const
0075   {
0076     return myType == anOther.myType && myVal.i == anOther.myVal.i;
0077   }
0078 
0079   Standard_Boolean operator!=(const LDOMBasicString& anOther) const
0080   {
0081     return myType != anOther.myType || myVal.i != anOther.myVal.i;
0082   }
0083 
0084   //      AGV auxiliary API
0085   Standard_EXPORT operator TCollection_AsciiString() const;
0086 
0087   Standard_EXPORT operator TCollection_ExtendedString() const;
0088 
0089   LDOMBasicString()
0090       : myType(LDOM_NULL)
0091   {
0092     myVal.ptr = NULL;
0093   }
0094 
0095   // Empty constructor
0096 
0097   Standard_EXPORT LDOMBasicString(const LDOMBasicString& anOther);
0098 
0099   // Copy constructor
0100 
0101   LDOMBasicString(const Standard_Integer aValue)
0102       : myType(LDOM_Integer)
0103   {
0104     myVal.i = aValue;
0105   }
0106 
0107   Standard_EXPORT LDOMBasicString(const char* aValue);
0108   //    Create LDOM_AsciiFree
0109 
0110   Standard_EXPORT LDOMBasicString(const char* aValue, const Handle(LDOM_MemManager)& aDoc);
0111   //    Create LDOM_AsciiDoc
0112 
0113   Standard_EXPORT LDOMBasicString(const char*                    aValue,
0114                                   const Standard_Integer         aLen,
0115                                   const Handle(LDOM_MemManager)& aDoc);
0116   //    Create LDOM_AsciiDoc
0117 
0118 protected:
0119   // ---------- PROTECTED METHODS ----------
0120   void SetDirect(const StringType aType, const char* aValue)
0121   {
0122     myType    = aType;
0123     myVal.ptr = (void*)aValue;
0124   }
0125 
0126 protected:
0127   // ---------- PROTECTED FIELDS ----------
0128 
0129   StringType myType;
0130 
0131   union {
0132     int   i;
0133     void* ptr;
0134   } myVal;
0135 
0136   friend char* db_pretty_print(const LDOMBasicString*, int, char*);
0137 };
0138 
0139 #endif