OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef BIN_UTILS_H_ | 5 #ifndef BIN_UTILS_H_ |
6 #define BIN_UTILS_H_ | 6 #define BIN_UTILS_H_ |
7 | 7 |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 int code_; | 54 int code_; |
55 char* message_; | 55 char* message_; |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(OSError); | 57 DISALLOW_COPY_AND_ASSIGN(OSError); |
58 }; | 58 }; |
59 | 59 |
60 class StringUtils { | 60 class StringUtils { |
61 public: | 61 public: |
62 // The following methods convert the argument if needed. The | 62 // The following methods convert the argument if needed. The |
63 // conversions are only needed on Windows. If the methods returns a | 63 // conversions are only needed on Windows. If the methods returns a |
64 // pointer that is different from the input pointer the returned | 64 // pointer that is different from the input pointer the returned |
Lasse Reichstein Nielsen
2015/06/22 12:08:34
comma after second "pointer"
Søren Gjesse
2015/06/23 11:17:59
Done.
| |
65 // pointer is allocated with malloc and should be freed using free. | 65 // pointer is allocated with malloc and should be freed using free. |
66 static const char* ConsoleStringToUtf8(const char* str); | 66 // |
67 static char* ConsoleStringToUtf8(char* str); | 67 // If the len argument is passed that number of characters are |
Lasse Reichstein Nielsen
2015/06/22 12:08:34
comma after "passed", or add a "then".
Søren Gjesse
2015/06/23 11:17:59
Done.
| |
68 static const char* Utf8ToConsoleString(const char* utf8); | 68 // converted. If len is -1 convertion until a null character will ve |
kustermann
2015/06/22 11:11:21
ve -> be
Lasse Reichstein Nielsen
2015/06/22 12:08:34
If len is -1, conversion will stop at the first NU
Søren Gjesse
2015/06/23 11:17:59
Done.
Søren Gjesse
2015/06/23 11:17:59
Done.
| |
69 static char* Utf8ToConsoleString(char* utf8); | 69 // performed. If result_len is not NULL this is set to the number of |
Lasse Reichstein Nielsen
2015/06/22 12:08:34
this is set -> , it is used to set
Søren Gjesse
2015/06/23 11:17:59
Done.
| |
70 static char* WideToUtf8(wchar_t* wide); | 70 // characters in the result. |
71 static const char* WideToUtf8(const wchar_t* wide); | 71 static const char* ConsoleStringToUtf8(const char* str, |
72 static wchar_t* Utf8ToWide(char* utf8); | 72 intptr_t len = -1, |
73 static const wchar_t* Utf8ToWide(const char* utf8); | 73 intptr_t* result_len = NULL); |
74 static char* ConsoleStringToUtf8(char* str, | |
75 intptr_t len = -1, | |
76 intptr_t* result_len = NULL); | |
77 static const char* Utf8ToConsoleString(const char* utf8, | |
78 intptr_t len = -1, | |
79 intptr_t* result_len = NULL); | |
80 static char* Utf8ToConsoleString(char* utf8, | |
81 intptr_t len = -1, | |
82 intptr_t* result_len = NULL); | |
83 static char* WideToUtf8(wchar_t* wide, | |
84 intptr_t len = -1, | |
85 intptr_t* result_len = NULL); | |
86 static const char* WideToUtf8(const wchar_t* wide, | |
87 intptr_t len = -1, | |
88 intptr_t* result_len = NULL); | |
89 static wchar_t* Utf8ToWide(char* utf8, | |
90 intptr_t len = -1, | |
91 intptr_t* result_len = NULL); | |
92 static const wchar_t* Utf8ToWide(const char* utf8, | |
93 intptr_t len = -1, | |
94 intptr_t* result_len = NULL); | |
74 }; | 95 }; |
75 | 96 |
76 class ShellUtils { | 97 class ShellUtils { |
77 public: | 98 public: |
78 // Get the arguments passed to the program as unicode strings. | 99 // Get the arguments passed to the program as unicode strings. |
79 // If GetUnicodeArgv returns a pointer that pointer has to be | 100 // If GetUnicodeArgv returns a pointer that pointer has to be |
80 // deallocated with a call to FreeUnicodeArgv. | 101 // deallocated with a call to FreeUnicodeArgv. |
81 static wchar_t** GetUnicodeArgv(int* argc); | 102 static wchar_t** GetUnicodeArgv(int* argc); |
82 static void FreeUnicodeArgv(wchar_t** argv); | 103 static void FreeUnicodeArgv(wchar_t** argv); |
83 }; | 104 }; |
84 | 105 |
85 class TimerUtils { | 106 class TimerUtils { |
86 public: | 107 public: |
87 static int64_t GetCurrentTimeMicros(); | 108 static int64_t GetCurrentTimeMicros(); |
88 static int64_t GetCurrentTimeMilliseconds(); | 109 static int64_t GetCurrentTimeMilliseconds(); |
89 static void Sleep(int64_t millis); | 110 static void Sleep(int64_t millis); |
90 }; | 111 }; |
91 | 112 |
92 } // namespace bin | 113 } // namespace bin |
93 } // namespace dart | 114 } // namespace dart |
94 | 115 |
95 #endif // BIN_UTILS_H_ | 116 #endif // BIN_UTILS_H_ |
OLD | NEW |