def format_str(s, delimiter=None):
    """ Format a python str as a c++ string literal. """
    if not delimiter:
        return '"{0}"'.format(s)
    return 'R"{delim}({s}){delim}"'.format(s=s, delim=delimiter)