secureswitools/swisistools/source/xmlparser/xerces/include/xercesc/util/Platforms/MacOS/MacOSPlatformUtils.hpp
changeset 0 ba25891c3a9e
child 1 c42dffbd5b4f
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 /*
       
    18  * Licensed to the Apache Software Foundation (ASF) under one or more
       
    19  * contributor license agreements.  See the NOTICE file distributed with
       
    20  * this work for additional information regarding copyright ownership.
       
    21  * The ASF licenses this file to You under the Apache License, Version 2.0
       
    22  * (the "License"); you may not use this file except in compliance with
       
    23  * the License.  You may obtain a copy of the License at
       
    24  * 
       
    25  *      http://www.apache.org/licenses/LICENSE-2.0
       
    26  * 
       
    27  * Unless required by applicable law or agreed to in writing, software
       
    28  * distributed under the License is distributed on an "AS IS" BASIS,
       
    29  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    30  * See the License for the specific language governing permissions and
       
    31  * limitations under the License.
       
    32  */
       
    33 
       
    34 /*
       
    35  * $Id: MacOSPlatformUtils.hpp 568078 2007-08-21 11:43:25Z amassari $
       
    36  */
       
    37 
       
    38 #pragma once
       
    39 
       
    40 #include <cstdlib>
       
    41 #include <xercesc/util/XercesDefs.hpp>
       
    42 #include <xercesc/util/PlatformUtils.hpp>
       
    43 #include <xercesc/util/Platforms/MacOS/MacAbstractFile.hpp>
       
    44 
       
    45 
       
    46 #if defined(__APPLE__)
       
    47     //	Framework includes from ProjectBuilder
       
    48     #include <CoreServices/CoreServices.h>
       
    49 #else
       
    50     //	Classic includes otherwise
       
    51     #include <Files.h>
       
    52 #endif
       
    53 
       
    54 XERCES_CPP_NAMESPACE_BEGIN
       
    55 
       
    56 //	Notes on our Xerces/Mac paths:
       
    57 //
       
    58 //	Wherever paths are used in Xerces, this Macintosh port assumes that they'll
       
    59 //	be in "unix" format, or at least as close as you can get to that on the particular
       
    60 //	OS. On classic, this means that a path will be a unix style path, separated by '/' and
       
    61 //	starting with the Mac OS volume name. Since slash is used as the segment separator,
       
    62 //	any slashes that actually exist in the segment name will be converted to colons
       
    63 //	(since colon is the Mac OS path separator and would be illegal in a segment name).
       
    64 //	For Mac OS X, paths are created and parsed using the FSRefMakePath, etc, routines:
       
    65 //	the major difference will be location of the volume name within the path.
       
    66 //
       
    67 //	The routines below help to create and interpret these pathnames for these cases.
       
    68 //	While the port itself never creates such paths, it does use these same routines to
       
    69 //	parse them.
       
    70 
       
    71 //	Factory method to create an appropriate concrete object
       
    72 //	descended from XMLMacAbstractFile.
       
    73 XMLUTIL_EXPORT XMLMacAbstractFile* XMLMakeMacFile(MemoryManager* manager);
       
    74 
       
    75 //	Convert fom FSRef/FSSpec to a Unicode character string path.
       
    76 //	Note that you'll need to delete [] that string after you're done with it!
       
    77 XMLUTIL_EXPORT XMLCh*	XMLCreateFullPathFromFSRef(const FSRef& startingRef,
       
    78                             MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager);
       
    79 XMLUTIL_EXPORT XMLCh*	XMLCreateFullPathFromFSSpec(const FSSpec& startingSpec,
       
    80                             MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager);
       
    81 
       
    82 //	Convert from path to FSRef/FSSpec
       
    83 //	You retain ownership of the pathName.
       
    84 //	Note: in the general case, these routines will fail if the specified file
       
    85 //	      does not exist when the routine is called.
       
    86 XMLUTIL_EXPORT bool	XMLParsePathToFSRef(const XMLCh* const pathName, FSRef& ref,
       
    87                             MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager);
       
    88 XMLUTIL_EXPORT bool	XMLParsePathToFSSpec(const XMLCh* const pathName, FSSpec& spec,
       
    89                             MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager);
       
    90 
       
    91 //	These routines copy characters between their representation in the Unicode Converter
       
    92 //	and the representation used by XMLCh. Until a recent change in Xerces, these were
       
    93 //	sometimes different on the Macintosh (with GCC), but XMLCh is now fixed at 16 bits.
       
    94 //	Code utilitizing these routines may be phased out in time, as a conversion is no
       
    95 //	longer necessary.
       
    96 XMLUTIL_EXPORT XMLCh*
       
    97 CopyUniCharsToXMLChs(const UniChar* src, XMLCh* dst, std::size_t charCount, std::size_t maxChars);
       
    98 XMLUTIL_EXPORT UniChar*
       
    99 CopyXMLChsToUniChars(const XMLCh* src, UniChar* dst, std::size_t charCount, std::size_t maxChars);
       
   100 
       
   101 //	UTF8/UniChar transcoding utilities
       
   102 XMLUTIL_EXPORT std::size_t
       
   103 TranscodeUniCharsToUTF8(const UniChar* src, char* dst, std::size_t srcCnt, std::size_t maxChars);
       
   104 XMLUTIL_EXPORT std::size_t
       
   105 TranscodeUTF8ToUniChars(const char* src, UniChar* dst, std::size_t maxChars);
       
   106 
       
   107 // Size of our statically allocated path buffers
       
   108 const std::size_t kMaxMacStaticPathChars = 512;
       
   109 
       
   110 //	Global variables set in platformInit()
       
   111 extern bool gFileSystemCompatible;
       
   112 extern bool gMacOSXOrBetter;
       
   113 extern bool gHasFSSpecAPIs;
       
   114 extern bool gHasFS2TBAPIs;
       
   115 extern bool gHasHFSPlusAPIs;
       
   116 extern bool gHasFSPathAPIs;
       
   117 extern bool gPathAPIsUsePosixPaths;
       
   118 extern bool gHasMPAPIs;
       
   119 extern bool gUsePosixFiles;
       
   120 
       
   121 XERCES_CPP_NAMESPACE_END
       
   122