📄 platformutils.hpp
字号:
* 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. * * @param fileName The string containing the name of the file * * @return The file handle of the opened file */ static FileHandle openFile(const XMLCh* const fileName , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** 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. * * @param fileName The string containing the name of the file * * @return The file handle of the opened file */ static FileHandle openFileToWrite(const char* const fileName , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** 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. * * @param fileName The string containing the name of the file * * @return The file handle of the opened file */ static FileHandle openFileToWrite(const XMLCh* const fileName , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** 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! * * @return The file handle of the standard input stream */ static FileHandle openStdInHandle(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** 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. * * @param theFile The file handle to be read from. * @param toRead The maximum number of byte to read from the current * position * @param toFill The byte buffer to fill * * @return Returns the number of bytes read from the stream or file */ static unsigned int readFileBuffer ( FileHandle theFile , const unsigned int toRead , XMLByte* const toFill , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** 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. * * @param theFile The file handle to be written to. * @param toWrite The maximum number of byte to write from the current * position * @param toFlush The byte buffer to flush * * @return void */ static void writeBufferToFile ( FileHandle const theFile , long toWrite , const XMLByte* const toFlush , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** 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. * * @param theFile The file handle that you want to reset */ static void resetFile(FileHandle theFile , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); //@} /** @name File System Methods */ //@{ /** 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. * * @param srcPath The path of the file for which you want the full path * * @param manager Pointer to the memory manager to be used to * allocate objects. * * @return Returns the fully qualified path of the file name including * the file name. This is dyanmically allocated and must be * deleted by the caller when its no longer needed! The memory * returned will beallocated using the static memory manager, if * user do not supply a memory manager. Users then need to make * sure to use either the default or user specific memory manager * to deallocate the memory. */ static XMLCh* getFullPath ( const XMLCh* const srcPath , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Gets the current working directory * * This must be implemented by the per-platform driver. It returns * the current working directory is. * * @return Returns the current working directory. * This is dyanmically allocated and must be deleted * by the caller when its no longer needed! The memory returned * will be allocated using the static memory manager, if users * do not supply a memory manager. Users then need to make sure * to use either the default or user specific memory manager to * deallocate the memory. */ static XMLCh* getCurrentDirectory ( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Check if a charater is a slash * * This must be implemented by the per-platform driver. * * @param c the character to be examined * * @return true if the character examined is a slash * false otherwise */ static inline bool isAnySlash(XMLCh c); /** Remove occurences of the pair of dot slash * * To remove the sequence, dot slash if it is part of the sequence, * slash dot slash. * * @param srcPath The path for which you want to remove the dot slash sequence. * * @return */ static void removeDotSlash(XMLCh* const srcPath , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** 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. * * @param srcPath The path for which you want to remove the slash dot * dot slash sequence and its preceding path segment. * * @return */ static void removeDotDotSlash(XMLCh* const srcPath , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** 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. * * @param toCheck The file name which you want to check * * @return Returns true if the filename appears to be relative */ static bool isRelative(const XMLCh* const toCheck , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** 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. * * @param basePath The string containing the base path * @param relativePath The string containing the relative path * * @return Returns a string containing the 'woven' path. It should * be dynamically allocated and becomes the responsibility of the * caller to delete. */ static XMLCh* weavePaths ( const XMLCh* const basePath , const XMLCh* const relativePath , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} /** @name Timing Methods */ //@{ /** 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. * * @return Returns the system time as an unsigned long */ static unsigned long getCurrentMillis(); //@} /** @name Mutex Methods */ //@{ /** Closes a mutex handle * * Each per-platform driver must implement this. Only it knows what * the actual content of the passed mutex handle is. * * @param mtxHandle The mutex handle that you want to close */ static void closeMutex(void* const mtxHandle); /** Locks a mutex handle * * Each per-platform driver must implement this. Only it knows what * the actual content of the passed mutex handle is. * * @param mtxHandle The mutex handle that you want to lock */ static void lockMutex(void* const mtxHandle); /** 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. */ static void* makeMutex(); /** 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. * * @param mtxHandle The mutex handle that you want to unlock */ static void unlockMutex(void* const mtxHandle); //@} /** @name External Message Support */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -