Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(XERCESC_INCLUDE_GUARD_PLATFORMUTILS_HPP)
00023 #define XERCESC_INCLUDE_GUARD_PLATFORMUTILS_HPP
00024
00025 #include <xercesc/util/XercesDefs.hpp>
00026 #include <xercesc/util/XMLException.hpp>
00027 #include <xercesc/util/PanicHandler.hpp>
00028
00029 #include <xercesc/util/XMLFileMgr.hpp>
00030 #include <xercesc/util/XMLMutexMgr.hpp>
00031
00032 XERCES_CPP_NAMESPACE_BEGIN
00033
00034 class XMLMsgLoader;
00035 class XMLNetAccessor;
00036 class XMLTransService;
00037 class MemoryManager;
00038 class XMLMutex;
00039
00040
00041
00042
00043
00044
00045
00046 class XMLUTIL_EXPORT XMLDeleter
00047 {
00048 public :
00049 virtual ~XMLDeleter();
00050
00051 protected :
00052 XMLDeleter();
00053
00054 private :
00055 XMLDeleter(const XMLDeleter&);
00056 XMLDeleter& operator=(const XMLDeleter&);
00057 };
00058
00059
00068 class XMLUTIL_EXPORT XMLPlatformUtils
00069 {
00070 public :
00071
00074
00087 static XMLNetAccessor* fgNetAccessor;
00088
00099 static XMLTransService* fgTransService;
00100 #ifdef OS390
00101 static XMLTransService* fgTransService2;
00102 #endif
00103
00108 static PanicHandler* fgUserPanicHandler;
00109
00114 static PanicHandler* fgDefaultPanicHandler;
00115
00121 static MemoryManager* fgMemoryManager;
00122
00123 static XMLFileMgr* fgFileMgr;
00124 static XMLMutexMgr* fgMutexMgr;
00125
00132 static XMLMutex* fgAtomicMutex;
00133
00134 static bool fgXMLChBigEndian;
00135 static bool fgSSE2ok;
00137
00138
00141
00173 static void Initialize(const char* const locale = XMLUni::fgXercescDefaultLocale
00174 , const char* const nlsHome = 0
00175 , PanicHandler* const panicHandler = 0
00176 , MemoryManager* const memoryManager = 0);
00177
00227 static void Initialize(XMLSize_t initialDOMHeapAllocSize
00228 , XMLSize_t maxDOMHeapAllocSize
00229 , XMLSize_t maxDOMSubAllocationSize
00230 , const char* const locale = XMLUni::fgXercescDefaultLocale
00231 , const char* const nlsHome = 0
00232 , PanicHandler* const panicHandler = 0
00233 , MemoryManager* const memoryManager = 0);
00234
00241 static void Terminate();
00242
00259 static void panic
00260 (
00261 const PanicHandler::PanicReasons reason
00262 );
00263
00265
00268
00273 static XMLFileMgr* makeFileMgr(MemoryManager* const manager);
00274
00288 static XMLFilePos curFilePos(FileHandle theFile
00289 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00290
00301 static void closeFile(FileHandle theFile
00302 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00303
00314 static XMLFilePos fileSize(FileHandle theFile
00315 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00316
00327 static FileHandle openFile(const char* const fileName
00328 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00329
00340 static FileHandle openFile(const XMLCh* const fileName
00341 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00342
00353 static FileHandle openFileToWrite(const char* const fileName
00354 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00355
00366 static FileHandle openFileToWrite(const XMLCh* const fileName
00367 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00368
00379 static FileHandle openStdInHandle(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00380
00397 static XMLSize_t readFileBuffer
00398 (
00399 FileHandle theFile
00400 , const XMLSize_t toRead
00401 , XMLByte* const toFill
00402 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00403 );
00404
00419 static void writeBufferToFile
00420 (
00421 FileHandle const theFile
00422 , XMLSize_t toWrite
00423 , const XMLByte* const toFlush
00424 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00425 );
00426
00436 static void resetFile(FileHandle theFile
00437 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00438
00440
00441
00465 static XMLCh* getFullPath
00466 (
00467 const XMLCh* const srcPath
00468 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00469 );
00470
00484 static XMLCh* getCurrentDirectory
00485 (
00486 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00487 );
00488
00498 static inline bool isAnySlash(XMLCh c);
00499
00509 static void removeDotSlash(XMLCh* const srcPath
00510 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00511
00522 static void removeDotDotSlash(XMLCh* const srcPath
00523 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00524
00538 static bool isRelative(const XMLCh* const toCheck
00539 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00540 );
00541
00561 static XMLCh* weavePaths
00562 (
00563 const XMLCh* const basePath
00564 , const XMLCh* const relativePath
00565 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00566 );
00568
00571
00581 static unsigned long getCurrentMillis();
00583
00586
00594 static XMLMutexMgr* makeMutexMgr(MemoryManager* const manager);
00595
00604 static void closeMutex(void* const mtxHandle, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00605
00613 static void lockMutex(void* const mtxHandle);
00614
00624 static void* makeMutex(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00625
00638 static void unlockMutex(void* const mtxHandle);
00639
00641
00642
00645
00653 static XMLMsgLoader* loadMsgSet(const XMLCh* const msgDomain);
00654
00656
00657
00671 static void recognizeNEL(bool state
00672 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00673
00677 static bool isNELRecognized();
00679
00691 static void strictIANAEncoding(const bool state);
00692
00697 static bool isStrictIANAEncoding();
00699
00707 static inline XMLSize_t alignPointerForNewBlockAllocation(XMLSize_t ptrSize);
00708
00709 private :
00710
00711
00712
00713 XMLPlatformUtils();
00714
00717
00723 static XMLMsgLoader* loadAMsgSet(const XMLCh* const msgDomain);
00724
00734 static XMLNetAccessor* makeNetAccessor();
00735
00746 static XMLTransService* makeTransService();
00747
00755 static int searchSlashDotDotSlash(XMLCh* const srcPath);
00756
00758
00761
00768 static bool fgMemMgrAdopted;
00769
00771 };
00772
00773
00774 MakeXMLException(XMLPlatformUtilsException, XMLUTIL_EXPORT)
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799 inline XMLSize_t
00800 XMLPlatformUtils::alignPointerForNewBlockAllocation(XMLSize_t ptrSize)
00801 {
00802
00803
00804
00805
00806 #ifdef XML_PLATFORM_NEW_BLOCK_ALIGNMENT
00807 static const XMLSize_t alignment = XML_PLATFORM_NEW_BLOCK_ALIGNMENT;
00808 #else
00809 static const XMLSize_t alignment = (sizeof(void*) >= sizeof(double)) ? sizeof(void*) : sizeof(double);
00810 #endif
00811
00812
00813 XMLSize_t current = ptrSize % alignment;
00814
00815
00816 return (current == 0)
00817 ? ptrSize
00818 : (ptrSize + alignment - current);
00819 }
00820
00821
00822
00823
00824
00825
00826 inline XMLDeleter::~XMLDeleter()
00827 {
00828 }
00829
00830
00831
00832
00833 inline XMLDeleter::XMLDeleter()
00834 {
00835 }
00836
00837 XERCES_CPP_NAMESPACE_END
00838
00839 #endif