OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
13 * distribution. | 13 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
17 * | 17 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
(...skipping 22 matching lines...) Expand all Loading... |
50 public: | 50 public: |
51 ~WebData() { reset(); } | 51 ~WebData() { reset(); } |
52 | 52 |
53 WebData() : m_private(0) { } | 53 WebData() : m_private(0) { } |
54 | 54 |
55 WebData(const char* data, size_t size) : m_private(0) | 55 WebData(const char* data, size_t size) : m_private(0) |
56 { | 56 { |
57 assign(data, size); | 57 assign(data, size); |
58 } | 58 } |
59 | 59 |
| 60 template <int N> |
| 61 WebData(const char (&data)[N]) : m_private(0) |
| 62 { |
| 63 assign(data, N - 1); |
| 64 } |
| 65 |
60 WebData(const WebData& d) : m_private(0) { assign(d); } | 66 WebData(const WebData& d) : m_private(0) { assign(d); } |
61 | 67 |
62 WebData& operator=(const WebData& d) | 68 WebData& operator=(const WebData& d) |
63 { | 69 { |
64 assign(d); | 70 assign(d); |
65 return *this; | 71 return *this; |
66 } | 72 } |
67 | 73 |
68 WEBKIT_API void reset(); | 74 WEBKIT_API void reset(); |
69 WEBKIT_API void assign(const WebData&); | 75 WEBKIT_API void assign(const WebData&); |
70 WEBKIT_API void assign(const char* data, size_t size); | 76 WEBKIT_API void assign(const char* data, size_t size); |
71 | 77 |
72 WEBKIT_API size_t size() const; | 78 WEBKIT_API size_t size() const; |
73 WEBKIT_API const char* data() const; | 79 WEBKIT_API const char* data() const; |
74 | 80 |
75 bool isEmpty() const { return size() == 0; } | 81 bool isEmpty() const { return size() == 0; } |
76 bool isNull() const { return m_private == 0; } | 82 bool isNull() const { return m_private == 0; } |
77 | 83 |
78 #if WEBKIT_IMPLEMENTATION | 84 #if WEBKIT_IMPLEMENTATION |
79 WebData(const WTF::PassRefPtr<WebCore::SharedBuffer>&); | 85 WebData(const WTF::PassRefPtr<WebCore::SharedBuffer>&); |
80 WebData& operator=(const WTF::PassRefPtr<WebCore::SharedBuffer>&); | 86 WebData& operator=(const WTF::PassRefPtr<WebCore::SharedBuffer>&); |
81 operator WTF::PassRefPtr<WebCore::SharedBuffer>() const; | 87 operator WTF::PassRefPtr<WebCore::SharedBuffer>() const; |
| 88 #else |
| 89 template <class C> |
| 90 WebData(const C& c) : m_private(0) |
| 91 { |
| 92 assign(c.data(), c.size()); |
| 93 } |
| 94 |
| 95 template <class C> |
| 96 WebData& operator=(const C& c) |
| 97 { |
| 98 assign(c.data(), c.size()); |
| 99 return *this; |
| 100 } |
82 #endif | 101 #endif |
83 | 102 |
84 private: | 103 private: |
85 void assign(WebDataPrivate*); | 104 void assign(WebDataPrivate*); |
86 WebDataPrivate* m_private; | 105 WebDataPrivate* m_private; |
87 }; | 106 }; |
88 | 107 |
89 } // namespace WebKit | 108 } // namespace WebKit |
90 | 109 |
91 #endif | 110 #endif |
OLD | NEW |