|
||||
File indexing completed on 2025-01-18 10:15:12
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 /* 0019 * $Id$ 0020 */ 0021 0022 #if !defined(XERCESC_INCLUDE_GUARD_PLATFORMUTILS_HPP) 0023 #define XERCESC_INCLUDE_GUARD_PLATFORMUTILS_HPP 0024 0025 #include <xercesc/util/XercesDefs.hpp> 0026 #include <xercesc/util/XMLException.hpp> 0027 #include <xercesc/util/PanicHandler.hpp> 0028 0029 #include <xercesc/util/XMLFileMgr.hpp> 0030 #include <xercesc/util/XMLMutexMgr.hpp> 0031 0032 XERCES_CPP_NAMESPACE_BEGIN 0033 0034 class XMLMsgLoader; 0035 class XMLNetAccessor; 0036 class XMLTransService; 0037 class MemoryManager; 0038 class XMLMutex; 0039 0040 // 0041 // For internal use only 0042 // 0043 // This class provides a simple abstract API via which lazily evaluated 0044 // data can be cleaned up. 0045 // 0046 class XMLUTIL_EXPORT XMLDeleter 0047 { 0048 public : 0049 virtual ~XMLDeleter(); 0050 0051 protected : 0052 XMLDeleter(); 0053 0054 private : 0055 XMLDeleter(const XMLDeleter&); 0056 XMLDeleter& operator=(const XMLDeleter&); 0057 }; 0058 0059 0060 /** 0061 * Utilities that must be implemented in a platform-specific way. 0062 * 0063 * This class contains methods that must be implemented in a platform 0064 * specific manner. The actual implementations of these methods are 0065 * available in the per-platform files inside <code>src/util/Platforms 0066 * </code>. 0067 */ 0068 class XMLUTIL_EXPORT XMLPlatformUtils 0069 { 0070 public : 0071 0072 /** @name Public Static Data */ 0073 //@{ 0074 0075 /** The network accessor 0076 * 0077 * This is provided by the per-platform driver, so each platform can 0078 * choose what actual implementation it wants to use. The object must 0079 * be dynamically allocated. 0080 * 0081 * <i>Note that you may optionally, if your platform driver does not 0082 * install a network accessor, set it manually from your client code 0083 * after calling Initialize(). This works because this object is 0084 * not required during initialization, and only comes into play during 0085 * actual XML parsing.</i> 0086 */ 0087 static XMLNetAccessor* fgNetAccessor; 0088 0089 /** The transcoding service. 0090 * 0091 * This is provided by the per platform driver, so each platform can 0092 * choose what implementation it wants to use. When the platform 0093 * independent initialization code needs to get a transcoding service 0094 * object, it will call <code>makeTransService()</code> to ask the 0095 * per-platform code to create one. Only one transcoding service 0096 * object is requested per-process, so it is shared and synchronized 0097 * among parser instances within that process. 0098 */ 0099 static XMLTransService* fgTransService; 0100 #ifdef OS390 0101 static XMLTransService* fgTransService2; 0102 #endif 0103 0104 /** The Panic Handler 0105 * 0106 * This is the application provided panic handler. 0107 */ 0108 static PanicHandler* fgUserPanicHandler; 0109 0110 /** The Panic Handler 0111 * 0112 * This is the default panic handler. 0113 */ 0114 static PanicHandler* fgDefaultPanicHandler; 0115 0116 /** The configurable memory manager 0117 * 0118 * This is the pluggable memory manager. If it is not provided by an 0119 * application, a default implementation is used. 0120 */ 0121 static MemoryManager* fgMemoryManager; 0122 0123 static XMLFileMgr* fgFileMgr; 0124 static XMLMutexMgr* fgMutexMgr; 0125 0126 /** Global mutex for fast or infrequent operations. 0127 * 0128 * Use this mutex only for fast (e.g., increment an integer, 0129 * check flag, etc.) or infrequent (e.g., once-off initialization) 0130 * operations. 0131 */ 0132 static XMLMutex* fgAtomicMutex; 0133 0134 static bool fgXMLChBigEndian; 0135 static bool fgSSE2ok; 0136 //@} 0137 0138 0139 /** @name Initialization and Panic methods */ 0140 //@{ 0141 0142 /** Perform per-process parser initialization 0143 * 0144 * Initialization <b>must</b> be called first in any client code. 0145 * 0146 * @param locale The locale to use for messages. 0147 * 0148 * The locale is set iff the Initialize() is invoked for the very first time, 0149 * to ensure that each and every message loader, in the process space, share 0150 * the same locale. 0151 * 0152 * All subsequent invocations of Initialize(), with a different locale, have 0153 * no effect on the message loaders, either instantiated, or to be instantiated. 0154 * 0155 * To set to a different locale, client application needs to Terminate() (or 0156 * multiple Terminate() in the case where multiple Initialize() have been invoked 0157 * before), followed by Initialize(new_locale). 0158 * 0159 * The default locale is "en_US". 0160 * 0161 * @param nlsHome User specified location where MsgLoader retrieves error message files. 0162 * the discussion above with regard to locale, applies to nlsHome as well. 0163 * 0164 * @param panicHandler Application's panic handler, application owns this handler. 0165 * Application shall make sure that the plugged panic handler persists 0166 * through the call to XMLPlatformUtils::Terminate(). 0167 * 0168 * @param memoryManager Plugged-in memory manager which is owned by the 0169 * application. Applications must make sure that the 0170 * plugged-in memory manager persist through the call to 0171 * XMLPlatformUtils::Terminate() 0172 */ 0173 static void Initialize(const char* const locale = XMLUni::fgXercescDefaultLocale 0174 , const char* const nlsHome = 0 0175 , PanicHandler* const panicHandler = 0 0176 , MemoryManager* const memoryManager = 0); 0177 0178 /** Perform per-process parser initialization 0179 * 0180 * Initialization <b>must</b> be called first in any client code. 0181 * 0182 * @param initialDOMHeapAllocSize The size of the first memory block 0183 * allocated by the DOMDocument heap. Note that changing this parameter 0184 * may result in poor performance and/or excessive memory usage. For 0185 * the default value refer to dom/impl/DOMDocumentImpl.cpp. 0186 * 0187 * @param maxDOMHeapAllocSize The maximum size of the memory block 0188 * allocated by the DOMDocument heap. As the document grows, the 0189 * allocated by the heap memory blocks grow from initialDOMHeapAllocSize 0190 * to maxDOMHeapAllocSize. Note that changing this parameter may result 0191 * in poor performance and/or excessive memory usage. For the default 0192 * value refer to dom/impl/DOMDocumentImpl.cpp. 0193 * 0194 * @param maxDOMSubAllocationSize The maximum size of the memory block 0195 * requested that is handled by the DOMDocument heap. A request for a 0196 * larger block is handled directly by the memory manager. Note that 0197 * changing this parameter may result in poor performance and/or 0198 * excessive memory usage. For the default value refer to 0199 * dom/impl/DOMDocumentImpl.cpp. 0200 * 0201 * @param locale The locale to use for messages. 0202 * 0203 * The locale is set iff the Initialize() is invoked for the very first time, 0204 * to ensure that each and every message loader, in the process space, share 0205 * the same locale. 0206 * 0207 * All subsequent invocations of Initialize(), with a different locale, have 0208 * no effect on the message loaders, either instantiated, or to be instantiated. 0209 * 0210 * To set to a different locale, client application needs to Terminate() (or 0211 * multiple Terminate() in the case where multiple Initialize() have been invoked 0212 * before), followed by Initialize(new_locale). 0213 * 0214 * The default locale is "en_US". 0215 * 0216 * @param nlsHome User specified location where MsgLoader retrieves error message files. 0217 * the discussion above with regard to locale, applies to nlsHome as well. 0218 * 0219 * @param panicHandler Application's panic handler, application owns this handler. 0220 * Application shall make sure that the plugged panic handler persists 0221 * through the call to XMLPlatformUtils::Terminate(). 0222 * 0223 * @param memoryManager Plugged-in memory manager which is owned by the 0224 * application. Applications must make sure that the plugged-in memory 0225 * manager persist through the call to XMLPlatformUtils::Terminate() 0226 */ 0227 static void Initialize(XMLSize_t initialDOMHeapAllocSize 0228 , XMLSize_t maxDOMHeapAllocSize 0229 , XMLSize_t maxDOMSubAllocationSize 0230 , const char* const locale = XMLUni::fgXercescDefaultLocale 0231 , const char* const nlsHome = 0 0232 , PanicHandler* const panicHandler = 0 0233 , MemoryManager* const memoryManager = 0); 0234 0235 /** Perform per-process parser termination 0236 * 0237 * The termination call is currently optional, to aid those dynamically 0238 * loading the parser to clean up before exit, or to avoid spurious 0239 * reports from leak detectors. 0240 */ 0241 static void Terminate(); 0242 0243 /** The panic mechanism. 0244 * 0245 * If, during initialization, we cannot even get far enough along 0246 * to get transcoding up or get message loading working, we call 0247 * this method.</p> 0248 * 0249 * Each platform can implement it however they want. This method will 0250 * delegate the panic handling to a user specified panic handler or 0251 * in the absence of it, the default panic handler. 0252 * 0253 * In case the default panic handler does not support a particular 0254 * platform, the platform specific panic handling shall be implemented 0255 * here </p>. 0256 * 0257 * @param reason The enumeration that defines the cause of the failure 0258 */ 0259 static void panic 0260 ( 0261 const PanicHandler::PanicReasons reason 0262 ); 0263 0264 //@} 0265 0266 /** @name File Methods */ 0267 //@{ 0268 0269 /** Make a new file object appropriate for the platform. 0270 * 0271 * @param manager The MemoryManager to use to allocate objects 0272 */ 0273 static XMLFileMgr* makeFileMgr(MemoryManager* const manager); 0274 0275 /** Get the current file position 0276 * 0277 * This must be implemented by the per-platform driver, which should 0278 * use local file services to determine the current position within 0279 * the passed file. 0280 * 0281 * Since the file API provided here only reads, if the host platform 0282 * supports separate read/write positions, only the read position is 0283 * of any interest, and hence should be the one returned. 0284 * 0285 * @param theFile The file handle 0286 * @param manager The MemoryManager to use to allocate objects 0287 */ 0288 static XMLFilePos curFilePos(FileHandle theFile 0289 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0290 0291 /** Closes the file handle 0292 * 0293 * This must be implemented by the per-platform driver, which should 0294 * use local file services to close the passed file handle, and to 0295 * destroy the passed file handle and any allocated data or system 0296 * resources it contains. 0297 * 0298 * @param theFile The file handle to close 0299 * @param manager The MemoryManager to use to allocate objects 0300 */ 0301 static void closeFile(FileHandle theFile 0302 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0303 0304 /** Returns the file size 0305 * 0306 * This must be implemented by the per-platform driver, which should 0307 * use local file services to determine the current size of the file 0308 * represented by the passed handle. 0309 * 0310 * @param theFile The file handle whose size you want 0311 * @param manager The MemoryManager to use to allocate objects 0312 * @return Returns the size of the file in bytes 0313 */ 0314 static XMLFilePos fileSize(FileHandle theFile 0315 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0316 0317 /** Opens the file 0318 * 0319 * This must be implemented by the per-platform driver, which should 0320 * use local file services to open passed file. If it fails, a 0321 * null handle pointer should be returned. 0322 * 0323 * @param fileName The string containing the name of the file 0324 * @param manager The MemoryManager to use to allocate objects 0325 * @return The file handle of the opened file 0326 */ 0327 static FileHandle openFile(const char* const fileName 0328 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0329 0330 /** Opens a named file 0331 * 0332 * This must be implemented by the per-platform driver, which should 0333 * use local file services to open the passed file. If it fails, a 0334 * null handle pointer should be returned. 0335 * 0336 * @param fileName The string containing the name of the file 0337 * @param manager The MemoryManager to use to allocate objects 0338 * @return The file handle of the opened file 0339 */ 0340 static FileHandle openFile(const XMLCh* const fileName 0341 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0342 0343 /** Open a named file to write 0344 * 0345 * This must be implemented by the per-platform driver, which should 0346 * use local file services to open passed file. If it fails, a 0347 * null handle pointer should be returned. 0348 * 0349 * @param fileName The string containing the name of the file 0350 * @param manager The MemoryManager to use to allocate objects 0351 * @return The file handle of the opened file 0352 */ 0353 static FileHandle openFileToWrite(const char* const fileName 0354 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0355 0356 /** Open a named file to write 0357 * 0358 * This must be implemented by the per-platform driver, which should 0359 * use local file services to open the passed file. If it fails, a 0360 * null handle pointer should be returned. 0361 * 0362 * @param fileName The string containing the name of the file 0363 * @param manager The MemoryManager to use to allocate objects 0364 * @return The file handle of the opened file 0365 */ 0366 static FileHandle openFileToWrite(const XMLCh* const fileName 0367 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0368 0369 /** Opens the standard input as a file 0370 * 0371 * This must be implemented by the per-platform driver, which should 0372 * use local file services to open a handle to the standard input. 0373 * It should be a copy of the standard input handle, since it will 0374 * be closed later! 0375 * 0376 * @param manager The MemoryManager to use to allocate objects 0377 * @return The file handle of the standard input stream 0378 */ 0379 static FileHandle openStdInHandle(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0380 0381 /** Reads the file buffer 0382 * 0383 * This must be implemented by the per-platform driver, which should 0384 * use local file services to read up to 'toRead' bytes of data from 0385 * the passed file, and return those bytes in the 'toFill' buffer. It 0386 * is not an error not to read the requested number of bytes. When the 0387 * end of file is reached, zero should be returned. 0388 * 0389 * @param theFile The file handle to be read from. 0390 * @param toRead The maximum number of byte to read from the current 0391 * position 0392 * @param toFill The byte buffer to fill 0393 * @param manager The MemoryManager to use to allocate objects 0394 * 0395 * @return Returns the number of bytes read from the stream or file 0396 */ 0397 static XMLSize_t readFileBuffer 0398 ( 0399 FileHandle theFile 0400 , const XMLSize_t toRead 0401 , XMLByte* const toFill 0402 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0403 ); 0404 0405 /** Writes the buffer to the file 0406 * 0407 * This must be implemented by the per-platform driver, which should 0408 * use local file services to write up to 'toWrite' bytes of data to 0409 * the passed file. Unless exception raised by local file services, 0410 * 'toWrite' bytes of data is to be written to the passed file. 0411 * 0412 * @param theFile The file handle to be written to. 0413 * @param toWrite The maximum number of byte to write from the current 0414 * position 0415 * @param toFlush The byte buffer to flush 0416 * @param manager The MemoryManager to use to allocate objects 0417 * @return void 0418 */ 0419 static void writeBufferToFile 0420 ( 0421 FileHandle const theFile 0422 , XMLSize_t toWrite 0423 , const XMLByte* const toFlush 0424 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0425 ); 0426 0427 /** Resets the file handle 0428 * 0429 * This must be implemented by the per-platform driver which will use 0430 * local file services to reset the file position to the start of the 0431 * the file. 0432 * 0433 * @param theFile The file handle that you want to reset 0434 * @param manager The MemoryManager to use to allocate objects 0435 */ 0436 static void resetFile(FileHandle theFile 0437 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0438 0439 //@} 0440 0441 0442 /** @name File System Methods */ 0443 //@{ 0444 /** Gets the full path from a relative path 0445 * 0446 * This must be implemented by the per-platform driver. It should 0447 * complete a relative path using the 'current directory', or whatever 0448 * the local equivalent of a current directory is. If the passed 0449 * source path is actually fully qualified, then a straight copy of it 0450 * will be returned. 0451 * 0452 * @param srcPath The path of the file for which you want the full path 0453 * 0454 * @param manager Pointer to the memory manager to be used to 0455 * allocate objects. 0456 * 0457 * @return Returns the fully qualified path of the file name including 0458 * the file name. This is dyanmically allocated and must be 0459 * deleted by the caller when its no longer needed! The memory 0460 * returned will beallocated using the static memory manager, if 0461 * user do not supply a memory manager. Users then need to make 0462 * sure to use either the default or user specific memory manager 0463 * to deallocate the memory. 0464 */ 0465 static XMLCh* getFullPath 0466 ( 0467 const XMLCh* const srcPath 0468 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0469 ); 0470 0471 /** Gets the current working directory 0472 * 0473 * This must be implemented by the per-platform driver. It returns 0474 * the current working directory is. 0475 * @param manager The MemoryManager to use to allocate objects 0476 * @return Returns the current working directory. 0477 * This is dyanmically allocated and must be deleted 0478 * by the caller when its no longer needed! The memory returned 0479 * will be allocated using the static memory manager, if users 0480 * do not supply a memory manager. Users then need to make sure 0481 * to use either the default or user specific memory manager to 0482 * deallocate the memory. 0483 */ 0484 static XMLCh* getCurrentDirectory 0485 ( 0486 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0487 ); 0488 0489 /** Check if a character is a slash 0490 * 0491 * This must be implemented by the per-platform driver. 0492 * 0493 * @param c the character to be examined 0494 * 0495 * @return true if the character examined is a slash 0496 * false otherwise 0497 */ 0498 static inline bool isAnySlash(XMLCh c); 0499 0500 /** Remove occurrences of the pair of dot slash 0501 * 0502 * To remove the sequence, dot slash if it is part of the sequence, 0503 * slash dot slash. 0504 * 0505 * @param srcPath The path for which you want to remove the dot slash sequence. 0506 * @param manager The MemoryManager to use to allocate objects 0507 * @return 0508 */ 0509 static void removeDotSlash(XMLCh* const srcPath 0510 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0511 0512 /** Remove occurrences of the dot dot slash 0513 * 0514 * To remove the sequence, slash dot dot slash and its preceding path segment 0515 * if and only if the preceding path segment is not slash dot dot slash. 0516 * 0517 * @param srcPath The path for which you want to remove the slash dot 0518 * dot slash sequence and its preceding path segment. 0519 * @param manager The MemoryManager to use to allocate objects 0520 * @return 0521 */ 0522 static void removeDotDotSlash(XMLCh* const srcPath 0523 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0524 0525 /** Determines if a path is relative or absolute 0526 * 0527 * This must be implemented by the per-platform driver, which should 0528 * determine whether the passed path is relative or not. The concept 0529 * of relative and absolute might be... well relative on different 0530 * platforms. But, as long as the determination is made consistently 0531 * and in coordination with the weavePaths() method, it should work 0532 * for any platform. 0533 * 0534 * @param toCheck The file name which you want to check 0535 * @param manager The MemoryManager to use to allocate objects 0536 * @return Returns true if the filename appears to be relative 0537 */ 0538 static bool isRelative(const XMLCh* const toCheck 0539 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0540 ); 0541 0542 /** Utility to join two paths 0543 * 0544 * This must be implemented by the per-platform driver, and should 0545 * weave the relative path part together with the base part and return 0546 * a new path that represents this combination. 0547 * 0548 * If the relative part turns out to be fully qualified, it will be 0549 * returned as is. If it is not, then it will be woven onto the 0550 * passed base path, by removing one path component for each leading 0551 * "../" (or whatever is the equivalent in the local system) in the 0552 * relative path. 0553 * 0554 * @param basePath The string containing the base path 0555 * @param relativePath The string containing the relative path 0556 * @param manager The MemoryManager to use to allocate objects 0557 * @return Returns a string containing the 'woven' path. It should 0558 * be dynamically allocated and becomes the responsibility of the 0559 * caller to delete. 0560 */ 0561 static XMLCh* weavePaths 0562 ( 0563 const XMLCh* const basePath 0564 , const XMLCh* const relativePath 0565 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0566 ); 0567 //@} 0568 0569 /** @name Timing Methods */ 0570 //@{ 0571 0572 /** Gets the system time in milliseconds 0573 * 0574 * This must be implemented by the per-platform driver, which should 0575 * use local services to return the current value of a running 0576 * millisecond timer. Note that the value returned is only as accurate 0577 * as the millisecond time of the underlying host system. 0578 * 0579 * @return Returns the system time as an unsigned long 0580 */ 0581 static unsigned long getCurrentMillis(); 0582 //@} 0583 0584 /** @name Mutex Methods */ 0585 //@{ 0586 0587 /** Factory method for creating MutexMgr object. 0588 * 0589 * This factory method creates a mutexmgr that will be used 0590 * on the particular platform. 0591 * 0592 * @param manager The MemoryManager to use to allocate objects 0593 */ 0594 static XMLMutexMgr* makeMutexMgr(MemoryManager* const manager); 0595 0596 /** Closes a mutex handle 0597 * 0598 * Each per-platform driver must implement this. Only it knows what 0599 * the actual content of the passed mutex handle is. 0600 * 0601 * @param mtxHandle The mutex handle that you want to close 0602 * @param manager The MemoryManager used to allocate the object 0603 */ 0604 static void closeMutex(void* const mtxHandle, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0605 0606 /** Locks a mutex handle 0607 * 0608 * Each per-platform driver must implement this. Only it knows what 0609 * the actual content of the passed mutex handle is. 0610 * 0611 * @param mtxHandle The mutex handle that you want to lock 0612 */ 0613 static void lockMutex(void* const mtxHandle); 0614 0615 /** Make a new mutex 0616 * 0617 * Each per-platform driver must implement this. Only it knows what 0618 * the actual content of the passed mutex handle is. The returned 0619 * handle pointer will be eventually passed to closeMutex() which is 0620 * also implemented by the platform driver. 0621 * 0622 * @param manager The MemoryManager to use to allocate objects 0623 */ 0624 static void* makeMutex(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0625 0626 /** Unlocks a mutex 0627 * 0628 * Each per-platform driver must implement this. Only it knows what 0629 * the actual content of the passed mutex handle is. 0630 * 0631 * Note that, since the underlying system synchronization services 0632 * are used, Xerces cannot guarantee that lock/unlock operations are 0633 * correctly enforced on a per-thread basis or that incorrect nesting 0634 * of lock/unlock operations will be caught. 0635 * 0636 * @param mtxHandle The mutex handle that you want to unlock 0637 */ 0638 static void unlockMutex(void* const mtxHandle); 0639 0640 //@} 0641 0642 0643 /** @name External Message Support */ 0644 //@{ 0645 0646 /** Loads the message set from among the available domains 0647 * 0648 * The returned object must be dynamically allocated and the caller 0649 * becomes responsible for cleaning it up. 0650 * 0651 * @param msgDomain The message domain which you want to load 0652 */ 0653 static XMLMsgLoader* loadMsgSet(const XMLCh* const msgDomain); 0654 0655 //@} 0656 0657 0658 /** @name NEL Character Handling */ 0659 //@{ 0660 /** 0661 * This function enables the recognition of NEL(0x85) char and LSEP (0x2028) as newline chars 0662 * which is disabled by default. 0663 * It is only called once per process. Once it is set, any subsequent calls 0664 * will result in exception being thrown. 0665 * 0666 * Note: 1. Turning this option on will make the parser non compliant to XML 1.0. 0667 * 2. This option has no effect to document conforming to XML 1.1 compliant, 0668 * which always recognize these two chars (0x85 and 0x2028) as newline characters. 0669 * 0670 */ 0671 static void recognizeNEL(bool state 0672 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0673 0674 /** 0675 * Return the value of fgNEL flag. 0676 */ 0677 static bool isNELRecognized(); 0678 //@} 0679 0680 /** @name Strict IANA Encoding Checking */ 0681 //@{ 0682 /** 0683 * This function enables/disables strict IANA encoding names checking. 0684 * 0685 * The strict checking is disabled by default. 0686 * 0687 * @param state If true, a strict IANA encoding name check is performed, 0688 * otherwise, no checking. 0689 * 0690 */ 0691 static void strictIANAEncoding(const bool state); 0692 0693 /** 0694 * Returns whether a strict IANA encoding name check is enabled or 0695 * disabled. 0696 */ 0697 static bool isStrictIANAEncoding(); 0698 //@} 0699 0700 /** 0701 * Aligns the specified pointer per platform block allocation 0702 * requirements. 0703 * 0704 * The results of this function may be altered by defining 0705 * XML_PLATFORM_NEW_BLOCK_ALIGNMENT. 0706 */ 0707 static inline XMLSize_t alignPointerForNewBlockAllocation(XMLSize_t ptrSize); 0708 0709 private : 0710 // ----------------------------------------------------------------------- 0711 // Unimplemented constructors and operators 0712 // ----------------------------------------------------------------------- 0713 XMLPlatformUtils(); 0714 0715 /** @name Private static methods */ 0716 //@{ 0717 0718 /** Loads a message set from the available domains 0719 * 0720 * @param msgDomain The message domain containing the message to be 0721 * loaded 0722 */ 0723 static XMLMsgLoader* loadAMsgSet(const XMLCh* const msgDomain); 0724 0725 /** Creates a net accessor object. 0726 * 0727 * Each per-platform driver must implement this method. However, 0728 * having a Net Accessor is optional and this method can return a 0729 * null pointer if remote access via HTTP and FTP URLs is not required. 0730 * 0731 * @return An object derived from XMLNetAccessor. It must be dynamically 0732 * allocated, since it will be deleted later. 0733 */ 0734 static XMLNetAccessor* makeNetAccessor(); 0735 0736 /** Creates a Transcoding service 0737 * 0738 * Each per-platform driver must implement this method and return some 0739 * derivative of the XMLTransService class. This object serves as the 0740 * transcoder factory for this process. The object must be dynamically 0741 * allocated and the caller is responsible for cleaning it up. 0742 * 0743 * @return A dynamically allocated object of some class derived from 0744 * the XMLTransService class. 0745 */ 0746 static XMLTransService* makeTransService(); 0747 0748 /** Search for sequence, slash dot dot slash 0749 * 0750 * @param srcPath the path to search 0751 * 0752 * @return the position of the first occurrence of slash dot dot slash 0753 * -1 if no such sequence is found 0754 */ 0755 static int searchSlashDotDotSlash(XMLCh* const srcPath); 0756 0757 //@} 0758 0759 /** @name Private static methods */ 0760 //@{ 0761 0762 /** 0763 * Indicates whether the memory manager was supplied by the user 0764 * or not. Users own the memory manager, and if none is supplied, 0765 * Xerces uses a default one that it owns and is responsible for 0766 * deleting in Terminate(). 0767 */ 0768 static bool fgMemMgrAdopted; 0769 0770 //@} 0771 }; 0772 0773 0774 MakeXMLException(XMLPlatformUtilsException, XMLUTIL_EXPORT) 0775 0776 0777 // --------------------------------------------------------------------------- 0778 // XMLPlatformUtils: alignPointerForNewBlockAllocation 0779 // --------------------------------------------------------------------------- 0780 // Calculate alignment required by platform for a new 0781 // block allocation. We use this in our custom allocators 0782 // to ensure that returned blocks are properly aligned. 0783 // Note that, although this will take a pointer and return the position 0784 // at which it should be placed for correct alignment, in our code 0785 // we normally use XMLSize_t parameters to discover what the alignment 0786 // of header blocks should be. Thus, if this is to be 0787 // used for the former purpose, to make compilers happy 0788 // some casting will be necessary - neilg. 0789 // 0790 // Note: XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be specified on a 0791 // per-architecture basis to dictate the alignment requirements 0792 // of the architecture. In the absense of this specification, 0793 // this routine guesses at the correct alignment value. 0794 // 0795 // A XML_PLATFORM_NEW_BLOCK_ALIGNMENT value of zero is illegal. 0796 // If a platform requires absolutely no alignment, a value 0797 // of 1 should be specified ("align pointers on 1 byte boundaries"). 0798 // 0799 inline XMLSize_t 0800 XMLPlatformUtils::alignPointerForNewBlockAllocation(XMLSize_t ptrSize) 0801 { 0802 // Macro XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be defined 0803 // as needed to dictate alignment requirements on a 0804 // per-architecture basis. In the absense of that we 0805 // take an educated guess. 0806 #ifdef XML_PLATFORM_NEW_BLOCK_ALIGNMENT 0807 const XMLSize_t alignment = XML_PLATFORM_NEW_BLOCK_ALIGNMENT; 0808 #else 0809 const XMLSize_t alignment = (sizeof(void*) >= sizeof(double)) ? sizeof(void*) : sizeof(double); 0810 #endif 0811 0812 // Calculate current alignment of pointer 0813 XMLSize_t current = ptrSize % alignment; 0814 0815 // Adjust pointer alignment as needed 0816 return (current == 0) 0817 ? ptrSize 0818 : (ptrSize + alignment - current); 0819 } 0820 0821 0822 0823 // --------------------------------------------------------------------------- 0824 // XMLDeleter: Public Destructor 0825 // --------------------------------------------------------------------------- 0826 inline XMLDeleter::~XMLDeleter() 0827 { 0828 } 0829 0830 // --------------------------------------------------------------------------- 0831 // XMLDeleter: Hidden constructors and operators 0832 // --------------------------------------------------------------------------- 0833 inline XMLDeleter::XMLDeleter() 0834 { 0835 } 0836 0837 XERCES_CPP_NAMESPACE_END 0838 0839 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |