OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights | 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 public: | 69 public: |
70 // Construct a null string, distinguishable from an empty string. | 70 // Construct a null string, distinguishable from an empty string. |
71 CString() {} | 71 CString() {} |
72 | 72 |
73 // Construct a string from arbitrary bytes. | 73 // Construct a string from arbitrary bytes. |
74 CString(const char* chars) : CString(chars, chars ? strlen(chars) : 0) {} | 74 CString(const char* chars) : CString(chars, chars ? strlen(chars) : 0) {} |
75 CString(const char*, size_t length); | 75 CString(const char*, size_t length); |
76 | 76 |
77 // Construct a string referencing an existing buffer. | 77 // Construct a string referencing an existing buffer. |
78 CString(CStringImpl* buffer) : m_buffer(buffer) {} | 78 CString(CStringImpl* buffer) : m_buffer(buffer) {} |
79 CString(PassRefPtr<CStringImpl> buffer) : m_buffer(buffer) {} | 79 CString(PassRefPtr<CStringImpl> buffer) : m_buffer(std::move(buffer)) {} |
80 | 80 |
81 static CString createUninitialized(size_t length, char*& data) { | 81 static CString createUninitialized(size_t length, char*& data) { |
82 return CStringImpl::createUninitialized(length, data); | 82 return CStringImpl::createUninitialized(length, data); |
83 } | 83 } |
84 | 84 |
85 // The bytes of the string, always NUL terminated. May be null. | 85 // The bytes of the string, always NUL terminated. May be null. |
86 const char* data() const { return m_buffer ? m_buffer->data() : 0; } | 86 const char* data() const { return m_buffer ? m_buffer->data() : 0; } |
87 | 87 |
88 // The length of the data(), *not* including the NUL terminator. | 88 // The length of the data(), *not* including the NUL terminator. |
89 size_t length() const { return m_buffer ? m_buffer->length() : 0; } | 89 size_t length() const { return m_buffer ? m_buffer->length() : 0; } |
(...skipping 19 matching lines...) Expand all Loading... |
109 | 109 |
110 // Pretty printer for gtest and base/logging.*. It prepends and appends | 110 // Pretty printer for gtest and base/logging.*. It prepends and appends |
111 // double-quotes, and escapes characters other than ASCII printables. | 111 // double-quotes, and escapes characters other than ASCII printables. |
112 WTF_EXPORT std::ostream& operator<<(std::ostream&, const CString&); | 112 WTF_EXPORT std::ostream& operator<<(std::ostream&, const CString&); |
113 | 113 |
114 } // namespace WTF | 114 } // namespace WTF |
115 | 115 |
116 using WTF::CString; | 116 using WTF::CString; |
117 | 117 |
118 #endif // CString_h | 118 #endif // CString_h |
OLD | NEW |