OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CRAZY_LINKER_ERROR_H |
| 6 #define CRAZY_LINKER_ERROR_H |
| 7 |
| 8 namespace crazy { |
| 9 |
| 10 // A class used to hold a fixed-size buffer to hold error messages |
| 11 // as well as perform assignment and formatting. |
| 12 // |
| 13 // Usage examples: |
| 14 // Error error; |
| 15 // error = "Unimplemented feature"; |
| 16 // error->Set("Unimplemented feature"); |
| 17 // error->Format("Feature %s is not implemented", feature_name); |
| 18 // error->Append(strerror(errno)); |
| 19 // error->AppendFormat("Error: %s", strerror(errno)); |
| 20 // |
| 21 class Error { |
| 22 public: |
| 23 Error() { |
| 24 buff_[0] = '\0'; |
| 25 } |
| 26 |
| 27 Error(const char* message) { |
| 28 Set(message); |
| 29 } |
| 30 |
| 31 Error(const Error& other) { |
| 32 Set(other.buff_); |
| 33 } |
| 34 |
| 35 const char* c_str() const { return buff_; } |
| 36 |
| 37 void Set(const char* message); |
| 38 |
| 39 void Format(const char* fmt, ...); |
| 40 |
| 41 void Append(const char* message); |
| 42 |
| 43 void AppendFormat(const char* fmt, ...); |
| 44 |
| 45 private: |
| 46 char buff_[512]; |
| 47 }; |
| 48 |
| 49 } // namespace crazy |
| 50 |
| 51 #endif // CRAZY_LINKER_ERROR_H |
OLD | NEW |