Chromium Code Reviews| Index: core/include/fxcrt/fx_string.h |
| diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h |
| index df7dd0c76241e359af3e367c400d759a9da9c463..a4889d9b654ed14c7d09137f0cc13b08bec37ad7 100644 |
| --- a/core/include/fxcrt/fx_string.h |
| +++ b/core/include/fxcrt/fx_string.h |
| @@ -7,6 +7,8 @@ |
| #ifndef _FX_STRING_H_ |
| #define _FX_STRING_H_ |
| +#include <algorithm> |
| + |
| #include "fx_memory.h" |
| class CFX_ByteStringC; |
| @@ -21,7 +23,7 @@ class CFX_WideStringL; |
| // An immutable string with caller-provided storage which must outlive the |
| // string itself. |
| -class CFX_ByteStringC |
| +class CFX_ByteStringC |
| { |
| public: |
| typedef FX_CHAR value_type; |
| @@ -100,7 +102,6 @@ public: |
| { |
| return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) != 0; |
| } |
| -#define FXBSTR_ID(c1, c2, c3, c4) ((c1 << 24) | (c2 << 16) | (c3 << 8) | (c4)) |
|
Tom Sepez
2015/04/21 19:34:49
Moved below, just because.
|
| FX_DWORD GetID(FX_STRSIZE start_pos = 0) const; |
| @@ -124,11 +125,6 @@ public: |
| return m_Length == 0; |
| } |
| - operator FX_LPCBYTE() const |
| - { |
| - return m_Ptr; |
| - } |
| - |
| FX_BYTE GetAt(FX_STRSIZE index) const |
| { |
| return m_Ptr[index]; |
| @@ -147,6 +143,18 @@ public: |
| } |
| return CFX_ByteStringC(m_Ptr + index, count); |
| } |
| + |
| + const FX_BYTE& operator[] (int index) const |
| + { |
| + return m_Ptr[index]; |
| + } |
| + |
| + bool operator< (const CFX_ByteStringC& that) |
| + { |
| + int result = memcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length)); |
| + return result < 0 || (result == 0 && m_Length < that.m_Length); |
| + } |
| + |
| protected: |
| FX_LPCBYTE m_Ptr; |
| @@ -161,6 +169,7 @@ private: |
| }; |
| typedef const CFX_ByteStringC& FX_BSTR; |
| #define FX_BSTRC(str) CFX_ByteStringC(str, sizeof str-1) |
| +#define FXBSTR_ID(c1, c2, c3, c4) ((c1 << 24) | (c2 << 16) | (c3 << 8) | (c4)) |
| struct CFX_StringData { |
| long m_nRefs; |