arduino_ci 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,172 @@
1
+ #pragma once
2
+
3
+ #include <stdlib.h>
4
+ #include <string>
5
+ #include <algorithm>
6
+ #include <iostream>
7
+ #include "AvrMath.h"
8
+ #include "WCharacter.h"
9
+
10
+ typedef std::string string;
11
+
12
+ typedef char __FlashStringHelper;
13
+ <<<<<<< Updated upstream
14
+
15
+ #define F(string_literal) (string_literal)
16
+ =======
17
+ //class __FlashStringHelper;
18
+ #define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
19
+ >>>>>>> Stashed changes
20
+
21
+ // Compatibility with string class
22
+ class String: public string
23
+ {
24
+ public:
25
+
26
+ // allow "string s; if (s) {}"
27
+ // http://www.artima.com/cppsource/safebool.html
28
+ typedef void (String::*TTDNSCstring)() const;
29
+ void ttdnsc() const {}
30
+ operator TTDNSCstring() const { return &String::ttdnsc; }
31
+
32
+ private:
33
+ static const char* digit(int val) {
34
+ static const char* bank = "0123456789ABCDEF";
35
+ return bank + val;
36
+ }
37
+
38
+ static string mytoa(unsigned long val, int base) {
39
+ int n = val % base;
40
+ string place = string(digit(n), 1);
41
+ if (val < base) return place;
42
+ return mytoa(val / base, base) + place;
43
+ }
44
+
45
+ static string mytoas(long val, int base) {
46
+ string ret = mytoa(abs(val), base);
47
+ return 0 <= val ? ret : string("-") + ret;
48
+ }
49
+
50
+ static string dtoas(double val, int decimalPlaces) {
51
+ double r = 0.5 * pow(0.1, decimalPlaces); // make sure that integer truncation will properly round
52
+ if (::isnan(val)) return "nan";
53
+ if (::isinf(val)) return "inf";
54
+ val += val > 0 ? r : -r;
55
+ if (val > 4294967040.0) return "ovf";
56
+ if (val <-4294967040.0) return "ovf";
57
+ return mytoas(val, 10) + "." + mytoa(abs(val - (long)val) * pow(10, decimalPlaces), 10);
58
+ }
59
+
60
+ public:
61
+ ~String(void) {}
62
+ String(const char *cstr = ""): string(cstr) {}
63
+ String(const string &str): string(str) {}
64
+ String(const String &str): string(str) {}
65
+ explicit String(char c): string(1, c) {}
66
+
67
+ explicit String(unsigned char val, unsigned char base=10): string(mytoa(val, base)) {}
68
+ explicit String(int val, unsigned char base=10): string(mytoas(val, base)) {}
69
+ explicit String(unsigned int val , unsigned char base=10): string(mytoa(val, base)) {}
70
+ explicit String(long val, unsigned char base=10): string(mytoas(val, base)) {}
71
+ explicit String(unsigned long val, unsigned char base=10): string(mytoa(val, base)) {}
72
+
73
+ explicit String(float val, unsigned char decimalPlaces=2): string(dtoas(val, decimalPlaces)) {}
74
+ explicit String(double val, unsigned char decimalPlaces=2): string(dtoas(val, decimalPlaces)) {}
75
+
76
+ String & operator = (const String &rhs) { assign(rhs); return *this; }
77
+ String & operator = (const string &rhs) { assign(rhs); return *this; }
78
+ String & operator = (const char *cstr) { assign(cstr); return *this; }
79
+ String & operator = (const char c) { assign(1, c); return *this; }
80
+
81
+ unsigned char concat(const String &str) { append(str); return 1; }
82
+ unsigned char concat(const char *cstr) { append(cstr); return 1; }
83
+ unsigned char concat(char c) { append(1, c); return 1; }
84
+ unsigned char concat(unsigned char c) { append(1, c); return 1; }
85
+ unsigned char concat(int num) { append(String(num)); return 1; }
86
+ unsigned char concat(unsigned int num) { append(String(num)); return 1; }
87
+ unsigned char concat(long num) { append(String(num)); return 1; }
88
+ unsigned char concat(unsigned long num) { append(String(num)); return 1; }
89
+ unsigned char concat(float num) { append(String(num)); return 1; }
90
+ unsigned char concat(double num) { append(String(num)); return 1; }
91
+
92
+ String & operator += (const String &rhs) { concat(rhs); return *this; }
93
+ String & operator += (const char *cstr) { concat(cstr); return *this; }
94
+ String & operator += (char c) { concat(c); return *this; }
95
+ String & operator += (unsigned char num) { concat(num); return *this; }
96
+ String & operator += (int num) { concat(num); return *this; }
97
+ String & operator += (unsigned int num) { concat(num); return *this; }
98
+ String & operator += (long num) { concat(num); return *this; }
99
+ String & operator += (unsigned long num) { concat(num); return *this; }
100
+ String & operator += (float num) { concat(num); return *this; }
101
+ String & operator += (double num) { concat(num); return *this; }
102
+
103
+
104
+ int compareTo(const String &s) const { return compare(s); }
105
+ unsigned char equals(const String &s) const { return compareTo(s) == 0; }
106
+ unsigned char equals(const char *cstr) const { return compareTo(String(cstr)) == 0; }
107
+ unsigned char equal(const String &s) const { return equals(s); }
108
+ unsigned char equal(const char *cstr) const { return equals(cstr); }
109
+ unsigned char equalsIgnoreCase(const String &s) const {
110
+ String a = String(*this);
111
+ String b = String(s);
112
+ a.toUpperCase();
113
+ b.toUpperCase();
114
+ return a.compare(b) == 0;
115
+ }
116
+
117
+ unsigned char startsWith(const String &prefix) const { return find(prefix) == 0; }
118
+ unsigned char startsWith(const String &prefix, unsigned int offset) const { return find(prefix, offset) == offset; }
119
+ unsigned char endsWith(const String &suffix) const { return rfind(suffix) == length() - suffix.length(); }
120
+
121
+ char charAt(unsigned int index) const { return operator[](index); }
122
+ void setCharAt(unsigned int index, char c) { (*this)[index] = c; }
123
+
124
+ void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const { copy((char*)buf, bufsize, index); }
125
+ void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
126
+ { getBytes((unsigned char *)buf, bufsize, index); }
127
+
128
+ int indexOf( char ch ) const { return find(ch); }
129
+ int indexOf( char ch, unsigned int fromIndex ) const { return find(ch, fromIndex); }
130
+ int indexOf( const String &str ) const { return find(str); }
131
+ int indexOf( const String &str, unsigned int fromIndex ) const { return find(str, fromIndex); }
132
+ int lastIndexOf( char ch ) const { return rfind(ch); }
133
+ int lastIndexOf( char ch, unsigned int fromIndex ) const { return rfind(ch, fromIndex); }
134
+ int lastIndexOf( const String &str ) const { return rfind(str); }
135
+ int lastIndexOf( const String &str, unsigned int fromIndex ) const { return rfind(str, fromIndex); }
136
+ String substring( unsigned int beginIndex ) const { return String(substr(beginIndex)); }
137
+ String substring( unsigned int beginIndex, unsigned int endIndex ) const { return String(substr(beginIndex, endIndex)); }
138
+
139
+ void replace(const String& target, const String& repl) {
140
+ int i = 0;
141
+ while ((i = find(target, i)) != npos) {
142
+ assign(substr(0, i) + repl + substr(i + target.length()));
143
+ i += repl.length();
144
+ }
145
+ }
146
+ void replace(char target, char repl) {
147
+ replace(String(target), String(repl));
148
+ }
149
+ void remove(unsigned int index) { assign(substr(0, index)); }
150
+ void remove(unsigned int index, unsigned int count) { assign(substr(0, index) + substr(min(length(), index + count), count)); }
151
+ void toLowerCase(void) { std::transform(begin(), end(), begin(), ::tolower); }
152
+ void toUpperCase(void) { std::transform(begin(), end(), begin(), ::toupper); }
153
+
154
+ void trim(void) {
155
+ int b;
156
+ int e;
157
+ for (b = 0; b < length() && isSpace(charAt(b)); ++b);
158
+ for (e = length() - 1; e > b && isSpace(charAt(e)); --e);
159
+ assign(substr(b, e - b + 1));
160
+ }
161
+
162
+ long toInt(void) const { return std::stol(*this); }
163
+ float toFloat(void) const { return std::stof(*this); }
164
+ double toDouble(void) const { return std::stod(*this); }
165
+
166
+ };
167
+
168
+ inline std::ostream& operator << ( std::ostream& out, const String& bs ) {
169
+ out << bs.c_str();
170
+ return out;
171
+ }
172
+
@@ -1,10 +1,9 @@
1
1
  #pragma once
