| 90 | |
| 91 | |
| 92 | bool Attributes::contains(const Attribute& attribute) const |
| 93 | { |
| 94 | foreach (const Attribute& attr, attributes) { |
| 95 | if (attr.name() == attribute.name() && attr.type() == attribute.type()) { |
| 96 | switch (attr.type()) { |
| 97 | case Value::SCALAR: |
| 98 | if (attr.scalar() == attribute.scalar()) { |
| 99 | return true; |
| 100 | } |
| 101 | break; |
| 102 | |
| 103 | case Value::RANGES: |
| 104 | if (attr.ranges() == attribute.ranges()) { |
| 105 | return true; |
| 106 | } |
| 107 | break; |
| 108 | |
| 109 | case Value::TEXT: |
| 110 | if (attr.text() == attribute.text()) { |
| 111 | return true; |
| 112 | } |
| 113 | break; |
| 114 | |
| 115 | case Value::SET: |
| 116 | LOG(FATAL) << "Sets not supported for attributes"; |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | return false; |
| 122 | } |
| 123 | |
| 124 | |
| 125 | Attribute Attributes::parse(const string& name, const string& text) |