libmDot 1.0.12-hotfix
MTS-Utils/Utils.h@0:5f84bdd949b8, 2016-07-17 (annotated)
- Committer:
- shaunkrnelson
- Date:
- Sun Jul 17 00:03:03 2016 +0000
- Revision:
- 0:5f84bdd949b8
1.0.12-hotfix
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shaunkrnelson | 0:5f84bdd949b8 | 1 | #ifndef UTILS_H |
shaunkrnelson | 0:5f84bdd949b8 | 2 | #define UTILS_H |
shaunkrnelson | 0:5f84bdd949b8 | 3 | |
shaunkrnelson | 0:5f84bdd949b8 | 4 | #include <string> |
shaunkrnelson | 0:5f84bdd949b8 | 5 | |
shaunkrnelson | 0:5f84bdd949b8 | 6 | //Defines a max function that can be used. |
shaunkrnelson | 0:5f84bdd949b8 | 7 | inline int mts_max(int a, int b) { return a > b ? a : b; } |
shaunkrnelson | 0:5f84bdd949b8 | 8 | |
shaunkrnelson | 0:5f84bdd949b8 | 9 | //Defines a min function that can be used. |
shaunkrnelson | 0:5f84bdd949b8 | 10 | inline int mts_min(int a, int b) { return a < b ? a : b; } |
shaunkrnelson | 0:5f84bdd949b8 | 11 | |
shaunkrnelson | 0:5f84bdd949b8 | 12 | ///An enumeration for relational operators |
shaunkrnelson | 0:5f84bdd949b8 | 13 | enum RelationalOperator { |
shaunkrnelson | 0:5f84bdd949b8 | 14 | GREATER, LESS, EQUAL, GREATER_EQUAL, LESS_EQUAL |
shaunkrnelson | 0:5f84bdd949b8 | 15 | }; |
shaunkrnelson | 0:5f84bdd949b8 | 16 | |
shaunkrnelson | 0:5f84bdd949b8 | 17 | /** A static method for getting a string representation for the RelationalOperator |
shaunkrnelson | 0:5f84bdd949b8 | 18 | * enumeration. |
shaunkrnelson | 0:5f84bdd949b8 | 19 | * |
shaunkrnelson | 0:5f84bdd949b8 | 20 | * @param relationalOperator a RelationalOperator enumeration. |
shaunkrnelson | 0:5f84bdd949b8 | 21 | * @returns the enumeration name as a string. |
shaunkrnelson | 0:5f84bdd949b8 | 22 | */ |
shaunkrnelson | 0:5f84bdd949b8 | 23 | static inline std::string getRelationalOperatorNames(RelationalOperator relationalOperator) |
shaunkrnelson | 0:5f84bdd949b8 | 24 | { |
shaunkrnelson | 0:5f84bdd949b8 | 25 | switch(relationalOperator) { |
shaunkrnelson | 0:5f84bdd949b8 | 26 | case GREATER: |
shaunkrnelson | 0:5f84bdd949b8 | 27 | return "GREATER"; |
shaunkrnelson | 0:5f84bdd949b8 | 28 | case LESS: |
shaunkrnelson | 0:5f84bdd949b8 | 29 | return "LESS"; |
shaunkrnelson | 0:5f84bdd949b8 | 30 | case EQUAL: |
shaunkrnelson | 0:5f84bdd949b8 | 31 | return "EQUAL"; |
shaunkrnelson | 0:5f84bdd949b8 | 32 | case GREATER_EQUAL: |
shaunkrnelson | 0:5f84bdd949b8 | 33 | return "GREATER_EQUAL"; |
shaunkrnelson | 0:5f84bdd949b8 | 34 | case LESS_EQUAL: |
shaunkrnelson | 0:5f84bdd949b8 | 35 | return "LESS_EQUAL"; |
shaunkrnelson | 0:5f84bdd949b8 | 36 | default: |
shaunkrnelson | 0:5f84bdd949b8 | 37 | return "UNKNOWN ENUM"; |
shaunkrnelson | 0:5f84bdd949b8 | 38 | } |
shaunkrnelson | 0:5f84bdd949b8 | 39 | } |
shaunkrnelson | 0:5f84bdd949b8 | 40 | |
shaunkrnelson | 0:5f84bdd949b8 | 41 | #endif |