2
2
 
3
-
4
3
  /*
5
4
  def d(var_raw)
6
5
  var = var_raw.split("_")[0]
7
- out = "#define #{var}_P(...) #{var}(__VA_ARGS__)\n"
6
+ out = "#define #{var}_P(...) ::#{var}(__VA_ARGS__)\n"
8
7
  IO.popen('pbcopy', 'w') { |f| f << out }
9
8
  out
10
9
  end
@@ -16,6 +15,7 @@ out.each { |l| puts d(l) }
16
15
  */
17
16
 
18
17
  #include <avr/io.h>
18
+ #include <string.h>
19
19
 
20
20
  #define PROGMEM
21
21
 
@@ -49,46 +49,46 @@ out.each { |l| puts d(l) }
49
49
  #define pgm_read_ptr(x) (x)
50
50
  #define pgm_get_far_address(x) (x)
51
51
 
52
- #define memchr_P(...) memchr(__VA_ARGS__)
53
- #define memcmp_P(...) memcmp(__VA_ARGS__)
54
- #define memccpy_P(...) memccpy(__VA_ARGS__)
55
- #define memcpy_P(...) memcpy(__VA_ARGS__)
56
- #define memmem_P(...) memmem(__VA_ARGS__)
57
- #define memrchr_P(...) memrchr(__VA_ARGS__)
58
- #define strcat_P(...) strcat(__VA_ARGS__)
59
- #define strchr_P(...) strchr(__VA_ARGS__)
60
- #define strchrnul_P(...) strchrnul(__VA_ARGS__)
61
- #define strcmp_P(...) strcmp(__VA_ARGS__)
62
- #define strcpy_P(...) strcpy(__VA_ARGS__)
63
- #define strcasecmp_P(...) strcasecmp(__VA_ARGS__)
64
- #define strcasestr_P(...) strcasestr(__VA_ARGS__)
65
- #define strcspn_P(...) strcspn(__VA_ARGS__)
66
- #define strlcat_P(...) strlcat(__VA_ARGS__)
67
- #define strlcpy_P(...) strlcpy(__VA_ARGS__)
68
- #define strnlen_P(...) strnlen(__VA_ARGS__)
69
- #define strncmp_P(...) strncmp(__VA_ARGS__)
70
- #define strncasecmp_P(...) strncasecmp(__VA_ARGS__)
71
- #define strncat_P(...) strncat(__VA_ARGS__)
72
- #define strncpy_P(...) strncpy(__VA_ARGS__)
73
- #define strpbrk_P(...) strpbrk(__VA_ARGS__)
74
- #define strrchr_P(...) strrchr(__VA_ARGS__)
75
- #define strsep_P(...) strsep(__VA_ARGS__)
76
- #define strspn_P(...) strspn(__VA_ARGS__)
77
- #define strstr_P(...) strstr(__VA_ARGS__)
78
- #define strtok_P(...) strtok(__VA_ARGS__)
79
- #define strtok_P(...) strtok(__VA_ARGS__)
80
- #define strlen_P(...) strlen(__VA_ARGS__)
81
- #define strnlen_P(...) strnlen(__VA_ARGS__)
82
- #define memcpy_P(...) memcpy(__VA_ARGS__)
83
- #define strcpy_P(...) strcpy(__VA_ARGS__)
84
- #define strncpy_P(...) strncpy(__VA_ARGS__)
85
- #define strcat_P(...) strcat(__VA_ARGS__)
86
- #define strlcat_P(...) strlcat(__VA_ARGS__)
87
- #define strncat_P(...) strncat(__VA_ARGS__)
88
- #define strcmp_P(...) strcmp(__VA_ARGS__)
89
- #define strncmp_P(...) strncmp(__VA_ARGS__)
90
- #define strcasecmp_P(...) strcasecmp(__VA_ARGS__)
91
- #define strncasecmp_P(...) strncasecmp(__VA_ARGS__)
92
- #define strstr_P(...) strstr(__VA_ARGS__)
93
- #define strlcpy_P(...) strlcpy(__VA_ARGS__)
94
- #define memcmp_P(...) memcmp(__VA_ARGS__)
52
+ #define memchr_P(...) ::memchr(__VA_ARGS__)
53
+ #define memcmp_P(...) ::memcmp(__VA_ARGS__)
54
+ #define memccpy_P(...) ::memccpy(__VA_ARGS__)
55
+ #define memcpy_P(...) ::memcpy(__VA_ARGS__)
56
+ #define memmem_P(...) ::memmem(__VA_ARGS__)
57
+ #define memrchr_P(...) ::memrchr(__VA_ARGS__)
58
+ #define strcat_P(...) ::strcat(__VA_ARGS__)
59
+ #define strchr_P(...) ::strchr(__VA_ARGS__)
60
+ #define strchrnul_P(...) ::strchrnul(__VA_ARGS__)
61
+ #define strcmp_P(...) ::strcmp(__VA_ARGS__)
62
+ #define strcpy_P(...) ::strcpy(__VA_ARGS__)
63
+ #define strcasecmp_P(...) ::strcasecmp(__VA_ARGS__)
64
+ #define strcasestr_P(...) ::strcasestr(__VA_ARGS__)
65
+ #define strcspn_P(...) ::strcspn(__VA_ARGS__)
66
+ #define strlcat_P(...) ::strlcat(__VA_ARGS__)
67
+ #define strlcpy_P(...) ::strlcpy(__VA_ARGS__)
68
+ #define strnlen_P(...) ::strnlen(__VA_ARGS__)
69
+ #define strncmp_P(...) ::strncmp(__VA_ARGS__)
70
+ #define strncasecmp_P(...) ::strncasecmp(__VA_ARGS__)
71
+ #define strncat_P(...) ::strncat(__VA_ARGS__)
72
+ #define strncpy_P(...) ::strncpy(__VA_ARGS__)
73
+ #define strpbrk_P(...) ::strpbrk(__VA_ARGS__)
74
+ #define strrchr_P(...) ::strrchr(__VA_ARGS__)
75
+ #define strsep_P(...) ::strsep(__VA_ARGS__)
76
+ #define strspn_P(...) ::strspn(__VA_ARGS__)
77
+ #define strstr_P(...) ::strstr(__VA_ARGS__)
78
+ #define strtok_P(...) ::strtok(__VA_ARGS__)
79
+ #define strtok_P(...) ::strtok(__VA_ARGS__)
80
+ #define strlen_P(...) ::strlen(__VA_ARGS__)
81
+ #define strnlen_P(...) ::strnlen(__VA_ARGS__)
82
+ #define memcpy_P(...) ::memcpy(__VA_ARGS__)
83
+ #define strcpy_P(...) ::strcpy(__VA_ARGS__)
84
+ #define strncpy_P(...) ::strncpy(__VA_ARGS__)
85
+ #define strcat_P(...) ::strcat(__VA_ARGS__)
86
+ #define strlcat_P(...) ::strlcat(__VA_ARGS__)
87
+ #define strncat_P(...) ::strncat(__VA_ARGS__)
88
+ #define strcmp_P(...) ::strcmp(__VA_ARGS__)
89
+ #define strncmp_P(...) ::strncmp(__VA_ARGS__)
90
+ #define strcasecmp_P(...) ::strcasecmp(__VA_ARGS__)
91
+ #define strncasecmp_P(...) ::strncasecmp(__VA_ARGS__)
92
+ #define strstr_P(...) ::strstr(__VA_ARGS__)
93
+ #define strlcpy_P(...) ::strlcpy(__VA_ARGS__)
94
+ #define memcmp_P(...) ::memcmp(__VA_ARGS__)
@@ -0,0 +1,95 @@
1
+ #pragma once
2
+
3
+
4
+ /*
5
+ def d(var_raw)
6
+ var = var_raw.split("_")[0]
7
+ out = "#define #{var}_P(...) ::#{var}(__VA_ARGS__)\n"
8
+ IO.popen('pbcopy', 'w') { |f| f << out }
9
+ out
10
+ end
11
+
12
+ text = File.open("arduino-1.8.5/hardware/tools/avr/avr/include/avr/pgmspace.h").read
13
+ externs = text.split("\n").select {|l| l.start_with? "extern"}
14
+ out = externs.map {|l| l.split("(")[0].split(" ")[-1].gsub("*", "") }.uniq
15
+ out.each { |l| puts d(l) }
16
+ */
17
+
18
+ #include <avr/io.h>
19
+ #include <string>
20
+
21
+ #define PROGMEM
22
+
23
+ #ifndef PGM_P
24
+ #define PGM_P const char *
25
+ #endif
26
+
27
+ #ifndef PGM_VOID_P
28
+ #define PGM_VOID_P const void *
29
+ #endif
30
+
31
+ // everything's a no-op
32
+ #define PSTR(s) ((const char *)(s))
33
+ #define pgm_read_byte_near(x) (x)
34
+ #define pgm_read_word_near(x) (x)
35
+ #define pgm_read_dword_near(x) (x)
36
+ #define pgm_read_float_near(x) (x)
37
+ #define pgm_read_ptr_near(x) (x)
38
+
39
+ #define pgm_read_byte_far(x) (x)
40
+ #define pgm_read_word_far(x) (x)
41
+ #define pgm_read_dword_far(x) (x)
42
+ #define pgm_read_float_far(x) (x)
43
+ #define pgm_read_ptr_far(x) (x)
44
+
45
+
46
+ #define pgm_read_byte(x) (x)
47
+ #define pgm_read_word(x) (x)
48
+ #define pgm_read_dword(x) (x)
49
+ #define pgm_read_float(x) (x)
50
+ #define pgm_read_ptr(x) (x)
51
+ #define pgm_get_far_address(x) (x)
52
+
53
+ #define memchr_P(...) ::memchr(__VA_ARGS__)
54
+ #define memcmp_P(...) ::memcmp(__VA_ARGS__)
55
+ #define memccpy_P(...) ::memccpy(__VA_ARGS__)
56
+ #define memcpy_P(...) ::memcpy(__VA_ARGS__)
57
+ #define memmem_P(...) ::memmem(__VA_ARGS__)
58
+ #define memrchr_P(...) ::memrchr(__VA_ARGS__)
59
+ #define strcat_P(...) ::strcat(__VA_ARGS__)
60
+ #define strchr_P(...) ::strchr(__VA_ARGS__)
61
+ #define strchrnul_P(...) ::strchrnul(__VA_ARGS__)
62
+ #define strcmp_P(...) ::strcmp(__VA_ARGS__)
63
+ #define strcpy_P(...) ::strcpy(__VA_ARGS__)
64
+ #define strcasecmp_P(...) ::strcasecmp(__VA_ARGS__)
65
+ #define strcasestr_P(...) ::strcasestr(__VA_ARGS__)
66
+ #define strcspn_P(...) ::strcspn(__VA_ARGS__)
67
+ #define strlcat_P(...) ::strlcat(__VA_ARGS__)
68
+ #define strlcpy_P(...) ::strlcpy(__VA_ARGS__)
69
+ #define strnlen_P(...) ::strnlen(__VA_ARGS__)
70
+ #define strncmp_P(...) ::strncmp(__VA_ARGS__)
71
+ #define strncasecmp_P(...) ::strncasecmp(__VA_ARGS__)
72
+ #define strncat_P(...) ::strncat(__VA_ARGS__)
73
+ #define strncpy_P(...) ::strncpy(__VA_ARGS__)
74
+ #define strpbrk_P(...) ::strpbrk(__VA_ARGS__)
75
+ #define strrchr_P(...) ::strrchr(__VA_ARGS__)
76
+ #define strsep_P(...) ::strsep(__VA_ARGS__)
77
+ #define strspn_P(...) ::strspn(__VA_ARGS__)
78
+ #define strstr_P(...) ::strstr(__VA_ARGS__)
79
+ #define strtok_P(...) ::strtok(__VA_ARGS__)
80
+ #define strtok_P(...) ::strtok(__VA_ARGS__)
81
+ #define strlen_P(...) ::strlen(__VA_ARGS__)
82
+ #define strnlen_P(...) ::strnlen(__VA_ARGS__)
83
+ #define memcpy_P(...) ::memcpy(__VA_ARGS__)
84
+ #define strcpy_P(...) ::strcpy(__VA_ARGS__)
85
+ #define strncpy_P(...) ::strncpy(__VA_ARGS__)
86
+ #define strcat_P(...) ::strcat(__VA_ARGS__)
87
+ #define strlcat_P(...) ::strlcat(__VA_ARGS__)
88
+ #define strncat_P(...) ::strncat(__VA_ARGS__)
89
+ #define strcmp_P(...) ::strcmp(__VA_ARGS__)
90
+ #define strncmp_P(...) ::strncmp(__VA_ARGS__)
91
+ #define strcasecmp_P(...) ::strcasecmp(__VA_ARGS__)
92
+ #define strncasecmp_P(...) ::strncasecmp(__VA_ARGS__)
93
+ #define strstr_P(...) ::strstr(__VA_ARGS__)
94
+ #define strlcpy_P(...) ::strlcpy(__VA_ARGS__)
95
+ #define memcmp_P(...) ::memcmp(__VA_ARGS__)
@@ -30,9 +30,9 @@ class Queue {
30
30
 
31
31
  inline bool empty() const { return 0 == mSize; }
32
32
 
33
- const T& front() const { return empty() ? mNil : mFront->data; }
33
+ T front() const { return empty() ? mNil : mFront->data; }
34
34
 
35
- const T& back() const { return empty() ? mNil : mBack->data; }
35
+ T back() const { return empty() ? mNil : mBack->data; }
36
36
 
37
37
  bool push(const T& v)
38
38
  {
@@ -113,8 +113,8 @@ class Test
113
113
  static const int RESULT_FAIL = 2;
114
114
  static const int RESULT_SKIP = 3;
115
115
 
116
- const inline char *name() { return mName; }
117
- const inline int result() { return mResult; }
116
+ inline const char *name() const { return mName; }
117
+ inline int result() const { return mResult; }
118
118
 
119
119
  Test(const char* _name) : mName(_name) {
120
120
  mResult = RESULT_NONE;
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
- #include "string.h"
2
+ #include <avr/pgmspace.h>
3
+ #include <WString.h>
3
4
 
4
5
  template < typename A, typename B > struct Compare
5
6
  {
@@ -34,17 +35,250 @@ template < typename A, typename B > struct Compare
34
35
  return !(a<b);
35
36
  } // moreOrEqual
36
37
  };
37
-
38
+ template < > struct Compare<String,String>;
39
+ template < > struct Compare<String,const char *>;
40
+ #if defined(F)
41
+ template < > struct Compare<String,const __FlashStringHelper *>;
42
+ #endif
43
+ template < > struct Compare<String,char *>;
44
+ template < size_t M > struct Compare<String,char [M]>;
45
+ template < > struct Compare<const char *,String>;
38
46
  template < > struct Compare<const char *,const char *>;
47
+ #if defined(F)
48
+ template < > struct Compare<const char *,const __FlashStringHelper *>;
49
+ #endif
39
50
  template < > struct Compare<const char *,char *>;
40
- template < long M > struct Compare<const char *,char [M]>;
51
+ template < size_t M > struct Compare<const char *,char [M]>;
52
+ #if defined(F)
53
+ template < > struct Compare<const __FlashStringHelper *,String>;
54
+ #endif
55
+ #if defined(F)
56
+ template < > struct Compare<const __FlashStringHelper *,const char *>;
57
+ #endif
58
+ #if defined(F)
59
+ template < > struct Compare<const __FlashStringHelper *,const __FlashStringHelper *>;
60
+ #endif
61
+ #if defined(F)
62
+ template < > struct Compare<const __FlashStringHelper *,char *>;
63
+ #endif
64
+ #if defined(F)
65
+ template < size_t M > struct Compare<const __FlashStringHelper *,char [M]>;
66
+ #endif
67
+ template < > struct Compare<char *,String>;
41
68
  template < > struct Compare<char *,const char *>;
69
+ #if defined(F)
70
+ template < > struct Compare<char *,const __FlashStringHelper *>;
71
+ #endif
42
72
  template < > struct Compare<char *,char *>;
43
- template < long M > struct Compare<char *,char [M]>;
44
- template < long N > struct Compare<char [N],const char *>;
45
- template < long N > struct Compare<char [N],char *>;
46
- template < long N, long M > struct Compare<char [N],char [M]>;
73
+ template < size_t M > struct Compare<char *,char [M]>;
74
+ template < size_t N > struct Compare<char [N],String>;
75
+ template < size_t N > struct Compare<char [N],const char *>;
76
+ #if defined(F)
77
+ template < size_t N > struct Compare<char [N],const __FlashStringHelper *>;
78
+ #endif
79
+ template < size_t N > struct Compare<char [N],char *>;
80
+ template < size_t N, size_t M > struct Compare<char [N],char [M]>;
81
+ template < > struct Compare<String,String>
82
+ {
83
+ inline static int between(const String &a,const String &b)
84
+ {
85
+ return a.compareTo(b);
86
+ } // between
87
+ inline static bool equal(const String &a,const String &b)
88
+ {
89
+ return between(a,b) == 0;
90
+ } // equal
91
+ inline static bool notEqual(const String &a,const String &b)
92
+ {
93
+ return between(a,b) != 0;
94
+ } // notEqual
95
+ inline static bool less(const String &a,const String &b)
96
+ {
97
+ return between(a,b) < 0;
98
+ } // less
99
+ inline static bool more(const String &a,const String &b)
100
+ {
101
+ return between(a,b) > 0;
102
+ } // more
103
+ inline static bool lessOrEqual(const String &a,const String &b)
104
+ {
105
+ return between(a,b) <= 0;
106
+ } // lessOrEqual
107
+ inline static bool moreOrEqual(const String &a,const String &b)
108
+ {
109
+ return between(a,b) >= 0;
110
+ } // moreOrEqual
111
+ };
112
+ template < > struct Compare<String,const char *>
113
+ {
114
+ inline static int between(const String &a,const char * const &b)
115
+ {
116
+ return a.compareTo(b);
117
+ } // between
118
+ inline static bool equal(const String &a,const char * const &b)
119
+ {
120
+ return between(a,b) == 0;
121
+ } // equal
122
+ inline static bool notEqual(const String &a,const char * const &b)
123
+ {
124
+ return between(a,b) != 0;
125
+ } // notEqual
126
+ inline static bool less(const String &a,const char * const &b)
127
+ {
128
+ return between(a,b) < 0;
129
+ } // less
130
+ inline static bool more(const String &a,const char * const &b)
131
+ {
132
+ return between(a,b) > 0;
133
+ } // more
134
+ inline static bool lessOrEqual(const String &a,const char * const &b)
135
+ {
136
+ return between(a,b) <= 0;
137
+ } // lessOrEqual
138
+ inline static bool moreOrEqual(const String &a,const char * const &b)
139
+ {
140
+ return between(a,b) >= 0;
141
+ } // moreOrEqual
142
+ };
143
+ #if defined(F)
144
+ template < > struct Compare<String,const __FlashStringHelper *>
145
+ {
146
+ inline static int between(const String &a,const __FlashStringHelper * const &b)
147
+ {
148
+ uint8_t a_buf[4],b_buf[4];
149
+ uint16_t i=0;
47
150
 
151
+ for (;;) {
152
+ uint8_t j=(i%4);
153
+ if (j == 0) {
154
+ a.getBytes(a_buf,4,i);
155
+ memcpy_P(b_buf,((const char *)b)+i,4);
156
+ }
157
+ if (a_buf[j] < b_buf[j]) return -1;
158
+ if (a_buf[j] > b_buf[j]) return 1;
159
+ if (a_buf[j] == 0) return 0;
160
+ ++i;
161
+ }
162
+ } // between
163
+ inline static bool equal(const String &a,const __FlashStringHelper * const &b)
164
+ {
165
+ return between(a,b) == 0;
166
+ } // equal
167
+ inline static bool notEqual(const String &a,const __FlashStringHelper * const &b)
168
+ {
169
+ return between(a,b) != 0;
170
+ } // notEqual
171
+ inline static bool less(const String &a,const __FlashStringHelper * const &b)
172
+ {
173
+ return between(a,b) < 0;
174
+ } // less
175
+ inline static bool more(const String &a,const __FlashStringHelper * const &b)
176
+ {
177
+ return between(a,b) > 0;
178
+ } // more
179
+ inline static bool lessOrEqual(const String &a,const __FlashStringHelper * const &b)
180
+ {
181
+ return between(a,b) <= 0;
182
+ } // lessOrEqual
183
+ inline static bool moreOrEqual(const String &a,const __FlashStringHelper * const &b)
184
+ {
185
+ return between(a,b) >= 0;
186
+ } // moreOrEqual
187
+ };
188
+ #endif
189
+ template < > struct Compare<String,char *>
190
+ {
191
+ inline static int between(const String &a,char * const &b)
192
+ {
193
+ return a.compareTo(b);
194
+ } // between
195
+ inline static bool equal(const String &a,char * const &b)
196
+ {
197
+ return between(a,b) == 0;
198
+ } // equal
199
+ inline static bool notEqual(const String &a,char * const &b)
200
+ {
201
+ return between(a,b) != 0;
202
+ } // notEqual
203
+ inline static bool less(const String &a,char * const &b)
204
+ {
205
+ return between(a,b) < 0;
206
+ } // less
207
+ inline static bool more(const String &a,char * const &b)
208
+ {
209
+ return between(a,b) > 0;
210
+ } // more
211
+ inline static bool lessOrEqual(const String &a,char * const &b)
212
+ {
213
+ return between(a,b) <= 0;
214
+ } // lessOrEqual
215
+ inline static bool moreOrEqual(const String &a,char * const &b)
216
+ {
217
+ return between(a,b) >= 0;
218
+ } // moreOrEqual
219
+ };
220
+ template < size_t M > struct Compare<String,char [M]>
221
+ {
222
+ inline static int between(const String &a,const char (&b)[M])
223
+ {
224
+ return a.compareTo(b);
225
+ } // between
226
+ inline static bool equal(const String &a,const char (&b)[M])
227
+ {
228
+ return between(a,b) == 0;
229
+ } // equal
230
+ inline static bool notEqual(const String &a,const char (&b)[M])
231
+ {
232
+ return between(a,b) != 0;
233
+ } // notEqual
234
+ inline static bool less(const String &a,const char (&b)[M])
235
+ {
236
+ return between(a,b) < 0;
237
+ } // less
238
+ inline static bool more(const String &a,const char (&b)[M])
239
+ {
240
+ return between(a,b) > 0;
241
+ } // more
242
+ inline static bool lessOrEqual(const String &a,const char (&b)[M])
243
+ {
244
+ return between(a,b) <= 0;
245
+ } // lessOrEqual
246
+ inline static bool moreOrEqual(const String &a,const char (&b)[M])
247
+ {
248
+ return between(a,b) >= 0;
249
+ } // moreOrEqual
250
+ };
251
+ template < > struct Compare<const char *,String>
252
+ {
253
+ inline static int between(const char * const &a,const String &b)
254
+ {
255
+ return -b.compareTo(a);
256
+ } // between
257
+ inline static bool equal(const char * const &a,const String &b)
258
+ {
259
+ return between(a,b) == 0;
260
+ } // equal
261
+ inline static bool notEqual(const char * const &a,const String &b)
262
+ {
263
+ return between(a,b) != 0;
264
+ } // notEqual
265
+ inline static bool less(const char * const &a,const String &b)
266
+ {
267
+ return between(a,b) < 0;
268
+ } // less
269
+ inline static bool more(const char * const &a,const String &b)
270
+ {
271
+ return between(a,b) > 0;
272
+ } // more
273
+ inline static bool lessOrEqual(const char * const &a,const String &b)
274
+ {
275
+ return between(a,b) <= 0;
276
+ } // lessOrEqual
277
+ inline static bool moreOrEqual(const char * const &a,const String &b)
278
+ {
279
+ return between(a,b) >= 0;
280
+ } // moreOrEqual
281
+ };
48
282
  template < > struct Compare<const char *,const char *>
49
283
  {
50
284
  inline static int between(const char * const &a,const char * const &b)
@@ -76,6 +310,39 @@ template < > struct Compare<const char *,const char *>
76
310
  return between(a,b) >= 0;
77
311
  } // moreOrEqual
78
312
  };
313
+ #if defined(F)
314
+ template < > struct Compare<const char *,const __FlashStringHelper *>
315
+ {
316
+ inline static int between(const char * const &a,const __FlashStringHelper * const &b)
317
+ {
318
+ return strcmp_P(a,(const char *)b);
319
+ } // between
320
+ inline static bool equal(const char * const &a,const __FlashStringHelper * const &b)
321
+ {
322
+ return between(a,b) == 0;
323
+ } // equal
324
+ inline static bool notEqual(const char * const &a,const __FlashStringHelper * const &b)
325
+ {
326
+ return between(a,b) != 0;
327
+ } // notEqual
328
+ inline static bool less(const char * const &a,const __FlashStringHelper * const &b)
329
+ {
330
+ return between(a,b) < 0;
331
+ } // less
332
+ inline static bool more(const char * const &a,const __FlashStringHelper * const &b)
333
+ {
334
+ return between(a,b) > 0;
335
+ } // more
336
+ inline static bool lessOrEqual(const char * const &a,const __FlashStringHelper * const &b)
337
+ {
338
+ return between(a,b) <= 0;
339
+ } // lessOrEqual
340
+ inline static bool moreOrEqual(const char * const &a,const __FlashStringHelper * const &b)
341
+ {
342
+ return between(a,b) >= 0;
343
+ } // moreOrEqual
344
+ };
345
+ #endif
79
346
  template < > struct Compare<const char *,char *>
80
347
  {
81
348
  inline static int between(const char * const &a,char * const &b)
@@ -107,7 +374,7 @@ template < > struct Compare<const char *,char *>
107
374
  return between(a,b) >= 0;
108
375
  } // moreOrEqual
109
376
  };
