From 7d3e2bd2c4cfd1296d1d6f996d7548de26540d41 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Fri, 15 Feb 2013 16:27:18 -0800 Subject: Sync with 8 months of Google-internal development. Many things have changed and been simplified. The memory-management story for upb_def and upb_handlers is much more robust; upb_def and upb_handlers should be fairly stable interfaces now. There is still much work to do for the runtime component (upb_sink). --- bindings/cpp/upb/upb.hpp | 81 ------------------------------------------------ 1 file changed, 81 deletions(-) delete mode 100644 bindings/cpp/upb/upb.hpp (limited to 'bindings/cpp/upb/upb.hpp') diff --git a/bindings/cpp/upb/upb.hpp b/bindings/cpp/upb/upb.hpp deleted file mode 100644 index 48c2708..0000000 --- a/bindings/cpp/upb/upb.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// -// upb - a minimalist implementation of protocol buffers. -// -// Copyright (c) 2011 Google Inc. See LICENSE for details. -// Author: Josh Haberman - -#ifndef UPB_HPP -#define UPB_HPP - -#include "upb/upb.h" -#include - -#if defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(UPB_NO_CXX11) -#define UPB_DISALLOW_CONSTRUCT_AND_DESTRUCT(class_name) \ - class_name() = delete; \ - ~class_name() = delete; -#else -#define UPB_DISALLOW_CONSTRUCT_AND_DESTRUCT(class_name) \ - class_name(); \ - ~class_name(); -#endif - -namespace upb { - -typedef upb_success_t Success; - -class Status : public upb_status { - public: - Status() { upb_status_init(this); } - ~Status() { upb_status_uninit(this); } - - bool ok() const { return upb_ok(this); } - bool eof() const { return upb_eof(this); } - - const char *GetString() const { return upb_status_getstr(this); } - void SetEof() { upb_status_seteof(this); } - void SetErrorLiteral(const char* msg) { - upb_status_seterrliteral(this, msg); - } - - void Clear() { upb_status_clear(this); } -}; - -typedef upb_value Value; - -template T GetValue(Value v); -template Value MakeValue(T v); - -#define UPB_VALUE_ACCESSORS(type, ctype) \ - template <> inline ctype GetValue(Value v) { \ - return upb_value_get ## type(v); \ - } \ - template <> inline Value MakeValue(ctype v) { \ - return upb_value_ ## type(v); \ - } - -UPB_VALUE_ACCESSORS(double, double); -UPB_VALUE_ACCESSORS(float, float); -UPB_VALUE_ACCESSORS(int32, int32_t); -UPB_VALUE_ACCESSORS(int64, int64_t); -UPB_VALUE_ACCESSORS(uint32, uint32_t); -UPB_VALUE_ACCESSORS(uint64, uint64_t); -UPB_VALUE_ACCESSORS(bool, bool); - -#undef UPB_VALUE_ACCESSORS - -template inline T* GetPtrValue(Value v) { - return static_cast(upb_value_getptr(v)); -} -template inline Value MakePtrValue(T* v) { - return upb_value_ptr(static_cast(v)); -} - -INLINE std::ostream& operator<<(std::ostream& out, const Status& status) { - out << status.GetString(); - return out; -} - -} // namespace upb - -#endif -- cgit v1.2.3