def mutates(f):
    '''Decorator for functions that mutate :class:`StringCounter`.

    This raises :exc:`~dossier.fc.exceptions.ReadOnlyException` if
    the object is read-only, and increments the generation counter
    otherwise.
    '''
    @wraps(f)
    def wrapper(self, *args, **kwargs):
        if self.read_only:
            raise ReadOnlyException()
        self.next_generation()
        return f(self, *args, **kwargs)
    return wrapper