110
- template < long M > struct Compare<const char *,char [M]>
377
+ template < size_t M > struct Compare<const char *,char [M]>
111
378
  {
112
379
  inline static int between(const char * const &a,const char (&b)[M])
113
380
  {
@@ -138,6 +405,215 @@ template < long M > struct Compare<const char *,char [M]>
138
405
  return between(a,b) >= 0;
139
406
  } // moreOrEqual
140
407
  };
408
+ #if defined(F)
409
+ template < > struct Compare<const __FlashStringHelper *,String>
410
+ {
411
+ inline static int between(const __FlashStringHelper * const &a,const String &b)
412
+ {
413
+ return -Compare < String,const __FlashStringHelper * >::between(b,a);
414
+ } // between
415
+ inline static bool equal(const __FlashStringHelper * const &a,const String &b)
416
+ {
417
+ return between(a,b) == 0;
418
+ } // equal
419
+ inline static bool notEqual(const __FlashStringHelper * const &a,const String &b)
420
+ {
421
+ return between(a,b) != 0;
422
+ } // notEqual
423
+ inline static bool less(const __FlashStringHelper * const &a,const String &b)
424
+ {
425
+ return between(a,b) < 0;
426
+ } // less
427
+ inline static bool more(const __FlashStringHelper * const &a,const String &b)
428
+ {
429
+ return between(a,b) > 0;
430
+ } // more
431
+ inline static bool lessOrEqual(const __FlashStringHelper * const &a,const String &b)
432
+ {
433
+ return between(a,b) <= 0;
434
+ } // lessOrEqual
435
+ inline static bool moreOrEqual(const __FlashStringHelper * const &a,const String &b)
436
+ {
437
+ return between(a,b) >= 0;
438
+ } // moreOrEqual
439
+ };
440
+ #endif
441
+ #if defined(F)
442
+ template < > struct Compare<const __FlashStringHelper *,const char *>
443
+ {
444
+ inline static int between(const __FlashStringHelper * const &a,const char * const &b)
445
+ {
446
+ return -strcmp_P(b,(const char *)a);
447
+ } // between
448
+ inline static bool equal(const __FlashStringHelper * const &a,const char * const &b)
449
+ {
450
+ return between(a,b) == 0;
451
+ } // equal
452
+ inline static bool notEqual(const __FlashStringHelper * const &a,const char * const &b)
453
+ {
454
+ return between(a,b) != 0;
455
+ } // notEqual
456
+ inline static bool less(const __FlashStringHelper * const &a,const char * const &b)
457
+ {
458
+ return between(a,b) < 0;
459
+ } // less
460
+ inline static bool more(const __FlashStringHelper * const &a,const char * const &b)
461
+ {
462
+ return between(a,b) > 0;
463
+ } // more
464
+ inline static bool lessOrEqual(const __FlashStringHelper * const &a,const char * const &b)
465
+ {
466
+ return between(a,b) <= 0;
467
+ } // lessOrEqual
468
+ inline static bool moreOrEqual(const __FlashStringHelper * const &a,const char * const &b)
469
+ {
470
+ return between(a,b) >= 0;
471
+ } // moreOrEqual
472
+ };
473
+ #endif
474
+ #if defined(F)
475
+ template < > struct Compare<const __FlashStringHelper *,const __FlashStringHelper *>
476
+ {
477
+ inline static int between(const __FlashStringHelper * const &a,const __FlashStringHelper * const &b)
478
+ {
479
+ uint8_t a_buf[4],b_buf[4];
480
+ uint16_t i=0;
481
+
482
+ for (;;) {
483
+ uint8_t j=(i%4);
484
+ if (j == 0) {
485
+ memcpy_P(a_buf,((const char *)a)+i,4);
486
+ memcpy_P(b_buf,((const char *)b)+i,4);
487
+ }
488
+ if (a_buf[j] < b_buf[j]) return -1;
489
+ if (a_buf[j] > b_buf[j]) return 1;
490
+ if (a_buf[j] == 0) return 0;
491
+ ++i;
492
+ }
493
+ } // between
494
+ inline static bool equal(const __FlashStringHelper * const &a,const __FlashStringHelper * const &b)
495
+ {
496
+ return between(a,b) == 0;
497
+ } // equal
498
+ inline static bool notEqual(const __FlashStringHelper * const &a,const __FlashStringHelper * const &b)
499
+ {
500
+ return between(a,b) != 0;
501
+ } // notEqual
502
+ inline static bool less(const __FlashStringHelper * const &a,const __FlashStringHelper * const &b)
503
+ {
504
+ return between(a,b) < 0;
505
+ } // less
506
+ inline static bool more(const __FlashStringHelper * const &a,const __FlashStringHelper * const &b)
507
+ {
508
+ return between(a,b) > 0;
509
+ } // more
510
+ inline static bool lessOrEqual(const __FlashStringHelper * const &a,const __FlashStringHelper * const &b)
511
+ {
512
+ return between(a,b) <= 0;
513
+ } // lessOrEqual
514
+ inline static bool moreOrEqual(const __FlashStringHelper * const &a,const __FlashStringHelper * const &b)
515
+ {
516
+ return between(a,b) >= 0;
517
+ } // moreOrEqual
518
+ };
519
+ #endif
520
+ #if defined(F)
521
+ template < > struct Compare<const __FlashStringHelper *,char *>
522
+ {
523
+ inline static int between(const __FlashStringHelper * const &a,char * const &b)
524
+ {
525
+ return -strcmp_P(b,(const char *)a);
526
+ } // between
527
+ inline static bool equal(const __FlashStringHelper * const &a,char * const &b)
528
+ {
529
+ return between(a,b) == 0;
530
+ } // equal
531
+ inline static bool notEqual(const __FlashStringHelper * const &a,char * const &b)
532
+ {
533
+ return between(a,b) != 0;
534
+ } // notEqual
535
+ inline static bool less(const __FlashStringHelper * const &a,char * const &b)
536
+ {
537
+ return between(a,b) < 0;
538
+ } // less
539
+ inline static bool more(const __FlashStringHelper * const &a,char * const &b)
540
+ {
541
+ return between(a,b) > 0;
542
+ } // more
543
+ inline static bool lessOrEqual(const __FlashStringHelper * const &a,char * const &b)
544
+ {
545
+ return between(a,b) <= 0;
546
+ } // lessOrEqual
547
+ inline static bool moreOrEqual(const __FlashStringHelper * const &a,char * const &b)
548
+ {
549
+ return between(a,b) >= 0;
550
+ } // moreOrEqual
551
+ };
552
+ #endif
553
+ #if defined(F)
554
+ template < size_t M > struct Compare<const __FlashStringHelper *,char [M]>
555
+ {
556
+ inline static int between(const __FlashStringHelper * const &a,const char (&b)[M])
557
+ {
558
+ return -strcmp_P(b,(const char *)a);
559
+ } // between
560
+ inline static bool equal(const __FlashStringHelper * const &a,const char (&b)[M])
561
+ {
562
+ return between(a,b) == 0;
563
+ } // equal
564
+ inline static bool notEqual(const __FlashStringHelper * const &a,const char (&b)[M])
565
+ {
566
+ return between(a,b) != 0;
567
+ } // notEqual
568
+ inline static bool less(const __FlashStringHelper * const &a,const char (&b)[M])
569
+ {
570
+ return between(a,b) < 0;
571
+ } // less
572
+ inline static bool more(const __FlashStringHelper * const &a,const char (&b)[M])
573
+ {
574
+ return between(a,b) > 0;
575
+ } // more
576
+ inline static bool lessOrEqual(const __FlashStringHelper * const &a,const char (&b)[M])
577
+ {
578
+ return between(a,b) <= 0;
579
+ } // lessOrEqual
580
+ inline static bool moreOrEqual(const __FlashStringHelper * const &a,const char (&b)[M])
581
+ {
582
+ return between(a,b) >= 0;
583
+ } // moreOrEqual
584
+ };
585
+ #endif
586
+ template < > struct Compare<char *,String>
587
+ {
588
+ inline static int between(char * const &a,const String &b)
589
+ {
590
+ return -b.compareTo(a);
591
+ } // between
592
+ inline static bool equal(char * const &a,const String &b)
593
+ {
594
+ return between(a,b) == 0;
595
+ } // equal
596
+ inline static bool notEqual(char * const &a,const String &b)
597
+ {
598
+ return between(a,b) != 0;
599
+ } // notEqual
600
+ inline static bool less(char * const &a,const String &b)
601
+ {
602
+ return between(a,b) < 0;
603
+ } // less
604
+ inline static bool more(char * const &a,const String &b)
605
+ {
606
+ return between(a,b) > 0;
607
+ } // more
608
+ inline static bool lessOrEqual(char * const &a,const String &b)
609
+ {
610
+ return between(a,b) <= 0;
611
+ } // lessOrEqual
612
+ inline static bool moreOrEqual(char * const &a,const String &b)
613
+ {
614
+ return between(a,b) >= 0;
615
+ } // moreOrEqual
616
+ };
141
617
  template < > struct Compare<char *,const char *>
