1 /* 2 * Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "RatingStability.h" 8 9 #include <Collator.h> 10 11 #include "LocaleUtils.h" 12 #include "Logger.h" 13 14 15 bool IsRatingStabilityBefore(const RatingStabilityRef& rs1, 16 const RatingStabilityRef& rs2) 17 { 18 if (rs1.Get() == NULL || rs2.Get() == NULL) 19 HDFATAL("unexpected NULL reference in a referencable"); 20 return rs1.Get()->Compare(*(rs2.Get())) < 0; 21 } 22 23 24 RatingStability::RatingStability() 25 : 26 fCode(), 27 fName(), 28 fOrdering(0) 29 { 30 } 31 32 33 RatingStability::RatingStability(const BString& code, 34 const BString& name, int64 ordering) 35 : 36 fCode(code), 37 fName(name), 38 fOrdering(ordering) 39 { 40 } 41 42 43 RatingStability::RatingStability(const RatingStability& other) 44 : 45 fCode(other.fCode), 46 fName(other.fName), 47 fOrdering(other.fOrdering) 48 { 49 } 50 51 52 RatingStability& 53 RatingStability::operator=(const RatingStability& other) 54 { 55 fCode = other.fCode; 56 fName = other.fName; 57 fOrdering = other.fOrdering; 58 return *this; 59 } 60 61 62 bool 63 RatingStability::operator==(const RatingStability& other) const 64 { 65 return fCode == other.fCode && fName == other.fName 66 && fOrdering == other.fOrdering; 67 } 68 69 70 bool 71 RatingStability::operator!=(const RatingStability& other) const 72 { 73 return !(*this == other); 74 } 75 76 77 int 78 RatingStability::Compare(const RatingStability& other) const 79 { 80 int32 result = other.Ordering() - Ordering(); 81 if (0 == result) 82 result = Code().Compare(other.Code()); 83 return result; 84 } 85