author | kcr |
Thu, 10 Jan 2019 11:30:09 -0800 | |
branch | JDK-8200758-branch |
changeset 57106 | ea870b9ce89a |
parent 57064 | a7fdadf67a92 |
child 57194 | 9d5fccd97421 |
permissions | -rw-r--r-- |
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
1 |
/* |
57106
ea870b9ce89a
8216492: Update copyright of all new jpackage fils to 2019
kcr
parents:
57064
diff
changeset
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
4 |
* |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
10 |
* |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
15 |
* accompanied this code). |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
16 |
* |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
20 |
* |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
23 |
* questions. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
24 |
*/ |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
25 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
26 |
#ifndef PLATFORMSTRING_H |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
27 |
#define PLATFORMSTRING_H |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
28 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
29 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
30 |
#include <string> |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
31 |
#include <list> |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
32 |
#include <stdio.h> |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
33 |
#include <stdlib.h> |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
34 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
35 |
#include "jni.h" |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
36 |
#include "Platform.h" |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
37 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
38 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
39 |
struct WideString { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
40 |
size_t length; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
41 |
wchar_t* data; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
42 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
43 |
WideString() { length = 0; data = NULL; } |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
44 |
}; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
45 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
46 |
struct MultibyteString { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
47 |
size_t length; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
48 |
char* data; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
49 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
50 |
MultibyteString() { length = 0; data = NULL; } |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
51 |
}; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
52 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
53 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
54 |
template <typename T> |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
55 |
class DynamicBuffer { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
56 |
private: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
57 |
T* FData; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
58 |
size_t FSize; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
59 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
60 |
public: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
61 |
DynamicBuffer(size_t Size) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
62 |
FSize = 0; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
63 |
FData = NULL; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
64 |
Resize(Size); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
65 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
66 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
67 |
~DynamicBuffer() { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
68 |
delete[] FData; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
69 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
70 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
71 |
T* GetData() { return FData; } |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
72 |
size_t GetSize() { return FSize; } |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
73 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
74 |
bool Resize(size_t Size) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
75 |
FSize = Size; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
76 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
77 |
if (FData != NULL) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
78 |
delete[] FData; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
79 |
FData = NULL; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
80 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
81 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
82 |
if (FSize != 0) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
83 |
FData = new T[FSize]; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
84 |
if (FData != NULL) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
85 |
Zero(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
86 |
} else { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
87 |
return false; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
88 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
89 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
90 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
91 |
return true; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
92 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
93 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
94 |
void Zero() { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
95 |
memset(FData, 0, FSize * sizeof(T)); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
96 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
97 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
98 |
T& operator[](size_t index) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
99 |
return FData[index]; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
100 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
101 |
}; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
102 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
103 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
104 |
#ifdef MAC |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
105 |
// StringToFileSystemString is a stack object. It's usage is |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
106 |
// simply inline to convert a |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
107 |
// TString to a file system string. Example: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
108 |
// |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
109 |
// return dlopen(StringToFileSystemString(FileName), RTLD_LAZY); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
110 |
// |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
111 |
class StringToFileSystemString { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
112 |
// Prohibit Heap-Based StringToFileSystemString |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
113 |
private: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
114 |
static void *operator new(size_t size); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
115 |
static void operator delete(void *ptr); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
116 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
117 |
private: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
118 |
TCHAR* FData; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
119 |
bool FRelease; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
120 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
121 |
public: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
122 |
StringToFileSystemString(const TString &value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
123 |
~StringToFileSystemString(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
124 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
125 |
operator TCHAR* (); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
126 |
}; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
127 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
128 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
129 |
// FileSystemStringToString is a stack object. It's usage is |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
130 |
// simply inline to convert a |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
131 |
// file system string to a TString. Example: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
132 |
// |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
133 |
// DynamicBuffer<TCHAR> buffer(MAX_PATH); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
134 |
// if (readlink("/proc/self/exe", buffer.GetData(), MAX_PATH) != -1) |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
135 |
// result = FileSystemStringToString(buffer.GetData()); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
136 |
// |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
137 |
class FileSystemStringToString { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
138 |
// Prohibit Heap-Based FileSystemStringToString |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
139 |
private: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
140 |
static void *operator new(size_t size); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
141 |
static void operator delete(void *ptr); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
142 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
143 |
private: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
144 |
TString FData; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
145 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
146 |
public: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
147 |
FileSystemStringToString(const TCHAR* value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
148 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
149 |
operator TString (); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
150 |
}; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
151 |
#endif //MAC |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
152 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
153 |
#ifdef LINUX |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
154 |
#define StringToFileSystemString PlatformString |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
155 |
#define FileSystemStringToString PlatformString |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
156 |
#endif //LINUX |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
157 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
158 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
159 |
class PlatformString { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
160 |
private: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
161 |
char* FData; // Stored as UTF-8 |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
162 |
size_t FLength; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
163 |
wchar_t* FWideTStringToFree; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
164 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
165 |
void initialize(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
166 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
167 |
// Caller must free result using delete[]. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
168 |
static void CopyString(char *Destination, |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
169 |
size_t NumberOfElements, const char *Source); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
170 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
171 |
// Caller must free result using delete[]. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
172 |
static void CopyString(wchar_t *Destination, |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
173 |
size_t NumberOfElements, const wchar_t *Source); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
174 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
175 |
static WideString MultibyteStringToWideString(const char* value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
176 |
static MultibyteString WideStringToMultibyteString(const wchar_t* value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
177 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
178 |
// Prohibit Heap-Based PlatformStrings |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
179 |
private: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
180 |
static void *operator new(size_t size); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
181 |
static void operator delete(void *ptr); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
182 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
183 |
public: |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
184 |
PlatformString(void); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
185 |
PlatformString(const PlatformString &value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
186 |
PlatformString(const char* value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
187 |
PlatformString(const wchar_t* value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
188 |
PlatformString(const std::string &value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
189 |
PlatformString(const std::wstring &value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
190 |
PlatformString(JNIEnv *env, jstring value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
191 |
PlatformString(size_t Value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
192 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
193 |
static TString Format(const TString value, ...); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
194 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
195 |
~PlatformString(void); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
196 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
197 |
size_t length(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
198 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
199 |
char* c_str(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
200 |
char* toMultibyte(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
201 |
wchar_t* toWideString(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
202 |
std::wstring toUnicodeString(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
203 |
std::string toStdString(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
204 |
jstring toJString(JNIEnv *env); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
205 |
TCHAR* toPlatformString(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
206 |
TString toString(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
207 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
208 |
operator char* (); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
209 |
operator wchar_t* (); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
210 |
operator std::wstring (); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
211 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
212 |
// Caller must free result using delete[]. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
213 |
static char* duplicate(const char* Value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
214 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
215 |
// Caller must free result using delete[]. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
216 |
static wchar_t* duplicate(const wchar_t* Value); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
217 |
}; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
218 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
219 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
220 |
#endif // PLATFORMSTRING_H |