diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-07-08 12:06:47 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-07-08 12:06:47 -0700 |
commit | 462b26c1cc041a8fa26deb62cf12f1f351a5b2f6 (patch) | |
tree | de5a58f8d66d11c13b349448a970f84d57d16cad /src/upb_enum.h | |
parent | c7ee14f8ef38a8bc90c0f1db1ad47b2e06612fa3 (diff) |
Directory restructuring.
Diffstat (limited to 'src/upb_enum.h')
-rw-r--r-- | src/upb_enum.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/upb_enum.h b/src/upb_enum.h new file mode 100644 index 0000000..9fea3a4 --- /dev/null +++ b/src/upb_enum.h @@ -0,0 +1,41 @@ +/* + * upb - a minimalist implementation of protocol buffers. + * + * Copyright (c) 2009 Joshua Haberman. See LICENSE for details. + * + * upb_enum is a simple object that allows run-time reflection over the values + * defined within an enum. */ + +#ifndef UPB_ENUM_H_ +#define UPB_ENUM_H_ + +#include <stdint.h> +#include "upb_table.h" + +/* Forward declaration from descriptor.h. */ +struct google_protobuf_EnumDescriptorProto; +struct google_protobuf_EnumValueDescriptorProto; + +struct upb_enum { + struct google_protobuf_EnumDescriptorProto *descriptor; + struct upb_strtable nametoint; + struct upb_inttable inttoname; +}; + +struct upb_enum_ntoi_entry { + struct upb_strtable_entry e; + uint32_t value; +}; + +struct upb_enum_iton_entry { + struct upb_inttable_entry e; + struct upb_string *string; +}; + +/* Initializes and frees an enum, respectively. Caller retains ownership of + * ed, but it must outlive e. */ +void upb_enum_init(struct upb_enum *e, + struct google_protobuf_EnumDescriptorProto *ed); +void upb_enum_free(struct upb_enum *e); + +#endif /* UPB_ENUM_H_ */ |