Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_caseless_str_h)
00024 #define octave_caseless_str_h 1
00025
00026 #include <string>
00027
00028 class caseless_str : public std::string
00029 {
00030 public:
00031
00032 typedef std::string::iterator iterator;
00033 typedef std::string::const_iterator const_iterator;
00034
00035 caseless_str (void) : std::string () { }
00036 caseless_str (const std::string& s) : std::string (s) { }
00037 caseless_str (const char *s) : std::string (s) { }
00038
00039 caseless_str (const caseless_str& name) : std::string (name) { }
00040
00041 caseless_str& operator = (const caseless_str& pname)
00042 {
00043 std::string::operator = (pname);
00044 return *this;
00045 }
00046
00047 operator std::string (void) const { return *this; }
00048
00049
00050 bool compare (const std::string& s, size_t limit = std::string::npos) const
00051 {
00052 const_iterator p1 = begin ();
00053 const_iterator p2 = s.begin ();
00054
00055 size_t k = 0;
00056
00057 while (p1 != end () && p2 != s.end () && k++ < limit)
00058 {
00059 if (std::tolower (*p1) != std::tolower (*p2))
00060 return false;
00061
00062 *p1++;
00063 *p2++;
00064 }
00065
00066 return (limit == std::string::npos) ? size () == s.size () : k == limit;
00067 }
00068 };
00069
00070 #endif