OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 | 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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 */ | 23 */ |
24 | 24 |
25 #ifndef TextPosition_h | 25 #ifndef TextPosition_h |
26 #define TextPosition_h | 26 #define TextPosition_h |
27 | 27 |
28 #include "wtf/Allocator.h" | 28 #include "wtf/Allocator.h" |
29 #include "wtf/Assertions.h" | 29 #include "wtf/Assertions.h" |
30 #include "wtf/Vector.h" | 30 #include "wtf/Vector.h" |
31 #include "wtf/WTFExport.h" | 31 #include "wtf/WTFExport.h" |
32 #include "wtf/text/WTFString.h" | 32 #include "wtf/text/WTFString.h" |
33 #include <memory> | |
34 | 33 |
35 namespace WTF { | 34 namespace WTF { |
36 | 35 |
37 // An abstract number of element in a sequence. The sequence has a first element
. | 36 // An abstract number of element in a sequence. The sequence has a first element
. |
38 // This type should be used instead of integer because 2 contradicting tradition
s can | 37 // This type should be used instead of integer because 2 contradicting tradition
s can |
39 // call a first element '0' or '1' which makes integer type ambiguous. | 38 // call a first element '0' or '1' which makes integer type ambiguous. |
40 class OrdinalNumber final { | 39 class OrdinalNumber final { |
41 DISALLOW_NEW(); | 40 DISALLOW_NEW(); |
42 public: | 41 public: |
43 static OrdinalNumber fromZeroBasedInt(int zeroBasedInt) { return OrdinalNumb
er(zeroBasedInt); } | 42 static OrdinalNumber fromZeroBasedInt(int zeroBasedInt) { return OrdinalNumb
er(zeroBasedInt); } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // A value with line value less than a minimum; used as an impossible positi
on. | 79 // A value with line value less than a minimum; used as an impossible positi
on. |
81 static TextPosition belowRangePosition() { return TextPosition(OrdinalNumber
::beforeFirst(), OrdinalNumber::beforeFirst()); } | 80 static TextPosition belowRangePosition() { return TextPosition(OrdinalNumber
::beforeFirst(), OrdinalNumber::beforeFirst()); } |
82 | 81 |
83 // A value corresponding to a position with given offset within text having
the specified line ending offsets. | 82 // A value corresponding to a position with given offset within text having
the specified line ending offsets. |
84 WTF_EXPORT static TextPosition fromOffsetAndLineEndings(unsigned, const Vect
or<unsigned>&); | 83 WTF_EXPORT static TextPosition fromOffsetAndLineEndings(unsigned, const Vect
or<unsigned>&); |
85 | 84 |
86 OrdinalNumber m_line; | 85 OrdinalNumber m_line; |
87 OrdinalNumber m_column; | 86 OrdinalNumber m_column; |
88 }; | 87 }; |
89 | 88 |
90 WTF_EXPORT std::unique_ptr<Vector<unsigned>> lineEndings(const String&); | 89 WTF_EXPORT PassOwnPtr<Vector<unsigned>> lineEndings(const String&); |
91 | 90 |
92 } // namespace WTF | 91 } // namespace WTF |
93 | 92 |
94 using WTF::OrdinalNumber; | 93 using WTF::OrdinalNumber; |
95 | 94 |
96 using WTF::TextPosition; | 95 using WTF::TextPosition; |
97 | 96 |
98 using WTF::lineEndings; | 97 using WTF::lineEndings; |
99 | 98 |
100 #endif // TextPosition_h | 99 #endif // TextPosition_h |
OLD | NEW |