#ifndef INCLUDED_CSTRING #define INCLUDED_CSTRING #include struct case_insensitive_traits { typedef char char_type; typedef int int_type; static void assign(char_type& lhs, const char_type& rhs) {lhs = rhs; } static bool eq(const char_type& lhs, const char_type& rhs) {return (toupper(lhs) == toupper(rhs)); } static bool lt(const char_type& lhs, const char_type& rhs) {return (toupper(lhs) < toupper(rhs)); } static int compare(const char_type *lhs, const char_type *rhs, size_t len) {while (len > 0) {int U=toupper(*lhs), V=toupper(*rhs); if (UV) return 1; ++lhs; ++rhs; len--;} return 0;} static size_t length(const char_type *src) {return (strlen(src)); } static char_type * copy(char_type *dst, const char_type *src, size_t len) {return ((char_type *)memcpy(dst, src, len)); } static const char_type * find(const char_type *src, size_t len, const char_type& tgt) {int C = toupper(tgt); while (len > 0) {int U=toupper(*src); if (U==C) return src; ++src; len--;} return NULL;} static char_type * move(char_type *dst, const char_type *src, size_t len) {return ((char_type *)memmove(dst, src, len)); } static char_type * assign(char_type *dst, size_t len, const char_type& tgt) {return ((char_type *)memset(dst, tgt, len)); } static char_type to_char_type(const int_type& src) {return ((char_type)src); } static int_type to_int_type(const char_type& src) {return ((int_type)((unsigned char)src)); } static bool eq_int_type(const int_type& lhs, const int_type& rhs) {return (lhs == rhs); } static int_type eof() {return (EOF); } static int_type not_eof(const int_type& src) {return (src != eof() ? src : !eof()); } }; typedef std::basic_string BaseCString; class CString : public BaseCString { public: // Constructors CString() : std::basic_string() {} CString(const char* src) : std::basic_string(src) {} CString(const CString& src) : std::basic_string(src) {} // Conversion to std::string for use in ostream operator const std::string() const {return std::string(c_str());} // operator equal for map bool is_valid() const {return true;} }; #endif