Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:12

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  public:
0036   enum StringType {
0037     LDOM_NULL = 0,
0038     LDOM_Integer,
0039 //    LDOM_Real,
0040     LDOM_AsciiFree,             // String not connected to any container
0041     LDOM_AsciiDoc,              // String connected to LDOM_Document (container)
0042     LDOM_AsciiDocClear,         // --"--"--, consists of only XML-valid chars
0043     LDOM_AsciiHashed            // String connected to hash table
0044   };
0045 
0046   Standard_EXPORT ~LDOMBasicString ();
0047 
0048   StringType Type       () const              { return myType; }
0049 
0050   Standard_EXPORT Standard_Boolean
0051         GetInteger      (Standard_Integer& aResult) const;
0052   //    Conversion to Integer (only for LDOM_Integer)
0053 
0054   const char *
0055         GetString       () const        { return myType == LDOM_Integer ||
0056                                                  myType == LDOM_NULL ?
0057                                             "" : (const char *) myVal.ptr; }
0058   //    Conversion to char * (only for LDOM_Ascii*)
0059 
0060   Standard_EXPORT Standard_Boolean
0061         equals          (const LDOMBasicString& anOther) const;
0062   //    Compare two strings by content
0063 
0064   Standard_EXPORT LDOMBasicString&
0065         operator =      (const LDOM_NullPtr *);
0066 
0067   Standard_EXPORT LDOMBasicString&
0068         operator =      (const LDOMBasicString& anOther);
0069 
0070   Standard_Boolean
0071         operator ==     (const LDOM_NullPtr *) const
0072                                                 { return myType==LDOM_NULL; }
0073   Standard_Boolean
0074         operator !=     (const LDOM_NullPtr *) const
0075                                                 { return myType!=LDOM_NULL; }
0076 
0077   Standard_Boolean
0078         operator ==     (const LDOMBasicString& anOther) const
0079         {
0080           return myType==anOther.myType && myVal.i==anOther.myVal.i;
0081         }
0082 
0083   Standard_Boolean
0084         operator !=     (const LDOMBasicString& anOther) const
0085         {
0086           return myType!=anOther.myType || myVal.i!=anOther.myVal.i;
0087         }
0088 
0089 //      AGV auxiliary API
0090   Standard_EXPORT operator TCollection_AsciiString      () const;
0091 
0092   Standard_EXPORT operator TCollection_ExtendedString   () const;
0093 
0094   LDOMBasicString                 ()
0095     : myType (LDOM_NULL)             { myVal.ptr = NULL; }
0096   // Empty constructor
0097 
0098   Standard_EXPORT LDOMBasicString (const LDOMBasicString& anOther);
0099   // Copy constructor
0100 
0101   LDOMBasicString                 (const Standard_Integer aValue)
0102     : myType (LDOM_Integer)             { myVal.i = aValue; }
0103 
0104   Standard_EXPORT LDOMBasicString (const char           * aValue);
0105   //    Create LDOM_AsciiFree
0106 
0107   Standard_EXPORT LDOMBasicString (const char           * aValue,
0108                                    const Handle(LDOM_MemManager)& aDoc);
0109   //    Create LDOM_AsciiDoc
0110 
0111   Standard_EXPORT LDOMBasicString (const char             * aValue,
0112                                    const Standard_Integer aLen,
0113                                    const Handle(LDOM_MemManager)&   aDoc);
0114   //    Create LDOM_AsciiDoc
0115 
0116  protected:
0117   // ---------- PROTECTED METHODS ----------
0118   void            SetDirect       (const StringType aType, const char * aValue)
0119     { myType = aType; myVal.ptr = (void *) aValue; }
0120     
0121 
0122  protected:
0123   // ---------- PROTECTED FIELDS ----------
0124 
0125   StringType            myType;
0126   union {
0127     int         i;
0128     void        * ptr;
0129   }                     myVal;
0130   friend char * db_pretty_print (const LDOMBasicString *, int, char *);
0131 };
0132 
0133 #endif