sqlparser/sqlparser.cpp
// Prepend the token with the specified value
Prepend the token with the specified value
Prepend the token with the specified value
Token* SqlParser::Prepend(Token *token, const char *str, const wchar_t *wstr, size_t len, Token *format)
{
	if(token == NULL)
		return NULL;
	Token *prepend = new Token();
	if(format == NULL)
		*prepend = *token;
	else
		*prepend = *format;
	prepend->prev = NULL;
	prepend->next = NULL;
	prepend->t_str = NULL;
	prepend->t_wstr = NULL;
	prepend->t_len = 0;
	prepend->flags = TOKEN_INSERTED;
	Token::Change(prepend, str, wstr, len);
	Prepend(token, prepend);
	if(str != NULL && str[len - 1] == '\n')
	{
		Token *prev = token->prev;
		while(prev != NULL && prev->flags & TOKEN_INSERTED)
			prev = prev->prev;
		while(prev != NULL && (prev->Compare(' ', L' ') == true || prev->Compare('\t', L'\t') == true))
		{
			AppendCopy(prepend, prev);
			prev = prev->prev;
		}
	}
	return prepend;
}
Token * SqlParser :: Prepend ( Token * token , const char * str , const wchar_t * wstr , size_t len , Token * format ) { if ( token == NULL ) return NULL ; Token * prepend = new Token ( ) ; if ( format == NULL ) * prepend = * token ; else * prepend = * format ; prepend -> prev = NULL ; prepend -> next = NULL ; prepend -> t_str = NULL ; prepend -> t_wstr = NULL ; prepend -> t_len = 0 ; prepend -> flags = TOKEN_INSERTED ; Token :: Change ( prepend , str , wstr , len ) ; Prepend ( token , prepend ) ; if ( str != NULL && str [ len - 1 ] == ' \n ' ) { Token * prev = token -> prev ; while ( prev != NULL && prev -> flags & TOKEN_INSERTED ) prev = prev -> prev ; while ( prev != NULL && ( prev -> Compare ( ' ' , L' ' ) == true || prev -> Compare ( ' \t ' , L' \t ' ) == true ) ) { AppendCopy ( prepend , prev ) ; prev = prev -> prev ; } } return prepend ; }
Prepend the token with the specified value
Prepend the token with the specified value
// Define how to format the token // If token ends with newline, add the same number of spaces after prepended token // Skip previously appended tokens // Copy all blanks and tabs before appended token after new line