| 30 | |
| 31 | |
| 32 | class Attributes |
| 33 | { |
| 34 | public: |
| 35 | Attributes() {} |
| 36 | |
| 37 | /*implicit*/ |
| 38 | Attributes(const google::protobuf::RepeatedPtrField<Attribute>& _attributes) |
| 39 | { |
| 40 | attributes.MergeFrom(_attributes); |
| 41 | } |
| 42 | |
| 43 | /*implicit*/ |
| 44 | Attributes(const Attributes& that) |
| 45 | { |
| 46 | attributes.MergeFrom(that.attributes); |
| 47 | } |
| 48 | |
| 49 | Attributes& operator=(const Attributes& that) |
| 50 | { |
| 51 | if (this != &that) { |
| 52 | attributes.Clear(); |
| 53 | attributes.MergeFrom(that.attributes); |
| 54 | } |
| 55 | |
| 56 | return *this; |
| 57 | } |
| 58 | |
| 59 | bool operator==(const Attributes& that) const; |
| 60 | |
| 61 | |
| 62 | bool operator!=(const Attributes& that) const |
| 63 | { |
| 64 | return !(*this == that); |
| 65 | } |
| 66 | |
| 67 | size_t size() const |
| 68 | { |
| 69 | return attributes.size(); |
| 70 | } |
| 71 | |
| 72 | // Using this operator makes it easy to copy an attributes object into |
| 73 | // a protocol buffer field. |
| 74 | operator const google::protobuf::RepeatedPtrField<Attribute>&() const |
| 75 | { |
| 76 | return attributes; |
| 77 | } |
| 78 | |
| 79 | void add(const Attribute& attribute) |
| 80 | { |
| 81 | attributes.Add()->MergeFrom(attribute); |
| 82 | } |
| 83 | |
| 84 | const Attribute get(int index) const |
| 85 | { |
| 86 | return attributes.Get(index); |
| 87 | } |
| 88 | |
| 89 | // Gets an attribute with the same name and type as the given |