]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/string.h
just a change in comment for wxUSE_MS_HTML_HELP
[wxWidgets.git] / include / wx / string.h
index 6cf19b5022d671cff06cd31e1fc885309af21541..fb73ad8757e168c6d1ffad036015bdea18a31487 100644 (file)
@@ -76,9 +76,15 @@ class WXDLLIMPEXP_BASE wxString;
 // constants
 // ----------------------------------------------------------------------------
 
+#if WXWIN_COMPATIBILITY_2_6
+
+// deprecated in favour of wxString::npos, don't use in new code
+//
 // maximum possible length for a string means "take all string" everywhere
 #define wxSTRING_MAXLEN wxStringBase::npos
 
+#endif // WXWIN_COMPATIBILITY_2_6
+
 // ----------------------------------------------------------------------------
 // global data
 // ----------------------------------------------------------------------------
@@ -299,6 +305,43 @@ public:
   typedef value_type *iterator;
   typedef const value_type *const_iterator;
 
+#define wxSTRING_REVERSE_ITERATOR(name, const_or_not)                         \
+  class name                                                                  \
+  {                                                                           \
+  public:                                                                     \
+      typedef wxChar value_type;                                              \
+      typedef const_or_not value_type& reference;                             \
+      typedef const_or_not value_type *pointer;                               \
+      typedef const_or_not value_type *iterator_type;                         \
+                                                                              \
+      name(iterator_type i) : m_cur(i) { }                                    \
+      name(const name& ri) : m_cur(ri.m_cur) { }                              \
+                                                                              \
+      iterator_type base() const { return m_cur; }                            \
+                                                                              \
+      reference operator*() const { return *(m_cur - 1); }                    \
+                                                                              \
+      name& operator++() { --m_cur; return *this; }                           \
+      name operator++(int) { name tmp = *this; --m_cur; return tmp; }         \
+      name& operator--() { ++m_cur; return *this; }                           \
+      name operator--(int) { name tmp = *this; ++m_cur; return tmp; }         \
+                                                                              \
+      bool operator==(name ri) const { return m_cur == ri.m_cur; }            \
+      bool operator!=(name ri) const { return !(*this == ri); }               \
+                                                                              \
+  private:                                                                    \
+      iterator_type m_cur;                                                    \
+  }
+
+  wxSTRING_REVERSE_ITERATOR(const_reverse_iterator, const);
+
+  #define wxSTRING_CONST
+  wxSTRING_REVERSE_ITERATOR(reverse_iterator, wxSTRING_CONST);
+  #undef wxSTRING_CONST
+
+  #undef wxSTRING_REVERSE_ITERATOR
+
+
   // constructors and destructor
     // ctor for an empty string
   wxStringBase() { Init(); }
@@ -370,7 +413,7 @@ public:
     // return the length of the string
   size_type size() const { return length(); }
     // return the maximum size of the string
-  size_type max_size() const { return wxSTRING_MAXLEN; }
+  size_type max_size() const { return npos; }
     // resize the string, filling the space with c if c != 0
   void resize(size_t nSize, wxChar ch = wxT('\0'));
     // delete the contents of the string
@@ -431,14 +474,18 @@ public:
 
     // first valid index position
   const_iterator begin() const { return m_pchData; }
+  iterator begin();
     // position one after the last valid one
   const_iterator end() const { return m_pchData + length(); }
-
-  // first valid index position
-  iterator begin();
-  // position one after the last valid one
   iterator end();
 
+    // first element of the reversed string
+  const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
+  reverse_iterator rbegin() { return reverse_iterator(end()); }
+    // one beyond the end of the reversed string
+  const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
+  reverse_iterator rend() { return reverse_iterator(begin()); }
+
     // insert another string
   wxStringBase& insert(size_t nPos, const wxStringBase& str)
   {
@@ -1015,10 +1062,14 @@ public:
   wxString  operator()(size_t start, size_t len) const
     { return Mid(start, len); }
 
-      // check that the string starts with prefix and return the rest of the
-      // string in the provided pointer if it is not NULL, otherwise return
-      // false
+      // check if the string starts with the given prefix and return the rest
+      // of the string in the provided pointer if it is not NULL; otherwise
+      // return false
   bool StartsWith(const wxChar *prefix, wxString *rest = NULL) const;
+      // check if the string ends with the given suffix and return the
+      // beginning of the string before the suffix in the provided pointer if
+      // it is not NULL; otherwise return false
+  bool EndsWith(const wxChar *suffix, wxString *rest = NULL) const;
 
       // get first nCount characters
   wxString Left(size_t nCount) const;
@@ -1081,9 +1132,17 @@ public:
     bool ToLong(long *val, int base = 10) const;
         // convert to an unsigned integer
     bool ToULong(unsigned long *val, int base = 10) const;
+        // convert to wxLongLong
+#if defined(wxLongLong_t)
+    bool ToLongLong(wxLongLong_t *val, int base = 10) const;
+        // convert to wxULongLong
+    bool ToULongLong(wxULongLong_t *val, int base = 10) const;
+#endif // wxLongLong_t
         // convert to a double
     bool ToDouble(double *val) const;
 
+
+
   // formatted input/output
     // as sprintf(), returns the number of characters written or < 0 on error
     // (take 'this' into account in attribute parameter count)
@@ -1533,7 +1592,6 @@ inline bool operator!=(const wxString& s, wxChar c) { return !s.IsSameAs(c); }
 
 #include "wx/iosfwrap.h"
 
-WXDLLIMPEXP_BASE wxSTD istream& operator>>(wxSTD istream&, wxString&);
 WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxString&);
 
 #endif  // wxSTD_STRING_COMPATIBILITY