Line functional theory for strings. I.