#include <config.h>
#include <algorithm>
+
+#ifdef __GLIBCPP__
+#include <ctype.h>
+#else
#include <cctype>
-#include <cstdio>
+#endif
#include <cstdlib>
#include "LString.h"
using std::count;
using std::transform;
+using std::tolower;
+using std::toupper;
int compare_no_case(string const & s, string const & s2)
{
return 1;
}
+
int compare_no_case(string const & s, string const & s2, unsigned int len)
{
//#warning verify this func please
return 1;
}
+
bool isStrInt(string const & str)
{
if (str.empty()) return false;
string lowercase(string const & a)
{
-#if 0
- string tmp;
- string::const_iterator cit = a.begin();
- for(; cit != a.end(); ++cit) {
- tmp += static_cast<char>(tolower(*cit));
- }
- return tmp;
-#endif
string tmp(a);
- transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
+//#ifdef __GLIBCPP__
+ string::iterator result = tmp.begin();
+ for (string::iterator first = tmp.begin();
+ first != tmp.end(); ++first, ++result) {
+ *result = tolower(*first);
+ }
+//#else
+// transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
+//#endif
return tmp;
}
string uppercase(string const & a)
{
string tmp(a);
- transform(tmp.begin(), tmp.end(), tmp.begin(), toupper);
+//#ifdef __GLIBCPP__
+ string::iterator result = tmp.begin();
+ for (string::iterator first = tmp.begin();
+ first != tmp.end(); ++first, ++result) {
+ *result = toupper(*first);
+ }
+//#else
+// transform(tmp.begin(), tmp.end(), tmp.begin(), toupper);
+//#endif
return tmp;
}
-string tostr(long i)
-{
- // should use string stream
- char str[30];
- sprintf(str, "%ld", i);
- return string(str);
-}
-
-
-string tostr(unsigned long i)
-{
- // should use string stream
- char str[30];
- sprintf(str, "%lu", i);
- return string(str);
-}
-
-
-string tostr(void * v)
-{
- return tostr(long(v));
-}
-
-
-string tostr(int i)
-{
- return tostr(long(i));
-}
-
-
-string tostr(unsigned int ui)
-{
- return tostr(long(ui));
-}
-
-
-string tostr(char c)
-{
- return string(1, c);
-}
-
-
-string tostr(bool b)
-{
- return b ? "true" : "false";
-}
-
-
-#if 0
-string tostr(float f)
-{
- return tostr(double(f));
-}
-#endif
-
-
-string tostr(double d)
-{
- // should use string stream
- char tmp[40];
- sprintf(tmp, "%f", d);
- return string(tmp);
-}
-
-
bool prefixIs(string const & a, char const * pre)
{
unsigned int l = strlen(pre);
}
-int countChar(string const & a, char const c)
+unsigned int countChar(string const & a, char const c)
{
+#ifdef HAVE_STD_COUNT
return count(a.begin(), a.end(), c);
+#else
+ unsigned int n = 0;
+ count(a.begin(), a.end(), c, n);
+ return n;
+#endif
}