OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple 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 | 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 INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE 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 INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE 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 StringConcatenate_h | 26 #ifndef StringConcatenate_h |
27 #define StringConcatenate_h | 27 #define StringConcatenate_h |
28 | 28 |
29 #include <string.h> | 29 #include <string.h> |
30 | 30 |
31 #ifndef WTFString_h | 31 #ifndef WTFString_h |
32 #include "wtf/text/AtomicString.h" | 32 #include "wtf/text/AtomicString.h" |
33 #endif | 33 #endif |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 bool is8Bit() { return m_buffer.isNull() || m_buffer.is8Bit(); } | 364 bool is8Bit() { return m_buffer.isNull() || m_buffer.is8Bit(); } |
365 | 365 |
366 void writeTo(LChar* destination) | 366 void writeTo(LChar* destination) |
367 { | 367 { |
368 unsigned length = m_buffer.length(); | 368 unsigned length = m_buffer.length(); |
369 | 369 |
370 ASSERT(is8Bit()); | 370 ASSERT(is8Bit()); |
371 const LChar* data = m_buffer.characters8(); | 371 const LChar* data = m_buffer.characters8(); |
372 for (unsigned i = 0; i < length; ++i) | 372 for (unsigned i = 0; i < length; ++i) |
373 destination[i] = data[i]; | 373 destination[i] = data[i]; |
374 | 374 |
375 WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING(); | 375 WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING(); |
376 } | 376 } |
377 | 377 |
378 void writeTo(UChar* destination) | 378 void writeTo(UChar* destination) |
379 { | 379 { |
380 unsigned length = m_buffer.length(); | 380 unsigned length = m_buffer.length(); |
381 | 381 |
382 if (is8Bit()) { | 382 if (is8Bit()) { |
383 const LChar* data = m_buffer.characters8(); | 383 const LChar* data = m_buffer.characters8(); |
384 for (unsigned i = 0; i < length; ++i) | 384 for (unsigned i = 0; i < length; ++i) |
385 destination[i] = data[i]; | 385 destination[i] = data[i]; |
386 } else { | 386 } else { |
387 const UChar* data = m_buffer.characters16(); | 387 const UChar* data = m_buffer.characters16(); |
388 for (unsigned i = 0; i < length; ++i) | 388 for (unsigned i = 0; i < length; ++i) |
389 destination[i] = data[i]; | 389 destination[i] = data[i]; |
390 } | 390 } |
391 | 391 |
392 WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING(); | 392 WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING(); |
393 } | 393 } |
394 | 394 |
395 private: | 395 private: |
396 const String& m_buffer; | 396 const String& m_buffer; |
397 }; | 397 }; |
398 | 398 |
399 template<> | 399 template<> |
400 class StringTypeAdapter<AtomicString> { | 400 class StringTypeAdapter<AtomicString> { |
401 public: | 401 public: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 result += adapter1.length(); | 459 result += adapter1.length(); |
460 adapter2.writeTo(result); | 460 adapter2.writeTo(result); |
461 | 461 |
462 return resultImpl.release(); | 462 return resultImpl.release(); |
463 } | 463 } |
464 | 464 |
465 } // namespace WTF | 465 } // namespace WTF |
466 | 466 |
467 #include "wtf/text/StringOperators.h" | 467 #include "wtf/text/StringOperators.h" |
468 #endif | 468 #endif |
OLD | NEW |