142
618
  {
143
619
  inline static int between(char * const &a,const char * const &b)
@@ -169,255 +645,258 @@ template < > struct Compare<char *,const char *>
169
645
  return between(a,b) >= 0;
170
646
  } // moreOrEqual
171
647
  };
172
- template < > struct Compare<char *,char *>
648
+ #if defined(F)
649
+ template < > struct Compare<char *,const __FlashStringHelper *>
173
650
  {
174
- inline static int between(char * const &a,char * const &b)
651
+ inline static int between(char * const &a,const __FlashStringHelper * const &b)
175
652
  {
176
- return strcmp(a,b);
653
+ return strcmp_P(a,(const char *)b);
177
654
  } // between
178
- inline static bool equal(char * const &a,char * const &b)
655
+ inline static bool equal(char * const &a,const __FlashStringHelper * const &b)
179
656
  {
180
657
  return between(a,b) == 0;
181
658
  } // equal
182
- inline static bool notEqual(char * const &a,char * const &b)
659
+ inline static bool notEqual(char * const &a,const __FlashStringHelper * const &b)
183
660
  {
184
661
  return between(a,b) != 0;
185
662
  } // notEqual
186
- inline static bool less(char * const &a,char * const &b)
663
+ inline static bool less(char * const &a,const __FlashStringHelper * const &b)
187
664
  {
188
665
  return between(a,b) < 0;
189
666
  } // less
190
- inline static bool more(char * const &a,char * const &b)
667
+ inline static bool more(char * const &a,const __FlashStringHelper * const &b)
191
668
  {
192
669
  return between(a,b) > 0;
193
670
  } // more
194
- inline static bool lessOrEqual(char * const &a,char * const &b)
671
+ inline static bool lessOrEqual(char * const &a,const __FlashStringHelper * const &b)
195
672
  {
196
673
  return between(a,b) <= 0;
197
674
  } // lessOrEqual
198
- inline static bool moreOrEqual(char * const &a,char * const &b)
675
+ inline static bool moreOrEqual(char * const &a,const __FlashStringHelper * const &b)
199
676
  {
200
677
  return between(a,b) >= 0;
201
678
  } // moreOrEqual
202
679
  };
