Measurement of the WW cross section in pp collisions with the ATLAS detector and limits on anomalous gauge couplings