Removed Common
Change-Id: I01ea8f07220375c2ad9bc0092281d4f27c642303
diff --git a/aos/print_field_helpers.h b/aos/print_field_helpers.h
new file mode 100644
index 0000000..933ce46
--- /dev/null
+++ b/aos/print_field_helpers.h
@@ -0,0 +1,41 @@
+#ifndef AOS_PRINT_FIELD_HELPERS_H_
+#define AOS_PRINT_FIELD_HELPERS_H_
+
+#include <stdint.h>
+
+#include <type_traits>
+
+namespace aos {
+
+template<typename T>
+inline bool PrintInteger(char *buf, T val, size_t *output) {
+ static const bool is_signed = ::std::is_signed<T>::value;
+ const bool is_negative =
+ is_signed ? (val & (static_cast<T>(1) << (sizeof(T) * 8 - 1))) : false;
+
+ size_t len = 0;
+ if (is_negative) {
+ do {
+ if (len == *output) return false;
+ buf[len++] = '0' - (val % 10);
+ val /= 10;
+ } while (val != 0);
+ if (len == *output) return false;
+ buf[len++] = '-';
+ } else {
+ do {
+ if (len == *output) return false;
+ buf[len++] = '0' + (val % 10);
+ val /= 10;
+ } while (val != 0);
+ }
+ for (size_t i = 0; i < (len >> 1); i++) {
+ std::swap(buf[len - 1 - i], buf[i]);
+ }
+ *output -= len;
+ return true;
+}
+
+} // namespace aos
+
+#endif // AOS_PRINT_FIELD_HELPERS_H_