203
- template < long M > struct Compare<char *,char [M]>
680
+ #endif
681
+ template < > struct Compare<char *,char *>
204
682
  {
205
- inline static int between(char * const &a,const char (&b)[M])
683
+ inline static int between(char * const &a,char * const &b)
206
684
  {
207
685
  return strcmp(a,b);
208
686
  } // between
209
- inline static bool equal(char * const &a,const char (&b)[M])
687
+ inline static bool equal(char * const &a,char * const &b)
210
688
  {
211
689
  return between(a,b) == 0;
212
690
  } // equal
213
- inline static bool notEqual(char * const &a,const char (&b)[M])
691
+ inline static bool notEqual(char * const &a,char * const &b)
214
692
  {
215
693
  return between(a,b) != 0;
216
694
  } // notEqual
217
- inline static bool less(char * const &a,const char (&b)[M])
695
+ inline static bool less(char * const &a,char * const &b)
218
696
  {
219
697
  return between(a,b) < 0;
220
698
  } // less
221
- inline static bool more(char * const &a,const char (&b)[M])
699
+ inline static bool more(char * const &a,char * const &b)
222
700
  {
223
701
  return between(a,b) > 0;
224
702
  } // more
225
- inline static bool lessOrEqual(char * const &a,const char (&b)[M])
703
+ inline static bool lessOrEqual(char * const &a,char * const &b)
226
704
  {
227
705
  return between(a,b) <= 0;
228
706
  } // lessOrEqual
229
- inline static bool moreOrEqual(char * const &a,const char (&b)[M])
707
+ inline static bool moreOrEqual(char * const &a,char * const &b)
230
708
  {
231
709
  return between(a,b) >= 0;
232
710
  } // moreOrEqual
233
711
  };
