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 11 matching lines...) Expand all Loading... |
22 OSError(); | 22 OSError(); |
23 OSError(int code, const char* message, SubSystem sub_system) { | 23 OSError(int code, const char* message, SubSystem sub_system) { |
24 sub_system_ = sub_system; | 24 sub_system_ = sub_system; |
25 code_ = code; | 25 code_ = code; |
26 message_ = NULL; // SetMessage will free existing message. | 26 message_ = NULL; // SetMessage will free existing message. |
27 SetMessage(message); | 27 SetMessage(message); |
28 } | 28 } |
29 virtual ~OSError() { free(message_); } | 29 virtual ~OSError() { free(message_); } |
30 | 30 |
31 SubSystem sub_system() { return sub_system_; } | 31 SubSystem sub_system() { return sub_system_; } |
| 32 int code() { return code_; } |
| 33 char* message() { return message_; } |
| 34 void SetCodeAndMessage(SubSystem sub_system, int code); |
| 35 |
| 36 private: |
32 void set_sub_system(SubSystem sub_system) { sub_system_ = sub_system; } | 37 void set_sub_system(SubSystem sub_system) { sub_system_ = sub_system; } |
33 int code() { return code_; } | |
34 void set_code(int code) { code_ = code; } | 38 void set_code(int code) { code_ = code; } |
35 char* message() { return message_; } | |
36 void SetMessage(const char* message) { | 39 void SetMessage(const char* message) { |
37 free(message_); | 40 free(message_); |
38 if (message == NULL) { | 41 if (message == NULL) { |
39 message_ = NULL; | 42 message_ = NULL; |
40 } else { | 43 } else { |
41 message_ = strdup(message); | 44 message_ = strdup(message); |
42 } | 45 } |
43 } | 46 } |
44 | 47 |
45 private: | |
46 SubSystem sub_system_; | 48 SubSystem sub_system_; |
47 int code_; | 49 int code_; |
48 char* message_; | 50 char* message_; |
49 | 51 |
50 DISALLOW_COPY_AND_ASSIGN(OSError); | 52 DISALLOW_COPY_AND_ASSIGN(OSError); |
51 }; | 53 }; |
52 | 54 |
53 #endif // BIN_UTILS_H_ | 55 #endif // BIN_UTILS_H_ |
OLD | NEW |