| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 |
| 31 // Defines classes for field comparison. | 31 // Author: ksroka@google.com (Krzysztof Sroka) |
| 32 | 32 |
| 33 #ifndef GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ | 33 #ifndef GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ |
| 34 #define GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ | 34 #define GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ |
| 35 | 35 |
| 36 #include <map> | 36 #include <map> |
| 37 #include <string> | 37 #include <string> |
| 38 | 38 |
| 39 #include <google/protobuf/stubs/common.h> | 39 #include <google/protobuf/stubs/common.h> |
| 40 | 40 |
| 41 namespace google { | 41 namespace google { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 double margin; | 160 double margin; |
| 161 Tolerance() | 161 Tolerance() |
| 162 : fraction(0.0), | 162 : fraction(0.0), |
| 163 margin(0.0) {} | 163 margin(0.0) {} |
| 164 Tolerance(double f, double m) | 164 Tolerance(double f, double m) |
| 165 : fraction(f), | 165 : fraction(f), |
| 166 margin(m) {} | 166 margin(m) {} |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 // Defines the map to store the tolerances for floating point comparison. | 169 // Defines the map to store the tolerances for floating point comparison. |
| 170 typedef std::map<const FieldDescriptor*, Tolerance> ToleranceMap; | 170 typedef map<const FieldDescriptor*, Tolerance> ToleranceMap; |
| 171 | 171 |
| 172 // The following methods get executed when CompareFields is called for the | 172 // The following methods get executed when CompareFields is called for the |
| 173 // basic types (instead of submessages). They return true on success. One | 173 // basic types (instead of submessages). They return true on success. One |
| 174 // can use ResultFromBoolean() to convert that boolean to a ComparisonResult | 174 // can use ResultFromBoolean() to convert that boolean to a ComparisonResult |
| 175 // value. | 175 // value. |
| 176 bool CompareBool(const google::protobuf::FieldDescriptor& field, | 176 bool CompareBool(const google::protobuf::FieldDescriptor& field, |
| 177 bool value_1, bool value_2) { | 177 bool value_1, bool value_2) { |
| 178 return value_1 == value_2; | 178 return value_1 == value_2; |
| 179 } | 179 } |
| 180 | 180 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 ToleranceMap map_tolerance_; | 250 ToleranceMap map_tolerance_; |
| 251 | 251 |
| 252 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DefaultFieldComparator); | 252 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DefaultFieldComparator); |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 } // namespace util | 255 } // namespace util |
| 256 } // namespace protobuf | 256 } // namespace protobuf |
| 257 | 257 |
| 258 } // namespace google | 258 } // namespace google |
| 259 #endif // GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ | 259 #endif // GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ |
| OLD | NEW |