234
- template < long N > struct Compare<char [N],const char *>
712
+ template < size_t M > struct Compare<char *,char [M]>
235
713
  {
236
- inline static int between(const char (&a)[N],const char * const &b)
714
+ inline static int between(char * const &a,const char (&b)[M])
237
715
  {
238
716
  return strcmp(a,b);
239
717
  } // between
240
- inline static bool equal(const char (&a)[N],const char * const &b)
718
+ inline static bool equal(char * const &a,const char (&b)[M])
241
719
  {
242
720
  return between(a,b) == 0;
243
721
  } // equal
244
- inline static bool notEqual(const char (&a)[N],const char * const &b)
722
+ inline static bool notEqual(char * const &a,const char (&b)[M])
245
723
  {
246
724
  return between(a,b) != 0;
247
725
  } // notEqual
248
- inline static bool less(const char (&a)[N],const char * const &b)
726
+ inline static bool less(char * const &a,const char (&b)[M])
249
727
  {
250
728
  return between(a,b) < 0;
251
729
  } // less
252
- inline static bool more(const char (&a)[N],const char * const &b)
730
+ inline static bool more(char * const &a,const char (&b)[M])
253
731
  {
254
732
  return between(a,b) > 0;
255
733
  } // more
256
- inline static bool lessOrEqual(const char (&a)[N],const char * const &b)
734
+ inline static bool lessOrEqual(char * const &a,const char (&b)[M])
257
735
  {
258
736
  return between(a,b) <= 0;
259
737
  } // lessOrEqual
260
- inline static bool moreOrEqual(const char (&a)[N],const char * const &b)
738
+ inline static bool moreOrEqual(char * const &a,const char (&b)[M])
261
739
  {
262
740
  return between(a,b) >= 0;
263
741
  } // moreOrEqual
264
742
  };
