  Measurements of the production cross sections of prompt ${\rm D^0}$, ${\rm
D^+}$, ${\rm D^{\ast +}}$, ${\rm D_s^+}$, ${\rm \Lambda_{c}^{+}}$, and ${\rm
\Xi_{c}^{+}}$ charm hadrons at midrapidity in proton$-$proton collisions at
$\sqrt{s}=13$ TeV with the ALICE detector are presented. The D-meson cross
sections as a function of transverse momentum ($p_{\rm T}$) are provided with
improved precision and granularity. The ratios of $p_{\rm T}$-differential
meson production cross sections based on this publication and on measurements
at different rapidity and collision energy provide a constraint on gluon parton
distribution functions at low values of Bjorken-$x$ ($10^{-5}-10^{-4}$). The
measurements of ${\rm \Lambda_{c}^{+}}$ (${\rm \Xi_{c}^{+}}$) baryon production
extend the measured $p_{\rm T}$ intervals down to $p_{\rm T}=0(3)$~GeV$/c$.
These measurements are used to determine the charm-quark fragmentation
fractions and the ${\rm c\overline{c}}$ production cross section at midrapidity
($|y|<0.5$) based on the sum of the cross sections of the weakly-decaying
ground-state charm hadrons ${\rm D^0}$, ${\rm D^+}$, ${\rm D_s^+}$, ${\rm
\Lambda_{c}^{+}}$, ${\rm \Xi_{c}^{0}}$ and, for the first time, ${\rm
\Xi_{c}^{+}}$, and of the strongly-decaying J/$psi$ mesons. The first
measurements of ${\rm \Xi_{c}^{+}}$ and ${\rm \Sigma_{c}^{0,++}}$ fragmentation
fractions at midrapidity are also reported. A significantly larger fraction of
charm quarks hadronising to baryons is found compared to e$^+$e$^-$ and ep
collisions. The ${\rm c\overline{c}}$ production cross section at midrapidity
is found to be at the upper bound of state-of-the-art perturbative QCD
calculations.
