Index: third_party/crazy_linker/crazy_linker/src/crazy_linker_error.h |
diff --git a/third_party/crazy_linker/crazy_linker/src/crazy_linker_error.h b/third_party/crazy_linker/crazy_linker/src/crazy_linker_error.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..676e583bb455e1cc470c034f2178284c4cb774f7 |
--- /dev/null |
+++ b/third_party/crazy_linker/crazy_linker/src/crazy_linker_error.h |
@@ -0,0 +1,51 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CRAZY_LINKER_ERROR_H |
+#define CRAZY_LINKER_ERROR_H |
+ |
+namespace crazy { |
+ |
+// A class used to hold a fixed-size buffer to hold error messages |
+// as well as perform assignment and formatting. |
+// |
+// Usage examples: |
+// Error error; |
+// error = "Unimplemented feature"; |
+// error->Set("Unimplemented feature"); |
+// error->Format("Feature %s is not implemented", feature_name); |
+// error->Append(strerror(errno)); |
+// error->AppendFormat("Error: %s", strerror(errno)); |
+// |
+class Error { |
+public: |
+ Error() { |
+ buff_[0] = '\0'; |
+ } |
+ |
+ Error(const char* message) { |
+ Set(message); |
+ } |
+ |
+ Error(const Error& other) { |
+ Set(other.buff_); |
+ } |
+ |
+ const char* c_str() const { return buff_; } |
+ |
+ void Set(const char* message); |
+ |
+ void Format(const char* fmt, ...); |
+ |
+ void Append(const char* message); |
+ |
+ void AppendFormat(const char* fmt, ...); |
+ |
+private: |
+ char buff_[512]; |
+}; |
+ |
+} // namespace crazy |
+ |
+#endif // CRAZY_LINKER_ERROR_H |