📄 platformutils.hpp
字号:
//@{ /** Loads the message set from among the available domains * * The returned object must be dynamically allocated and the caller * becomes responsible for cleaning it up. * * @param msgDomain The message domain which you want to load */ static XMLMsgLoader* loadMsgSet(const XMLCh* const msgDomain); //@} /** @name Miscellaneous synchronization methods */ //@{ /** Conditionally updates or returns a single word variable atomically * * This must be implemented by the per-platform driver. The * compareAndSwap subroutine performs an atomic operation which * compares the contents of a single word variable with a stored old * value. If the values are equal, a new value is stored in the single * word variable and TRUE is returned; otherwise, the old value is set * to the current value of the single word variable and FALSE is * returned. * * The compareAndSwap subroutine is useful when a word value must be * updated only if it has not been changed since it was last read. * * Note: The word containing the single word variable must be aligned * on a full word boundary. * * @param toFill Specifies the address of the single word variable * @param newValue Specifies the new value to be conditionally assigned * to the single word variable. * @param toCompare Specifies the address of the old value to be checked * against (and conditionally updated with) the value of the single word * variable. * * @return Returns the new value assigned to the single word variable */ static void* compareAndSwap ( void** toFill , const void* const newValue , const void* const toCompare ); //@} /** @name Atomic Increment and Decrement */ //@{ /** Increments a single word variable atomically. * * This must be implemented by the per-platform driver. The * atomicIncrement subroutine increments one word in a single atomic * operation. This operation is useful when a counter variable is shared * between several threads or processes. When updating such a counter * variable, it is important to make sure that the fetch, update, and * store operations occur atomically (are not interruptible). * * @param location Specifies the address of the word variable to be * incremented. * * @return The function return value is positive if the result of the * operation was positive. Zero if the result of the operation was zero. * Negative if the result of the operation was negative. Except for the * zero case, the value returned may differ from the actual result of * the operation - only the sign and zero/nonzero state is guaranteed * to be correct. */ static int atomicIncrement(int& location); /** Decrements a single word variable atomically. * * This must be implemented by the per-platform driver. The * atomicDecrement subroutine increments one word in a single atomic * operation. This operation is useful when a counter variable is shared * between several threads or processes. When updating such a counter * variable, it is important to make sure that the fetch, update, and * store operations occur atomically (are not interruptible). * * @param location Specifies the address of the word variable to be * decremented. * * @return The function return value is positive if the result of the * operation was positive. Zero if the result of the operation was zero. * Negative if the result of the operation was negative. Except for the * zero case, the value returned may differ from the actual result of the * operation - only the sign and zero/nonzero state is guaranteed to be * correct. */ static int atomicDecrement(int& location); //@} /** @name NEL Character Handling */ //@{ /** * This function enables the recognition of NEL(0x85) char and LSEP (0x2028) as newline chars * which is disabled by default. * It is only called once per process. Once it is set, any subsequent calls * will result in exception being thrown. * * Note: 1. Turning this option on will make the parser non compliant to XML 1.0. * 2. This option has no effect to document conforming to XML 1.1 compliant, * which always recognize these two chars (0x85 and 0x2028) as newline characters. * */ static void recognizeNEL(bool state , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** * Return the value of fgNEL flag. */ static bool isNELRecognized(); //@} /** @name Strict IANA Encoding Checking */ //@{ /** * This function enables/disables strict IANA encoding names checking. * * The strict checking is disabled by default. * * @param state If true, a strict IANA encoding name check is performed, * otherwise, no checking. * */ static void strictIANAEncoding(const bool state); /** * Returns whether a strict IANA encoding name check is enabled or * disabled. */ static bool isStrictIANAEncoding(); //@} /** * Aligns the specified pointer per platform block allocation * requirements. * * The results of this function may be altered by defining * XML_PLATFORM_NEW_BLOCK_ALIGNMENT. */ static inline size_t alignPointerForNewBlockAllocation(size_t ptrSize);private : // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- XMLPlatformUtils(); /** @name Private static methods */ //@{ /** Loads a message set from the available domains * * @param msgDomain The message domain containing the message to be * loaded */ static XMLMsgLoader* loadAMsgSet(const XMLCh* const msgDomain); /** Creates a net accessor object. * * Each per-platform driver must implement this method. However, * having a Net Accessor is optional and this method can return a * null pointer if remote access via HTTP and FTP URLs is not required. * * @return An object derived from XMLNetAccessor. It must be dynamically * allocated, since it will be deleted later. */ static XMLNetAccessor* makeNetAccessor(); /** Creates a Transoding service * * Each per-platform driver must implement this method and return some * derivative of the XMLTransService class. This object serves as the * transcoder factory for this process. The object must be dynamically * allocated and the caller is responsible for cleaning it up. * * @return A dynamically allocated object of some class derived from * the XMLTransService class. */ static XMLTransService* makeTransService(); /** Does initialization for a particular platform * * Each per-platform driver must implement this to do any low level * system initialization required. It <b>cannot</b> use any XML * parser or utilities services! */ static void platformInit(); /** Does termination for a particular platform * * Each per-platform driver must implement this to do any low level * system resource cleanup required. It <b>cannot</b> use any XML * parser or utilities services! */ static void platformTerm(); /** Search for sequence, slash dot dot slash * * @param srcPath the path to search * * @return the position of the first occurence of slash dot dot slash * -1 if no such sequence is found */ static int searchSlashDotDotSlash(XMLCh* const srcPath); //@} /** @name Private static methods */ //@{ /** * Indicates whether the memory manager was supplied by the user * or not. Users own the memory manager, and if none is supplied, * Xerces uses a default one that it owns and is responsible for * deleting in Terminate(). */ static bool fgMemMgrAdopted; //@}};MakeXMLException(XMLPlatformUtilsException, XMLUTIL_EXPORT)// ---------------------------------------------------------------------------// XMLPlatformUtils: alignPointerForNewBlockAllocation// ---------------------------------------------------------------------------// Calculate alignment required by platform for a new// block allocation. We use this in our custom allocators// to ensure that returned blocks are properly aligned.// Note that, although this will take a pointer and return the position// at which it should be placed for correct alignment, in our code// we normally use size_t parameters to discover what the alignment// of header blocks should be. Thus, if this is to be// used for the former purpose, to make compilers happy// some casting will be necessary - neilg.//// Note: XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be specified on a// per-architecture basis to dictate the alignment requirements// of the architecture. In the absense of this specification,// this routine guesses at the correct alignment value.//// A XML_PLATFORM_NEW_BLOCK_ALIGNMENT value of zero is illegal.// If a platform requires absolutely no alignment, a value// of 1 should be specified ("align pointers on 1 byte boundaries").//inline size_tXMLPlatformUtils::alignPointerForNewBlockAllocation(size_t ptrSize){ // Macro XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be defined // as needed to dictate alignment requirements on a // per-architecture basis. In the absense of that we // take an educated guess. #ifdef XML_PLATFORM_NEW_BLOCK_ALIGNMENT size_t alignment = XML_PLATFORM_NEW_BLOCK_ALIGNMENT; #else size_t alignment = (sizeof(void*) >= sizeof(double)) ? sizeof(void*) : sizeof(double); #endif // Calculate current alignment of pointer size_t current = ptrSize % alignment; // Adjust pointer alignment as needed return (current == 0) ? ptrSize : (ptrSize + alignment - current);}// ---------------------------------------------------------------------------// XMLDeleter: Public Destructor// ---------------------------------------------------------------------------inline XMLDeleter::~XMLDeleter(){}// ---------------------------------------------------------------------------// XMLDeleter: Hidden constructors and operators// ---------------------------------------------------------------------------inline XMLDeleter::XMLDeleter(){}XERCES_CPP_NAMESPACE_END#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -