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