Analytic solution to the generalized complex Duffing equation and its application in soliton theory