265
- template < long N > struct Compare<char [N],char *>
743
+ template < size_t N > struct Compare<char [N],String>
266
744
  {
267
- inline static int between(const char (&a)[N],char * const &b)
745
+ inline static int between(const char (&a)[N],const String &b)
268
746
  {
269
- return strcmp(a,b);
747
+ return -b.compareTo(a);
270
748
  } // between
271
- inline static bool equal(const char (&a)[N],char * const &b)
749
+ inline static bool equal(const char (&a)[N],const String &b)
272
750
  {
273
751
  return between(a,b) == 0;
274
752
  } // equal
275
- inline static bool notEqual(const char (&a)[N],char * const &b)
753
+ inline static bool notEqual(const char (&a)[N],const String &b)
276
754
  {
277
755
  return between(a,b) != 0;
278
756
  } // notEqual
279
- inline static bool less(const char (&a)[N],char * const &b)
757
+ inline static bool less(const char (&a)[N],const String &b)
280
758
  {
281
759
  return between(a,b) < 0;
282
760
  } // less
283
- inline static bool more(const char (&a)[N],char * const &b)
761
+ inline static bool more(const char (&a)[N],const String &b)
284
762
  {
285
763
  return between(a,b) > 0;
286
764
  } // more
287
- inline static bool lessOrEqual(const char (&a)[N],char * const &b)
765
+ inline static bool lessOrEqual(const char (&a)[N],const String &b)
288
766
  {
289
767
  return between(a,b) <= 0;
290
768
  } // lessOrEqual
291
- inline static bool moreOrEqual(const char (&a)[N],char * const &b)
769
+ inline static bool moreOrEqual(const char (&a)[N],const String &b)
292
770
  {
293
771
  return between(a,b) >= 0;
294
772
  } // moreOrEqual
295
773
  };
