Localized orbital studies of hydrogen bonding. General approach and applications to water, formic acid, and pyruvic acid