OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_UTF_OFFSET_STRING_CONVERSIONS_H_ | 5 #ifndef BASE_UTF_OFFSET_STRING_CONVERSIONS_H_ |
6 #define BASE_UTF_OFFSET_STRING_CONVERSIONS_H_ | 6 #define BASE_UTF_OFFSET_STRING_CONVERSIONS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/base_export.h" | 12 #include "base/base_export.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 | 14 #include "base/string_piece.h" |
15 namespace base { | |
16 class StringPiece; | |
17 class StringPiece16; | |
18 } | |
19 | 15 |
20 // Like the conversions in utf_string_conversions.h, but also takes one or more | 16 // Like the conversions in utf_string_conversions.h, but also takes one or more |
21 // offsets (|offset[s]_for_adjustment|) into the source strings, each offset | 17 // offsets (|offset[s]_for_adjustment|) into the source strings, each offset |
22 // will be adjusted to point at the same logical place in the result strings. | 18 // will be adjusted to point at the same logical place in the result strings. |
23 // If this isn't possible because an offset points past the end of the source | 19 // If this isn't possible because an offset points past the end of the source |
24 // strings or into the middle of a multibyte sequence, the offending offset will | 20 // strings or into the middle of a multibyte sequence, the offending offset will |
25 // be set to string16::npos. |offset[s]_for_adjustment| may be NULL. | 21 // be set to string16::npos. |offset[s]_for_adjustment| may be NULL. |
26 BASE_EXPORT bool UTF8ToUTF16AndAdjustOffset(const char* src, | 22 BASE_EXPORT bool UTF8ToUTF16AndAdjustOffset(const char* src, |
27 size_t src_len, | 23 size_t src_len, |
28 string16* output, | 24 string16* output, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void Add(const Adjustment& adjustment); | 81 void Add(const Adjustment& adjustment); |
86 | 82 |
87 private: | 83 private: |
88 void AdjustOffset(std::vector<size_t>::iterator offset); | 84 void AdjustOffset(std::vector<size_t>::iterator offset); |
89 | 85 |
90 std::vector<size_t>* offsets_for_adjustment_; | 86 std::vector<size_t>* offsets_for_adjustment_; |
91 std::vector<Adjustment> adjustments_; | 87 std::vector<Adjustment> adjustments_; |
92 }; | 88 }; |
93 | 89 |
94 #endif // BASE_UTF_OFFSET_STRING_CONVERSIONS_H_ | 90 #endif // BASE_UTF_OFFSET_STRING_CONVERSIONS_H_ |
OLD | NEW |