@@ -137,39 +137,37 @@ auto LogParser::parse(LogParser::ParsingAction& parsing_action) -> ErrorCode {
137137 }
138138 next_token = optional_next_token.value ();
139139 if (false == output_buffer->has_timestamp ()
140- && next_token.m_type_ids_ptr ->at (0 ) == (uint32_t )SymbolId::TokenNewlineTimestamp)
140+ && next_token.get_type_ids ()->at (0 )
141+ == static_cast <uint32_t >(SymbolId::TokenNewlineTimestamp))
141142 {
142143 // TODO: combine the below with found_start_of_next_message
143144 // into 1 function
144145 // Increment by 1 because the '\n' character is not part of the
145146 // next log message
146147 m_start_of_log_message = next_token;
147- if (m_start_of_log_message.m_start_pos == m_start_of_log_message.m_buffer_size - 1 )
148- {
149- m_start_of_log_message.m_start_pos = 0 ;
150- } else {
151- m_start_of_log_message.m_start_pos ++;
152- }
148+ m_start_of_log_message.increment_start_pos ();
153149 // make a message with just the '\n' character
154- next_token.m_end_pos = next_token.m_start_pos + 1 ;
155- next_token.m_type_ids_ptr
156- = &Lexer<ByteNfaState, ByteDfaState>::cTokenUncaughtStringTypes;
150+ next_token.set_end_pos (next_token.get_next_pos ());
151+ next_token.set_type_ids (
152+ &Lexer<ByteNfaState, ByteDfaState>::cTokenUncaughtStringTypes
153+ );
157154 output_buffer->set_token (1 , next_token);
158155 output_buffer->set_pos (2 );
159- m_input_buffer.set_consumed_pos (next_token.m_start_pos );
156+ m_input_buffer.set_consumed_pos (next_token.get_start_pos () );
160157 m_has_start_of_log = true ;
161158 parsing_action = ParsingAction::Compress;
162159 return ErrorCode::Success;
163160 }
164161 }
165- if (next_token.m_type_ids_ptr ->at (0 ) == ( uint32_t ) SymbolId::TokenEnd) {
162+ if (next_token.get_type_ids () ->at (0 ) == static_cast < uint32_t >( SymbolId::TokenEnd) ) {
166163 output_buffer->set_token (0 , next_token);
167164 output_buffer->set_pos (1 );
168165 parsing_action = ParsingAction::CompressAndFinish;
169166 return ErrorCode::Success;
170167 }
171- if (next_token.m_type_ids_ptr ->at (0 ) == (uint32_t )SymbolId::TokenFirstTimestamp
172- || next_token.m_type_ids_ptr ->at (0 ) == (uint32_t )SymbolId::TokenNewlineTimestamp)
168+ if (next_token.get_type_ids ()->at (0 ) == static_cast <uint32_t >(SymbolId::TokenFirstTimestamp)
169+ || next_token.get_type_ids ()->at (0 )
170+ == static_cast <uint32_t >(SymbolId::TokenNewlineTimestamp))
173171 {
174172 output_buffer->set_has_timestamp (true );
175173 output_buffer->set_token (0 , next_token);
@@ -189,11 +187,11 @@ auto LogParser::parse(LogParser::ParsingAction& parsing_action) -> ErrorCode {
189187 }
190188 Token next_token{optional_next_token.value ()};
191189 output_buffer->set_curr_token (next_token);
192- auto token_type = next_token.m_type_ids_ptr ->at (0 );
190+ auto token_type{ next_token.get_type_ids () ->at (0 )} ;
193191 bool found_start_of_next_message
194192 = (output_buffer->has_timestamp ()
195193 && token_type == (uint32_t )SymbolId::TokenNewlineTimestamp)
196- || (! output_buffer->has_timestamp () && next_token.get_char ( 0 ) == ' \n '
194+ || (false == output_buffer->has_timestamp () && next_token.get_delimiter ( ) == " \n "
197195 && token_type != (uint32_t )SymbolId::TokenNewline);
198196 if (token_type == (uint32_t )SymbolId::TokenEnd) {
199197 parsing_action = ParsingAction::CompressAndFinish;
@@ -202,7 +200,7 @@ auto LogParser::parse(LogParser::ParsingAction& parsing_action) -> ErrorCode {
202200 if (false == output_buffer->has_timestamp ()
203201 && token_type == (uint32_t )SymbolId::TokenNewline)
204202 {
205- m_input_buffer.set_consumed_pos (output_buffer->get_curr_token ().m_end_pos );
203+ m_input_buffer.set_consumed_pos (output_buffer->get_curr_token ().get_end_pos () );
206204 output_buffer->advance_to_next_token ();
207205 parsing_action = ParsingAction::Compress;
208206 return ErrorCode::Success;
@@ -211,22 +209,13 @@ auto LogParser::parse(LogParser::ParsingAction& parsing_action) -> ErrorCode {
211209 // increment by 1 because the '\n' character is not part of the next
212210 // log message
213211 m_start_of_log_message = output_buffer->get_curr_token ();
214- if (m_start_of_log_message.m_start_pos == m_start_of_log_message.m_buffer_size - 1 ) {
215- m_start_of_log_message.m_start_pos = 0 ;
216- } else {
217- m_start_of_log_message.m_start_pos ++;
218- }
212+ auto const consumed_pos{m_start_of_log_message.increment_start_pos ()};
219213 // make the last token of the current message the '\n' character
220214 Token curr_token = output_buffer->get_curr_token ();
221- curr_token.m_end_pos = curr_token.m_start_pos + 1 ;
222- curr_token.m_type_ids_ptr
223- = &Lexer<ByteNfaState, ByteDfaState>::cTokenUncaughtStringTypes;
215+ curr_token.set_end_pos (curr_token.get_next_pos ());
216+ curr_token.set_type_ids (&Lexer<ByteNfaState, ByteDfaState>::cTokenUncaughtStringTypes);
224217 output_buffer->set_curr_token (curr_token);
225- if (0 == m_start_of_log_message.m_start_pos ) {
226- m_input_buffer.set_consumed_pos (m_input_buffer.storage ().size () - 1 );
227- } else {
228- m_input_buffer.set_consumed_pos (m_start_of_log_message.m_start_pos - 1 );
229- }
218+ m_input_buffer.set_consumed_pos (consumed_pos);
230219 m_has_start_of_log = true ;
231220 output_buffer->advance_to_next_token ();
232221 parsing_action = ParsingAction::Compress;
@@ -255,7 +244,7 @@ auto LogParser::generate_log_event_view_metadata() -> void {
255244 uint32_t first_newline_pos{0 };
256245 for (uint32_t i = start; i < m_log_event_view->m_log_output_buffer ->pos (); i++) {
257246 Token* token = &m_log_event_view->m_log_output_buffer ->get_mutable_token (i);
258- m_log_event_view->add_token (token->m_type_ids_ptr ->at (0 ), token);
247+ m_log_event_view->add_token (token->get_type_ids () ->at (0 ), token);
259248 if (token->get_delimiter () == " \n " && first_newline_pos == 0 ) {
260249 first_newline_pos = i;
261250 }
0 commit comments