00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef Tanl_Text_strings_H
00025 #define Tanl_Text_strings_H
00026
00027
00028 #include "include/config.h"
00029
00030
00031 #include <cctype>
00032 #include <cstring>
00033 #include <string>
00034 #include <functional>
00035
00036 #include "text/text.h"
00037
00038 #ifndef __GNUC__
00039
00042 char* strndup(char const* s, int len);
00043 #endif
00044
00045 namespace Tanl {
00046 namespace Text {
00047
00048
00052
00053
00054 extern void itoa(long, char*);
00055
00056
00057 inline char to_lower(char c) { return (char)tolower(c); }
00058 extern char* to_lower(char*);
00059 extern std::string& to_lower(std::string&);
00060 extern void to_lower(register char* d, register char const* s);
00061
00062 inline char to_upper(char c) { return (char)toupper(c); }
00063 extern char* to_upper(char*);
00064 extern std::string& to_upper(std::string&);
00065 extern void to_upper(register char* d, register char const* s);
00066
00067 char const* next_token(char const*& start, char const* end,
00068 const char* sep);
00069 char const* next_token(char const*& start, const char* sep,
00070 char esc);
00071 char const* next_token_line(char const*& start, const char* sep,
00072 char esc = '\\');
00073
00074 std::string operator+(const std::string s, const int i);
00075 std::string operator+(const int i, const std::string s);
00076 std::string operator+(const std::string s, const unsigned i);
00077 std::string operator+(const unsigned i, const std::string s);
00078
00079 #ifndef __GNUC__
00080
00083 char* strndup(char const* s, int len);
00084 #endif
00085
00089 char* strstr(const char* haystack, const char* needle,
00090 size_t count);
00091
00092 inline int strncasecmp(const char* s1, const char* s2)
00093 {
00094 return ::strncasecmp(s1, s2, ::strlen(s2));
00095 }
00096
00101 bool strStartsWith(const char* s1, const char* init);
00102
00107 inline bool strempty(const char* s)
00108 {
00109 return !s || (s[0] == '\0');
00110 }
00111
00112 }
00113 }
00114
00115
00116 namespace std
00117 {
00118 template <>
00119 struct equal_to<char const*> :
00120 public binary_function<char const*, char const*, bool>
00121 {
00122 bool operator()(first_argument_type __x, first_argument_type __y) const {
00123 return ::strcmp(__x, __y) == 0;
00124 }
00125 };
00126 }
00127
00128 #endif