#include <PlatformUtils.hpp>
Static Public Member Functions | |
static size_t | alignPointerForNewBlockAllocation (size_t ptrSize) |
Aligns the specified pointer per platform block allocation requirements. | |
Initialization amd Panic methods | |
static void | Initialize (const char *const locale=XMLUni::fgXercescDefaultLocale, const char *const nlsHome=0, PanicHandler *const panicHandler=0, MemoryManager *const memoryManager=0, bool toInitStatics=false) |
Perform per-process parser initialization. | |
static void | Terminate () |
Perform per-process parser termination. | |
static void | panic (const PanicHandler::PanicReasons reason) |
The panic mechanism. | |
File Methods | |
static unsigned int | curFilePos (FileHandle theFile, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Get the current file position. | |
static void | closeFile (FileHandle theFile, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Closes the file handle. | |
static unsigned int | fileSize (FileHandle theFile, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Returns the file size. | |
static FileHandle | openFile (const char *const fileName, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Opens the file. | |
static FileHandle | openFile (const XMLCh *const fileName, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Opens a named file. | |
static FileHandle | openFileToWrite (const char *const fileName, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Open a named file to write. | |
static FileHandle | openFileToWrite (const XMLCh *const fileName, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Open a named file to write. | |
static FileHandle | openStdInHandle (MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Opens the standard input as a file. | |
static unsigned int | readFileBuffer (FileHandle theFile, const unsigned int toRead, XMLByte *const toFill, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Reads the file buffer. | |
static void | writeBufferToFile (FileHandle const theFile, long toWrite, const XMLByte *const toFlush, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Writes the buffer to the file. | |
static void | resetFile (FileHandle theFile, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Resets the file handle. | |
File System Methods | |
static XMLCh * | getFullPath (const XMLCh *const srcPath, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Gets the full path from a relative path. | |
static XMLCh * | getCurrentDirectory (MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Gets the current working directory. | |
static bool | isAnySlash (XMLCh c) |
Check if a charater is a slash. | |
static void | removeDotSlash (XMLCh *const srcPath, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Remove occurences of the pair of dot slash. | |
static void | removeDotDotSlash (XMLCh *const srcPath, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Remove occurences of the dot dot slash. | |
static bool | isRelative (const XMLCh *const toCheck, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Determines if a path is relative or absolute. | |
static XMLCh * | weavePaths (const XMLCh *const basePath, const XMLCh *const relativePath, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
Utility to join two paths. | |
Timing Methods | |
static unsigned long | getCurrentMillis () |
Gets the system time in milliseconds. | |
Mutex Methods | |
static void | closeMutex (void *const mtxHandle) |
Closes a mutex handle. | |
static void | lockMutex (void *const mtxHandle) |
Locks a mutex handle. | |
static void * | makeMutex (MemoryManager *manager=XMLPlatformUtils::fgMemoryManager) |
Make a new mutex. | |
static void | unlockMutex (void *const mtxHandle) |
Unlocks a mutex. | |
External Message Support | |
static XMLMsgLoader * | loadMsgSet (const XMLCh *const msgDomain) |
Loads the message set from among the available domains. | |
Miscellaneous synchronization methods | |
static void * | compareAndSwap (void **toFill, const void *const newValue, const void *const toCompare) |
Conditionally updates or returns a single word variable atomically. | |
Atomic Increment and Decrement | |
static int | atomicIncrement (int &location) |
Increments a single word variable atomically. | |
static int | atomicDecrement (int &location) |
Decrements a single word variable atomically. | |
NEL Character Handling | |
static void | recognizeNEL (bool state, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) |
This function enables the recognition of NEL(0x85) char and LSEP (0x2028) as newline chars which is disabled by default. | |
static bool | isNELRecognized () |
Return the value of fgNEL flag. | |
Strict IANA Encoding Checking | |
static void | strictIANAEncoding (const bool state) |
This function enables/disables strict IANA encoding names checking. | |
static bool | isStrictIANAEncoding () |
Returns whether a strict IANA encoding name check is enabled or disabled. | |
Static Public Attributes | |
Public Static Data | |
static XMLNetAccessor * | fgNetAccessor |
The network accessor. | |
static XMLTransService * | fgTransService |
The transcoding service. | |
static PanicHandler * | fgUserPanicHandler |
The Panic Handler. | |
static PanicHandler * | fgDefaultPanicHandler |
The Panic Handler. | |
static MemoryManager * | fgMemoryManager |
The configurable memory manager. | |
static MemoryManager * | fgArrayMemoryManager |
The array-allocating memory manager. | |
static XMLMutex * | fgAtomicMutex |
This class contains methods that must be implemented in a platform specific manner. The actual implementations of these methods are available in the per-platform files indide src/util/Platforms
.
|
Aligns the specified pointer per platform block allocation requirements. The results of this function may be altered by defining XML_PLATFORM_NEW_BLOCK_ALIGNMENT. |
|
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).
|
|
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).
|
|
Closes the file handle. This must be implemented by the per-platform driver, which should use local file services to close the passed file handle, and to destroy the passed file handle and any allocated data or system resources it contains.
|
|
Closes a mutex handle. Each per-platform driver must implement this. Only it knows what the actual content of the passed mutex handle is.
|
|
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.
|
|
Get the current file position. This must be implemented by the per-platform driver, which should use local file services to deterine the current position within the passed file. Since the file API provided here only reads, if the host platform supports separate read/write positions, only the read position is of any interest, and hence should be the one returned.
|
|
Returns the file size. This must be implemented by the per-platform driver, which should use local file services to determine the current size of the file represented by the passed handle.
|
|
Gets the current working directory. This must be implemented by the per-platform driver. It returns the current working directory is.
|
|
Gets the system time in milliseconds. This must be implemented by the per-platform driver, which should use local services to return the current value of a running millisecond timer. Note that the value returned is only as accurate as the millisecond time of the underyling host system.
|
|
Gets the full path from a relative path. This must be implemented by the per-platform driver. It should complete a relative path using the 'current directory', or whatever the local equivalent of a current directory is. If the passed source path is actually fully qualified, then a straight copy of it will be returned.
|
|
Perform per-process parser initialization. Initialization must be called first in any client code. The locale is set iff the Initialize() is invoked for the very first time, to ensure that each and every message loaders, in the process space, share the same locale. All subsequent invocations of Initialize(), with a different locale, have no effect on the message loaders, either instantiated, or to be instantiated. To set to a different locale, client application needs to Terminate() (or multiple Terminate() in the case where multiple Initialize() have been invoked before), followed by Initialize(new_locale). The default locale is "en_US". nlsHome: user specified location where MsgLoader retrieves error message files. the discussion above with regard to locale, applies to this nlsHome as well. panicHandler: application's panic handler, application owns this handler. Application shall make sure that the plugged panic handler persists through the call to XMLPlatformUtils::terminate(). memoryManager: plugged-in memory manager which is owned by user applications. Applications must make sure that the plugged-in memory manager persist through the call to XMLPlatformUtils::terminate() |
|
Check if a charater is a slash. This must be implemented by the per-platform driver.
|
|
Return the value of fgNEL flag.
|
|
Determines if a path is relative or absolute. This must be implemented by the per-platform driver, which should determine whether the passed path is relative or not. The concept of relative and absolute might be... well relative on different platforms. But, as long as the determination is made consistently and in coordination with the weavePaths() method, it should work for any platform.
|
|
Returns whether a strict IANA encoding name check is enabled or disabled.
|
|
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.
|
|
Locks a mutex handle. Each per-platform driver must implement this. Only it knows what the actual content of the passed mutex handle is.
|
|
Make a new mutex. Each per-platform driver must implement this. Only it knows what the actual content of the passed mutex handle is. The returned handle pointer will be eventually passed to closeMutex() which is also implemented by the platform driver.
|
|
Opens a named file. This must be implemented by the per-platform driver, which should use local file services to open the passed file. If it fails, a null handle pointer should be returned.
|
|
Opens the file. This must be implemented by the per-platform driver, which should use local file services to open passed file. If it fails, a null handle pointer should be returned.
|
|
Open a named file to write. This must be implemented by the per-platform driver, which should use local file services to open the passed file. If it fails, a null handle pointer should be returned.
|
|
Open a named file to write. This must be implemented by the per-platform driver, which should use local file services to open passed file. If it fails, a null handle pointer should be returned.
|
|
Opens the standard input as a file. This must be implemented by the per-platform driver, which should use local file services to open a handle to the standard input. It should be a copy of the standard input handle, since it will be closed later!
|
|
The panic mechanism. If, during initialization, we cannot even get far enough along to get transcoding up or get message loading working, we call this method. Each platform can implement it however they want. This method will delegate the panic handling to a user specified panic handler or in the absence of it, the default panic handler. In case the default panic handler does not support a particular platform, the platform specific panic hanlding shall be implemented here .
|
|
Reads the file buffer. This must be implemented by the per-platform driver, which should use local file services to read up to 'toRead' bytes of data from the passed file, and return those bytes in the 'toFill' buffer. It is not an error not to read the requested number of bytes. When the end of file is reached, zero should be returned.
|
|
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. |
|
Remove occurences of the dot dot slash. To remove the sequence, slash dot dot slash and its preceding path segment if and only if the preceding path segment is not slash dot dot slash.
|
|
Remove occurences of the pair of dot slash. To remove the sequence, dot slash if it is part of the sequence, slash dot slash.
|
|
Resets the file handle. This must be implemented by the per-platform driver which will use local file services to reset the file position to the start of the the file.
|
|
This function enables/disables strict IANA encoding names checking. The strict checking is disabled by default.
|
|
Perform per-process parser termination. The termination call is currently optional, to aid those dynamically loading the parser to clean up before exit, or to avoid spurious reports from leak detectors. |
|
Unlocks a mutex. Each per-platform driver must implement this. Only it knows what the actual content of the passed mutex handle is. Note that, since the underlying system synchronization services are used, Xerces cannot guarantee that lock/unlock operations are correctly enforced on a per-thread basis or that incorrect nesting of lock/unlock operations will be caught.
|
|
Utility to join two paths. This must be implemented by the per-platform driver, and should weave the relative path part together with the base part and return a new path that represents this combination. If the relative part turns out to be fully qualified, it will be returned as is. If it is not, then it will be woven onto the passed base path, by removing one path component for each leading "../" (or whatever is the equivalent in the local system) in the relative path.
|
|
Writes the buffer to the file. This must be implemented by the per-platform driver, which should use local file services to write up to 'toWrite' bytes of data to the passed file. Unless exception raised by local file services, 'toWrite' bytes of data is to be written to the passed file.
|
|
The array-allocating memory manager. This memory manager always allocates memory by calling the global new[] operator. It may be used to allocate memory where such memory needs to be deletable by calling delete []. Since this allocator is always guaranteed to do the same thing there is no reason, nor facility, to override it. |
|
|
|
The Panic Handler. This is the default panic handler. |
|
The configurable memory manager. This is the pluggable memory manager. If it is not provided by an application, a default implementation is used. |
|
The network accessor. This is provided by the per-platform driver, so each platform can choose what actual implementation it wants to use. The object must be dynamically allocated. Note that you may optionally, if your platform driver does not install a network accessor, set it manually from your client code after calling Initialize(). This works because this object is not required during initialization, and only comes into play during actual XML parsing. |
|
The transcoding service.
This is provided by the per platform driver, so each platform can choose what implemenation it wants to use. When the platform independent initialization code needs to get a transcoding service object, it will call |
|
The Panic Handler. This is the application provided panic handler. |