reprodyne/lexcompare.h

355 lines
17 KiB
C++

//This file is part of the reprodyne project and is licensed under the terms of the LGPL-3.0-only
#ifndef RUSTUTILS_LEXCOMPARE
#define RUSTUTILS_LEXCOMPARE
#include <tuple>
//Once upon a time I thought 7 outta be enough. But it proved insufficient, so then I made it 17.
//... Then that wasn't enough... So now it's 22...
#define RUSTUTILS_MACRO_OVERLOAD(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, MACRO, ...) MACRO
#define RUSTUTILS_UNPACK_FINAL(object, field) object . field
#define RUSTUTILS_UNPACK22(object, field22, field21, field20, field19, field18, field17, field16, field15, field14, field13, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field22) , \
RUSTUTILS_UNPACK_FINAL(object, field21) , \
RUSTUTILS_UNPACK_FINAL(object, field20) , \
RUSTUTILS_UNPACK_FINAL(object, field19) , \
RUSTUTILS_UNPACK_FINAL(object, field18) , \
RUSTUTILS_UNPACK_FINAL(object, field17) , \
RUSTUTILS_UNPACK_FINAL(object, field16) , \
RUSTUTILS_UNPACK_FINAL(object, field15) , \
RUSTUTILS_UNPACK_FINAL(object, field14) , \
RUSTUTILS_UNPACK_FINAL(object, field13) , \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK21(object, field21, field20, field19, field18, field17, field16, field15, field14, field13, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field21) , \
RUSTUTILS_UNPACK_FINAL(object, field20) , \
RUSTUTILS_UNPACK_FINAL(object, field19) , \
RUSTUTILS_UNPACK_FINAL(object, field18) , \
RUSTUTILS_UNPACK_FINAL(object, field17) , \
RUSTUTILS_UNPACK_FINAL(object, field16) , \
RUSTUTILS_UNPACK_FINAL(object, field15) , \
RUSTUTILS_UNPACK_FINAL(object, field14) , \
RUSTUTILS_UNPACK_FINAL(object, field13) , \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK20(object, field20, field19, field18, field17, field16, field15, field14, field13, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field20) , \
RUSTUTILS_UNPACK_FINAL(object, field19) , \
RUSTUTILS_UNPACK_FINAL(object, field18) , \
RUSTUTILS_UNPACK_FINAL(object, field17) , \
RUSTUTILS_UNPACK_FINAL(object, field16) , \
RUSTUTILS_UNPACK_FINAL(object, field15) , \
RUSTUTILS_UNPACK_FINAL(object, field14) , \
RUSTUTILS_UNPACK_FINAL(object, field13) , \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK19(object, field19, field18, field17, field16, field15, field14, field13, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field19) , \
RUSTUTILS_UNPACK_FINAL(object, field18) , \
RUSTUTILS_UNPACK_FINAL(object, field17) , \
RUSTUTILS_UNPACK_FINAL(object, field16) , \
RUSTUTILS_UNPACK_FINAL(object, field15) , \
RUSTUTILS_UNPACK_FINAL(object, field14) , \
RUSTUTILS_UNPACK_FINAL(object, field13) , \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK18(object, field18, field17, field16, field15, field14, field13, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field18) , \
RUSTUTILS_UNPACK_FINAL(object, field17) , \
RUSTUTILS_UNPACK_FINAL(object, field16) , \
RUSTUTILS_UNPACK_FINAL(object, field15) , \
RUSTUTILS_UNPACK_FINAL(object, field14) , \
RUSTUTILS_UNPACK_FINAL(object, field13) , \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK17(object, field17, field16, field15, field14, field13, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field17) , \
RUSTUTILS_UNPACK_FINAL(object, field16) , \
RUSTUTILS_UNPACK_FINAL(object, field15) , \
RUSTUTILS_UNPACK_FINAL(object, field14) , \
RUSTUTILS_UNPACK_FINAL(object, field13) , \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK16(object, field16, field15, field14, field13, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field16) , \
RUSTUTILS_UNPACK_FINAL(object, field15) , \
RUSTUTILS_UNPACK_FINAL(object, field14) , \
RUSTUTILS_UNPACK_FINAL(object, field13) , \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK15(object, field15, field14, field13, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field15) , \
RUSTUTILS_UNPACK_FINAL(object, field14) , \
RUSTUTILS_UNPACK_FINAL(object, field13) , \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK14(object, field14, field13, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field14) , \
RUSTUTILS_UNPACK_FINAL(object, field13) , \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK13(object, field13, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field13) , \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK12(object, field12, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field12) , \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK11(object, field11, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field11) , \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK10(object, field10, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field10) , \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK9(object, field9, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field9) , \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK8(object, field8, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field8) , \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK7(object, field7, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field7) , \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK6(object, field6, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field6) , \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK5(object, field5, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field5) , \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK4(object, field4, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field4) , \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK3(object, field3, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field3) , \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK2(object, field2, field1) \
RUSTUTILS_UNPACK_FINAL(object, field2) , \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK1(object, field1) \
RUSTUTILS_UNPACK_FINAL(object, field1)
#define RUSTUTILS_UNPACK(object, fields...) \
RUSTUTILS_MACRO_OVERLOAD(fields, \
RUSTUTILS_UNPACK22, \
RUSTUTILS_UNPACK21, \
RUSTUTILS_UNPACK20, \
RUSTUTILS_UNPACK19, \
RUSTUTILS_UNPACK18, \
RUSTUTILS_UNPACK17, \
RUSTUTILS_UNPACK16, \
RUSTUTILS_UNPACK15, \
RUSTUTILS_UNPACK14, \
RUSTUTILS_UNPACK13, \
RUSTUTILS_UNPACK12, \
RUSTUTILS_UNPACK11, \
RUSTUTILS_UNPACK10, \
RUSTUTILS_UNPACK9, \
RUSTUTILS_UNPACK8, \
RUSTUTILS_UNPACK7, \
RUSTUTILS_UNPACK6, \
RUSTUTILS_UNPACK5, \
RUSTUTILS_UNPACK4, \
RUSTUTILS_UNPACK3, \
RUSTUTILS_UNPACK2, \
RUSTUTILS_UNPACK1)(object, fields)
#define RUSTUTILS_DEFINE_COMP(type, fields...) \
friend bool operator<(const type & left, const type & right) \
{ \
return std::tie(RUSTUTILS_UNPACK(left, fields)) < \
std::tie(RUSTUTILS_UNPACK(right, fields)); \
} \
friend bool operator!=(const type & left, const type & right) \
{ \
return left < right || right < left; \
} \
friend bool operator==(const type & left, const type & right) \
{ \
return !(left != right); \
}
#endif // RUSTUTILS_LEXCOMPARE