Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: Source/wtf/text/CString.h

Issue 15861022: Build WTF as dll in component build (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix AutoDrainedPool ctor and ThreadSpecificThreadExit exports Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/text/Base64.h ('k') | Source/wtf/text/StringBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef CString_h 26 #ifndef CString_h
27 #define CString_h 27 #define CString_h
28 28
29 #include <wtf/PassRefPtr.h> 29 #include "wtf/PassRefPtr.h"
30 #include <wtf/RefCounted.h> 30 #include "wtf/RefCounted.h"
31 #include <wtf/Vector.h> 31 #include "wtf/Vector.h"
32 #include "wtf/WTFExport.h"
32 33
33 namespace WTF { 34 namespace WTF {
34 35
35 // CStringBuffer is the ref-counted storage class for the characters in a CStrin g. 36 // CStringBuffer is the ref-counted storage class for the characters in a CStrin g.
36 // The data is implicitly allocated 1 character longer than length(), as it is z ero-terminated. 37 // The data is implicitly allocated 1 character longer than length(), as it is z ero-terminated.
37 class CStringBuffer : public RefCounted<CStringBuffer> { 38 class CStringBuffer : public RefCounted<CStringBuffer> {
38 // This is needed because we malloc() space for a CStringBuffer plus an 39 // This is needed because we malloc() space for a CStringBuffer plus an
39 // immediately following buffer, as a performance tweak. 40 // immediately following buffer, as a performance tweak.
40 NEW_DELETE_SAME_AS_MALLOC_FREE; 41 NEW_DELETE_SAME_AS_MALLOC_FREE;
41 public: 42 public:
42 const char* data() { return m_data; } 43 const char* data() { return m_data; }
43 size_t length() const { return m_length; } 44 size_t length() const { return m_length; }
44 45
45 private: 46 private:
46 friend class CString; 47 friend class CString;
47 48
48 static PassRefPtr<CStringBuffer> createUninitialized(size_t length); 49 static PassRefPtr<CStringBuffer> createUninitialized(size_t length);
49 50
50 CStringBuffer(size_t length) : m_length(length) { } 51 CStringBuffer(size_t length) : m_length(length) { }
51 char* mutableData() { return m_data; } 52 char* mutableData() { return m_data; }
52 53
53 const unsigned m_length; 54 const unsigned m_length;
54 char m_data[1]; 55 char m_data[1];
55 }; 56 };
56 57
57 // A container for a null-terminated char array supporting copy-on-write 58 // A container for a null-terminated char array supporting copy-on-write
58 // assignment. The contained char array may be null. 59 // assignment. The contained char array may be null.
59 class CString { 60 class WTF_EXPORT CString {
60 public: 61 public:
61 CString() { } 62 CString() { }
62 CString(const char*); 63 CString(const char*);
63 CString(const char*, size_t length); 64 CString(const char*, size_t length);
64 CString(CStringBuffer* buffer) : m_buffer(buffer) { } 65 CString(CStringBuffer* buffer) : m_buffer(buffer) { }
65 static CString newUninitialized(size_t length, char*& characterBuffer); 66 static CString newUninitialized(size_t length, char*& characterBuffer);
66 67
67 const char* data() const 68 const char* data() const
68 { 69 {
69 return m_buffer ? m_buffer->data() : 0; 70 return m_buffer ? m_buffer->data() : 0;
70 } 71 }
71 char* mutableData(); 72 char* mutableData();
72 size_t length() const 73 size_t length() const
73 { 74 {
74 return m_buffer ? m_buffer->length() : 0; 75 return m_buffer ? m_buffer->length() : 0;
75 } 76 }
76 77
77 bool isNull() const { return !m_buffer; } 78 bool isNull() const { return !m_buffer; }
78 bool isSafeToSendToAnotherThread() const; 79 bool isSafeToSendToAnotherThread() const;
79 80
80 CStringBuffer* buffer() const { return m_buffer.get(); } 81 CStringBuffer* buffer() const { return m_buffer.get(); }
81 82
82 private: 83 private:
83 void copyBufferIfNeeded(); 84 void copyBufferIfNeeded();
84 void init(const char*, size_t length); 85 void init(const char*, size_t length);
85 RefPtr<CStringBuffer> m_buffer; 86 RefPtr<CStringBuffer> m_buffer;
86 }; 87 };
87 88
88 bool operator==(const CString& a, const CString& b); 89 WTF_EXPORT bool operator==(const CString& a, const CString& b);
89 inline bool operator!=(const CString& a, const CString& b) { return !(a == b); } 90 inline bool operator!=(const CString& a, const CString& b) { return !(a == b); }
90 bool operator==(const CString& a, const char* b); 91 WTF_EXPORT bool operator==(const CString& a, const char* b);
91 inline bool operator!=(const CString& a, const char* b) { return !(a == b); } 92 inline bool operator!=(const CString& a, const char* b) { return !(a == b); }
92 93
93 } // namespace WTF 94 } // namespace WTF
94 95
95 using WTF::CString; 96 using WTF::CString;
96 97
97 #endif // CString_h 98 #endif // CString_h
OLDNEW
« no previous file with comments | « Source/wtf/text/Base64.h ('k') | Source/wtf/text/StringBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698