1*ed2f6d3bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ed2f6d3bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ed2f6d3bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ed2f6d3bSAndrew Rist * distributed with this work for additional information 6*ed2f6d3bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ed2f6d3bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ed2f6d3bSAndrew Rist * "License"); you may not use this file except in compliance 9*ed2f6d3bSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*ed2f6d3bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*ed2f6d3bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ed2f6d3bSAndrew Rist * software distributed under the License is distributed on an 15*ed2f6d3bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ed2f6d3bSAndrew Rist * KIND, either express or implied. See the License for the 17*ed2f6d3bSAndrew Rist * specific language governing permissions and limitations 18*ed2f6d3bSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*ed2f6d3bSAndrew Rist *************************************************************/ 21*ed2f6d3bSAndrew Rist 22*ed2f6d3bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef UTILITIES_HXX_INCLUDED 25cdf0e10cSrcweir #define UTILITIES_HXX_INCLUDED 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <malloc.h> 28cdf0e10cSrcweir #if defined _MSC_VER 29cdf0e10cSrcweir #pragma warning(push, 1) 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir #ifndef OS2 32cdf0e10cSrcweir #include <windows.h> 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir #if defined _MSC_VER 35cdf0e10cSrcweir #pragma warning(pop) 36cdf0e10cSrcweir #endif 37cdf0e10cSrcweir #include <stdio.h> 38cdf0e10cSrcweir #include <fcntl.h> 39cdf0e10cSrcweir #include <io.h> 40cdf0e10cSrcweir #include "internal/types.hxx" 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <string> 43cdf0e10cSrcweir #define STRSAFE_NO_DEPRECATE 44cdf0e10cSrcweir #include <strsafe.h> 45cdf0e10cSrcweir 46cdf0e10cSrcweir //--------------------------------- 47cdf0e10cSrcweir /** Convert a string to a wstring 48cdf0e10cSrcweir using CP_ACP 49cdf0e10cSrcweir */ 50cdf0e10cSrcweir std::wstring StringToWString(const std::string& String); 51cdf0e10cSrcweir 52cdf0e10cSrcweir //--------------------------------- 53cdf0e10cSrcweir /** Convert a wstring to a string 54cdf0e10cSrcweir using CP_ACP 55cdf0e10cSrcweir */ 56cdf0e10cSrcweir std::string WStringToString(const std::wstring& String); 57cdf0e10cSrcweir 58cdf0e10cSrcweir //--------------------------------- 59cdf0e10cSrcweir /** Retrieve a string from the 60cdf0e10cSrcweir resources of this module 61cdf0e10cSrcweir */ 62cdf0e10cSrcweir std::wstring GetResString(int ResId); 63cdf0e10cSrcweir 64cdf0e10cSrcweir //--------------------------------- 65cdf0e10cSrcweir /** Returns whether we are running 66cdf0e10cSrcweir on Windows XP or not 67cdf0e10cSrcweir */ 68cdf0e10cSrcweir bool is_windows_xp_or_above(); 69cdf0e10cSrcweir 70cdf0e10cSrcweir //--------------------------------- 71cdf0e10cSrcweir /** helper function to judge if the string is only has spaces. 72cdf0e10cSrcweir @returns 73cdf0e10cSrcweir <TRUE>if the provided string contains only but at least one space 74cdf0e10cSrcweir character else <FALSE/>. 75cdf0e10cSrcweir */ 76cdf0e10cSrcweir bool HasOnlySpaces(const std::wstring& String); 77cdf0e10cSrcweir 78cdf0e10cSrcweir /** convert LocaleSet pair into Windows LCID identifier. 79cdf0e10cSrcweir @returns 80cdf0e10cSrcweir Windows Locale Identifier corresponding to input LocaleSet. 81cdf0e10cSrcweir */ 82cdf0e10cSrcweir 83cdf0e10cSrcweir //--------------------------------- 84cdf0e10cSrcweir /** Convert a long path name using Windows api call GetShortPathName 85cdf0e10cSrcweir */ 86cdf0e10cSrcweir std::wstring getShortPathName( const std::wstring& aLongName ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir 89cdf0e10cSrcweir #ifndef OS2 90cdf0e10cSrcweir LCID LocaleSetToLCID( const LocaleSet_t & Locale ); 91cdf0e10cSrcweir #endif 92cdf0e10cSrcweir 93cdf0e10cSrcweir //---------------------------------------------------------- 94cdf0e10cSrcweir #ifdef DEBUG 95cdf0e10cSrcweir inline void OutputDebugStringFormat( LPCSTR pFormat, ... ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir CHAR buffer[1024]; 98cdf0e10cSrcweir va_list args; 99cdf0e10cSrcweir 100cdf0e10cSrcweir va_start( args, pFormat ); 101cdf0e10cSrcweir StringCchVPrintfA( buffer, sizeof(buffer), pFormat, args ); 102cdf0e10cSrcweir OutputDebugStringA( buffer ); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir #else 105cdf0e10cSrcweir static inline void OutputDebugStringFormat( LPCSTR, ... ) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir } 108cdf0e10cSrcweir #endif 109cdf0e10cSrcweir //---------------------------------------------------------- 110cdf0e10cSrcweir 111cdf0e10cSrcweir 112cdf0e10cSrcweir #endif 113