OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights 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 are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 class OutputBuffer { | 40 class OutputBuffer { |
41 public: | 41 public: |
42 virtual char* allocate(size_t) = 0; | 42 virtual char* allocate(size_t) = 0; |
43 virtual void copy(const CString&) = 0; | 43 virtual void copy(const CString&) = 0; |
44 virtual ~OutputBuffer() { } | 44 virtual ~OutputBuffer() { } |
45 }; | 45 }; |
46 | 46 |
47 class CStringBuffer : public OutputBuffer { | 47 class CStringBuffer FINAL : public OutputBuffer { |
48 public: | 48 public: |
49 CStringBuffer(CString& buffer) | 49 CStringBuffer(CString& buffer) |
50 : m_buffer(buffer) | 50 : m_buffer(buffer) |
51 { | 51 { |
52 } | 52 } |
53 virtual ~CStringBuffer() { } | 53 virtual ~CStringBuffer() { } |
54 | 54 |
55 virtual char* allocate(size_t size) | 55 virtual char* allocate(size_t size) OVERRIDE |
56 { | 56 { |
57 char* ptr; | 57 char* ptr; |
58 m_buffer = CString::newUninitialized(size, ptr); | 58 m_buffer = CString::newUninitialized(size, ptr); |
59 return ptr; | 59 return ptr; |
60 } | 60 } |
61 | 61 |
62 virtual void copy(const CString& source) | 62 virtual void copy(const CString& source) OVERRIDE |
63 { | 63 { |
64 m_buffer = source; | 64 m_buffer = source; |
65 } | 65 } |
66 | 66 |
67 const CString& buffer() const { return m_buffer; } | 67 const CString& buffer() const { return m_buffer; } |
68 | 68 |
69 private: | 69 private: |
70 CString m_buffer; | 70 CString m_buffer; |
71 }; | 71 }; |
72 | 72 |
73 class VectorCharAppendBuffer : public OutputBuffer { | 73 class VectorCharAppendBuffer FINAL : public OutputBuffer { |
74 public: | 74 public: |
75 VectorCharAppendBuffer(Vector<char>& buffer) | 75 VectorCharAppendBuffer(Vector<char>& buffer) |
76 : m_buffer(buffer) | 76 : m_buffer(buffer) |
77 { | 77 { |
78 } | 78 } |
79 virtual ~VectorCharAppendBuffer() { } | 79 virtual ~VectorCharAppendBuffer() { } |
80 | 80 |
81 virtual char* allocate(size_t size) | 81 virtual char* allocate(size_t size) OVERRIDE |
82 { | 82 { |
83 size_t oldSize = m_buffer.size(); | 83 size_t oldSize = m_buffer.size(); |
84 m_buffer.grow(oldSize + size); | 84 m_buffer.grow(oldSize + size); |
85 return m_buffer.data() + oldSize; | 85 return m_buffer.data() + oldSize; |
86 } | 86 } |
87 | 87 |
88 virtual void copy(const CString& source) | 88 virtual void copy(const CString& source) OVERRIDE |
89 { | 89 { |
90 m_buffer.append(source.data(), source.length()); | 90 m_buffer.append(source.data(), source.length()); |
91 } | 91 } |
92 | 92 |
93 private: | 93 private: |
94 Vector<char>& m_buffer; | 94 Vector<char>& m_buffer; |
95 }; | 95 }; |
96 | 96 |
97 void internalNormalizeLineEndingsToCRLF(const CString& from, OutputBuffer& buffe
r) | 97 void internalNormalizeLineEndingsToCRLF(const CString& from, OutputBuffer& buffe
r) |
98 { | 98 { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 { | 228 { |
229 #if OS(WIN) | 229 #if OS(WIN) |
230 VectorCharAppendBuffer buffer(result); | 230 VectorCharAppendBuffer buffer(result); |
231 internalNormalizeLineEndingsToCRLF(from, buffer); | 231 internalNormalizeLineEndingsToCRLF(from, buffer); |
232 #else | 232 #else |
233 normalizeLineEndingsToLF(from, result); | 233 normalizeLineEndingsToLF(from, result); |
234 #endif | 234 #endif |
235 } | 235 } |
236 | 236 |
237 } // namespace WebCore | 237 } // namespace WebCore |
OLD | NEW |