| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserv
ed. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 CString() { } | 61 CString() { } |
| 62 CString(const char*); | 62 CString(const char*); |
| 63 CString(const char*, size_t length); | 63 CString(const char*, size_t length); |
| 64 CString(CStringBuffer* buffer) : m_buffer(buffer) { } | 64 CString(CStringBuffer* buffer) : m_buffer(buffer) { } |
| 65 static CString newUninitialized(size_t length, char*& characterBuffer); | 65 static CString newUninitialized(size_t length, char*& characterBuffer); |
| 66 | 66 |
| 67 const char* data() const | 67 const char* data() const |
| 68 { | 68 { |
| 69 return m_buffer ? m_buffer->data() : 0; | 69 return m_buffer ? m_buffer->data() : 0; |
| 70 } | 70 } |
| 71 |
| 72 const operator const char*() const { return data(); } |
| 73 |
| 71 char* mutableData(); | 74 char* mutableData(); |
| 72 size_t length() const | 75 size_t length() const |
| 73 { | 76 { |
| 74 return m_buffer ? m_buffer->length() : 0; | 77 return m_buffer ? m_buffer->length() : 0; |
| 75 } | 78 } |
| 76 | 79 |
| 77 bool isNull() const { return !m_buffer; } | 80 bool isNull() const { return !m_buffer; } |
| 78 bool isSafeToSendToAnotherThread() const; | 81 bool isSafeToSendToAnotherThread() const; |
| 79 | 82 |
| 80 CStringBuffer* buffer() const { return m_buffer.get(); } | 83 CStringBuffer* buffer() const { return m_buffer.get(); } |
| 81 | 84 |
| 82 private: | 85 private: |
| 83 void copyBufferIfNeeded(); | 86 void copyBufferIfNeeded(); |
| 84 void init(const char*, size_t length); | 87 void init(const char*, size_t length); |
| 85 RefPtr<CStringBuffer> m_buffer; | 88 RefPtr<CStringBuffer> m_buffer; |
| 86 }; | 89 }; |
| 87 | 90 |
| 88 WTF_EXPORT bool operator==(const CString& a, const CString& b); | 91 WTF_EXPORT bool operator==(const CString& a, const CString& b); |
| 89 inline bool operator!=(const CString& a, const CString& b) { return !(a == b); } | 92 inline bool operator!=(const CString& a, const CString& b) { return !(a == b); } |
| 90 WTF_EXPORT bool operator==(const CString& a, const char* b); | 93 WTF_EXPORT bool operator==(const CString& a, const char* b); |
| 91 inline bool operator!=(const CString& a, const char* b) { return !(a == b); } | 94 inline bool operator!=(const CString& a, const char* b) { return !(a == b); } |
| 92 | 95 |
| 93 } // namespace WTF | 96 } // namespace WTF |
| 94 | 97 |
| 95 using WTF::CString; | 98 using WTF::CString; |
| 96 | 99 |
| 97 #endif // CString_h | 100 #endif // CString_h |
| OLD | NEW |