OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 }; | 47 }; |
48 | 48 |
49 class VTTToken { | 49 class VTTToken { |
50 WTF_MAKE_NONCOPYABLE(VTTToken); | 50 WTF_MAKE_NONCOPYABLE(VTTToken); |
51 WTF_MAKE_FAST_ALLOCATED; | 51 WTF_MAKE_FAST_ALLOCATED; |
52 public: | 52 public: |
53 typedef VTTTokenTypes Type; | 53 typedef VTTTokenTypes Type; |
54 | 54 |
55 VTTToken() { clear(); } | 55 VTTToken() { clear(); } |
56 | 56 |
57 void appendToName(UChar character) | |
58 { | |
59 ASSERT(character); | |
60 m_data.append(character); | |
61 } | |
62 | |
63 Type::Type type() const { return m_type; } | 57 Type::Type type() const { return m_type; } |
64 void setType(Type::Type type) { m_type = type; } | 58 void setType(Type::Type type) { m_type = type; } |
65 | 59 |
66 StringBuilder& name() | 60 StringBuilder& name() |
67 { | 61 { |
68 return m_data; | 62 return m_data; |
69 } | 63 } |
70 | 64 |
71 StringBuilder& characters() | 65 StringBuilder& characters() |
72 { | 66 { |
73 return m_data; | 67 return m_data; |
74 } | 68 } |
75 | 69 |
76 void appendToCharacter(char character) | 70 void appendToData(char character) |
77 { | 71 { |
78 m_data.append(character); | 72 m_data.append(character); |
79 } | 73 } |
80 | 74 |
81 void appendToCharacter(UChar character) | 75 void appendToData(UChar character) |
82 { | 76 { |
83 m_data.append(character); | 77 m_data.append(character); |
84 } | 78 } |
85 | 79 |
86 void appendToCharacter(const StringBuilder& characters) | 80 void appendToData(const StringBuilder& characters) |
87 { | 81 { |
88 m_data.append(characters); | 82 m_data.append(characters); |
89 } | 83 } |
90 | 84 |
91 void beginEmptyStartTag() | 85 void addNewClass(const StringBuilder& s) |
92 { | |
93 m_data.clear(); | |
94 } | |
95 | |
96 void beginStartTag(UChar character) | |
97 { | |
98 ASSERT(character); | |
99 m_data.append(character); | |
100 } | |
101 | |
102 void beginEndTag(LChar character) | |
103 { | |
104 m_data.append(character); | |
105 } | |
106 | |
107 void beginTimestampTag(UChar character) | |
108 { | |
109 ASSERT(character); | |
110 m_data.append(character); | |
111 } | |
112 | |
113 void appendToTimestamp(UChar character) | |
114 { | |
115 ASSERT(character); | |
116 m_data.append(character); | |
117 } | |
118 | |
119 void appendToClass(UChar character) | |
120 { | |
121 appendToStartType(character); | |
122 } | |
123 | |
124 void addNewClass() | |
125 { | 86 { |
126 if (!m_classes.isEmpty()) | 87 if (!m_classes.isEmpty()) |
127 m_classes.append(' '); | 88 m_classes.append(' '); |
128 m_classes.append(m_currentBuffer); | 89 m_classes.append(s); |
129 m_currentBuffer.clear(); | |
130 } | 90 } |
131 | 91 |
132 StringBuilder& classes() | 92 StringBuilder& classes() |
133 { | 93 { |
134 return m_classes; | 94 return m_classes; |
135 } | 95 } |
136 | 96 |
137 void appendToAnnotation(UChar character) | 97 void addNewAnnotation(const StringBuilder& s) |
138 { | |
139 appendToStartType(character); | |
140 } | |
141 | |
142 void addNewAnnotation() | |
143 { | 98 { |
144 m_annotation.clear(); | 99 m_annotation.clear(); |
145 m_annotation.append(m_currentBuffer); | 100 m_annotation.append(s); |
146 m_currentBuffer.clear(); | |
147 } | 101 } |
148 | 102 |
149 StringBuilder& annotation() | 103 StringBuilder& annotation() |
150 { | 104 { |
151 return m_annotation; | 105 return m_annotation; |
152 } | 106 } |
153 | 107 |
154 void clear() | 108 void clear() |
155 { | 109 { |
156 m_type = Type::Uninitialized; | 110 m_type = Type::Uninitialized; |
157 m_data.clear(); | 111 m_data.clear(); |
158 m_annotation.clear(); | 112 m_annotation.clear(); |
159 m_classes.clear(); | 113 m_classes.clear(); |
160 m_currentBuffer.clear(); | |
161 } | 114 } |
162 | 115 |
163 private: | 116 private: |
164 void appendToStartType(UChar character) | |
165 { | |
166 ASSERT(character); | |
167 m_currentBuffer.append(character); | |
168 } | |
169 | |
170 Type::Type m_type; | 117 Type::Type m_type; |
171 StringBuilder m_data; | 118 StringBuilder m_data; |
172 StringBuilder m_annotation; | 119 StringBuilder m_annotation; |
173 StringBuilder m_classes; | 120 StringBuilder m_classes; |
174 StringBuilder m_currentBuffer; | |
175 }; | 121 }; |
176 | 122 |
177 } | 123 } |
178 | 124 |
179 #endif | 125 #endif |
OLD | NEW |