296
- template < long N, long M > struct Compare<char [N],char [M]>
774
+ template < size_t N > struct Compare<char [N],const char *>
297
775
  {
298
- inline static int between(const char (&a)[N],const char (&b)[M])
776
+ inline static int between(const char (&a)[N],const char * const &b)
299
777
  {
300
778
  return strcmp(a,b);
301
779
  } // between
302
- inline static bool equal(const char (&a)[N],const char (&b)[M])
780
+ inline static bool equal(const char (&a)[N],const char * const &b)
303
781
  {
304
782
  return between(a,b) == 0;
305
783
  } // equal
306
- inline static bool notEqual(const char (&a)[N],const char (&b)[M])
784
+ inline static bool notEqual(const char (&a)[N],const char * const &b)
307
785
  {
308
786
  return between(a,b) != 0;
309
787
  } // notEqual
310
- inline static bool less(const char (&a)[N],const char (&b)[M])
788
+ inline static bool less(const char (&a)[N],const char * const &b)
311
789
  {
312
790
  return between(a,b) < 0;
313
791
  } // less
314
- inline static bool more(const char (&a)[N],const char (&b)[M])
792
+ inline static bool more(const char (&a)[N],const char * const &b)
315
793
  {
316
794
  return between(a,b) > 0;
317
795
  } // more
318
- inline static bool lessOrEqual(const char (&a)[N],const char (&b)[M])
796
+ inline static bool lessOrEqual(const char (&a)[N],const char * const &b)
319
797
  {
320
798
  return between(a,b) <= 0;
321
799
  } // lessOrEqual
322
- inline static bool moreOrEqual(const char (&a)[N],const char (&b)[M])
800
+ inline static bool moreOrEqual(const char (&a)[N],const char * const &b)
323
801
  {
324
802
  return between(a,b) >= 0;
325
803
  } // moreOrEqual
326
804
  };
327
- template < > struct Compare<bool, bool>
805
+ #if defined(F)
806
+ template < size_t N > struct Compare<char [N],const __FlashStringHelper *>
328
807
  {
329
- inline static int between(bool a, bool b)
808
+ inline static int between(const char (&a)[N],const __FlashStringHelper * const &b)
330
809
  {
331
- return b ? (a ? 0 : -1) : (a ? 1 : 0);
810
+ return strcmp_P(a,(const char *)b);
332
811
  } // between
333
- inline static bool equal(bool a, bool b)
812
+ inline static bool equal(const char (&a)[N],const __FlashStringHelper * const &b)
334
813
  {
335
814
  return between(a,b) == 0;
336
815
  } // equal
337
- inline static bool notEqual(bool a, bool b)
816
+ inline static bool notEqual(const char (&a)[N],const __FlashStringHelper * const &b)
338
817
  {
339
818
  return between(a,b) != 0;
340
819
  } // notEqual
341
- inline static bool less(bool a, bool b)
820
+ inline static bool less(const char (&a)[N],const __FlashStringHelper * const &b)
342
821
  {
343
822
  return between(a,b) < 0;
344
823
  } // less
345
- inline static bool more(bool a, bool b)
824
+ inline static bool more(const char (&a)[N],const __FlashStringHelper * const &b)
346
825
  {
347
826
  return between(a,b) > 0;
348
827
  } // more
349
- inline static bool lessOrEqual(bool a, bool b)
828
+ inline static bool lessOrEqual(const char (&a)[N],const __FlashStringHelper * const &b)
350
829
  {
351
830
  return between(a,b) <= 0;
352
831
  } // lessOrEqual
353
- inline static bool moreOrEqual(bool a, bool b)
832
+ inline static bool moreOrEqual(const char (&a)[N],const __FlashStringHelper * const &b)
354
833
  {
355
834
  return between(a,b) >= 0;
356
835
  } // moreOrEqual
357
836
  };
358
- template <typename T> struct Compare<bool, T>
837
+ #endif
838
+ template < size_t N > struct Compare<char [N],char *>
359
839
  {
360
- inline static int between(bool a, T b)
840
+ inline static int between(const char (&a)[N],char * const &b)
361
841
  {
362
- return b ? (a ? 0 : -1) : (a ? 1 : 0);
842
+ return strcmp(a,b);
363
843
  } // between
364
- inline static bool equal(bool a, T b)
844
+ inline static bool equal(const char (&a)[N],char * const &b)
365
845
  {
366
846
  return between(a,b) == 0;
367
847
  } // equal
368
- inline static bool notEqual(bool a, T b)
848
+ inline static bool notEqual(const char (&a)[N],char * const &b)
369
849
  {
370
850
  return between(a,b) != 0;
371
851
  } // notEqual
372
- inline static bool less(bool a, T b)
852
+ inline static bool less(const char (&a)[N],char * const &b)
373
853
  {
374
854
  return between(a,b) < 0;
375
855
  } // less
376
- inline static bool more(bool a, T b)
856
+ inline static bool more(const char (&a)[N],char * const &b)
377
857
  {
378
858
  return between(a,b) > 0;
379
859
  } // more
380
- inline static bool lessOrEqual(bool a, T b)
860
+ inline static bool lessOrEqual(const char (&a)[N],char * const &b)
381
861
  {
382
862
  return between(a,b) <= 0;
383
863
  } // lessOrEqual
384
- inline static bool moreOrEqual(bool a, T b)
864
+ inline static bool moreOrEqual(const char (&a)[N],char * const &b)
385
865
  {
386
866
  return between(a,b) >= 0;
387
867
  } // moreOrEqual
388
868
  };
389
- template <typename T> struct Compare<T, bool>
869
+ template < size_t N, size_t M > struct Compare<char [N],char [M]>
390
870
  {
391
- inline static int between(T a, bool b)
871
+ inline static int between(const char (&a)[N],const char (&b)[M])
392
872
  {
393
- return b ? (a ? 0 : -1) : (a ? 1 : 0);
873
+ return strcmp(a,b);
394
874
  } // between
395
- inline static bool equal(T a, bool b)
875
+ inline static bool equal(const char (&a)[N],const char (&b)[M])
396
876
  {
397
877
  return between(a,b) == 0;
398
878
  } // equal
399
- inline static bool notEqual(T a, bool b)
879
+ inline static bool notEqual(const char (&a)[N],const char (&b)[M])
400
880
  {
401
881
  return between(a,b) != 0;
402
882
  } // notEqual
403
- inline static bool less(T a, bool b)
883
+ inline static bool less(const char (&a)[N],const char (&b)[M])
404
884
  {
405
885
  return between(a,b) < 0;
406
886
  } // less
407
- inline static bool more(T a, bool b)
887
+ inline static bool more(const char (&a)[N],const char (&b)[M])
408
888
  {
409
889
  return between(a,b) > 0;
410
890
  } // more
411
- inline static bool lessOrEqual(T a, bool b)
891
+ inline static bool lessOrEqual(const char (&a)[N],const char (&b)[M])
412
892
  {
413
893
  return between(a,b) <= 0;
414
894
  } // lessOrEqual
415
- inline static bool moreOrEqual(T a, bool b)
895
+ inline static bool moreOrEqual(const char (&a)[N],const char (&b)[M])
416
896
  {
417
897
  return between(a,b) >= 0;
418
898
  } // moreOrEqual
419
899
  };
420
-
421
900
  template <typename A, typename B> int compareBetween(const A &a, const B &b) { return Compare<A,B>::between(a,b); }
422
901
  template <typename A, typename B> bool compareEqual(const A &a, const B &b) { return Compare<A,B>::equal(a,b); }
423
902
  template <typename A, typename B> bool compareNotEqual(const A &a, const B &b) { return Compare<A,B>::notEqual(a,b); }