// Copyright (c) 2011 Bryan Schumaker. #include #include #include /* * Return positive value if s1 > s2 * Return negative value if s1 < s2 * Return 0 s1 == s2 */ static inline int compare_strings(string *s1, string *s2) { /* List empty strings last */ if (*s1 == "") return 1; if (*s2 == "") return -1; return s1->compare(*s2); } namespace libsaria { /* Return true if this < cmp_track */ bool Track::operator<(Track &cmp_track) { int cmp; /* Compare artists */ cmp = compare_strings(artist_lc, cmp_track.artist_lc); if (cmp < 0) return true; else if (cmp > 0) return false; /* Compare albums */ cmp = compare_strings(album_lc, cmp_track.album_lc); if (cmp < 0) return true; else if (cmp > 0) return false; /* Compare tracks */ return track < cmp_track.track; } }