A generalization of the Whitney rank generating function