From 648aa3b32fb75ced3a02bc32900901c4f33fb8be Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 31 Mar 2015 23:39:10 +0200 Subject: Add equals and smaller than operator to SyntaxDescriptor (for std::sort or the use in std::set) --- src/core/model/Syntax.hpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/core/model/Syntax.hpp') diff --git a/src/core/model/Syntax.hpp b/src/core/model/Syntax.hpp index 97a2995..91b2226 100644 --- a/src/core/model/Syntax.hpp +++ b/src/core/model/Syntax.hpp @@ -157,6 +157,29 @@ struct SyntaxDescriptor { { } + /** + * Equality operator, returns true if the two SyntaxDescriptor instances + * are exactly equal. + * + * @param o1 is the first syntax descriptor for the comparison. + * @param o2 is the second syntax descriptor for the comparison. + * @return true if the two syntax descriptors equal, false otherwise. + */ + friend bool operator==(const SyntaxDescriptor &o1, + const SyntaxDescriptor &o2); + + /** + * Orders two SyntaxDescriptor instances by their depth, open, close and + * shortForm TokenId and the descriptor pointer. Additionally, + * SyntaxDescriptors belonging to FieldDescriptors are prefered. + * + * @param o1 is the first syntax descriptor for the comparison. + * @param o2 is the second syntax descriptor for the comparison. + * @return true if o1 is should be ordered before o2. + */ + friend bool operator<(const SyntaxDescriptor &o1, + const SyntaxDescriptor &o2); + /** * Inserts all tokens referenced in this SyntaxDescriptor into the * given TokenSet. Skips token ids set to Tokens::Empty. -- cgit v1.2.3