xref: /aoo4110/main/shell/inc/internal/utilities.hxx (revision b1cdbd2c)
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 #ifndef OS2
44 #define STRSAFE_NO_DEPRECATE
45 #include <strsafe.h>
46 #endif
47 
48 //---------------------------------
49 /** Convert a string to a wstring
50 	using CP_ACP
51 */
52 std::wstring StringToWString(const std::string& String);
53 
54 //---------------------------------
55 /** Convert a wstring to a string
56 	using CP_ACP
57 */
58 std::string WStringToString(const std::wstring& String);
59 
60 //---------------------------------
61 /** Retrieve a string from the
62 	resources of this module
63 */
64 std::wstring GetResString(int ResId);
65 
66 //---------------------------------
67 /** Returns whether we are running
68     on Windows XP or not
69 */
70 bool is_windows_xp_or_above();
71 
72 //---------------------------------
73 /** helper function to judge if the string is only has spaces.
74     @returns
75         <TRUE>if the provided string contains only but at least one space
76         character else <FALSE/>.
77 */
78 bool HasOnlySpaces(const std::wstring& String);
79 
80 /** convert LocaleSet pair into Windows LCID identifier.
81     @returns
82         Windows Locale Identifier corresponding to input LocaleSet.
83 */
84 
85 //---------------------------------
86 /** Convert a long path name using Windows api call GetShortPathName
87 */
88 std::wstring getShortPathName( const std::wstring& aLongName );
89 
90 
91 #ifndef OS2
92 LCID LocaleSetToLCID( const LocaleSet_t & Locale );
93 #endif
94 
95 #ifdef OS2
96 typedef const   char            *LPCSTR;
97 #endif
98 
99 //----------------------------------------------------------
100 #ifdef DEBUG
OutputDebugStringFormat(LPCSTR pFormat,...)101 inline void OutputDebugStringFormat( LPCSTR pFormat, ... )
102 {
103 #ifndef OS2
104 	CHAR    buffer[1024];
105 	va_list args;
106 
107 	va_start( args, pFormat );
108 	StringCchVPrintfA( buffer, sizeof(buffer), pFormat, args );
109 	OutputDebugStringA( buffer );
110 #endif
111 }
112 #else
OutputDebugStringFormat(LPCSTR,...)113 static inline void OutputDebugStringFormat( LPCSTR, ... )
114 {
115 }
116 #endif
117 //----------------------------------------------------------
118 
119 
120 #endif
121