<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _scalar_value_tomof( value, type, indent=0, maxline=MAX_MOF_LINE, line_pos=0, end_space=0, avoid_splits=False):
 # pylint: disable=line-too-long,redefined-builtin """ Return a MOF string representing a scalar CIM-typed value. `None` is returned as 'NULL'. Parameters: value (:term:`CIM data type`, :term:`number`, :class:`~pywbem.CIMInstance`, :class:`~pywbem.CIMClass`):
 The scalar CIM-typed value. May be `None`. Must not be an array/list/tuple. Must not be a :ref:`CIM object` other than those listed. type (string):
 CIM data type name. indent (:term:`integer`):
 Number of spaces to indent any new lines that are generated. maxline (:term:`integer`):
 Maximum line length for the generated MOF. line_pos (:term:`integer`):
 Length of content already on the current line. end_space (:term:`integer`):
 Length of space to be left free on the last line. avoid_splits (bool):
 Avoid splits at the price of starting a new line instead of using the current line. Returns: tuple of * :term:`unicode string`: MOF string. * new line_pos """
  # noqa: E501

    if value is None:
        return mofval(u'NULL', indent, maxline, line_pos, end_space)

    if type == 'string':  # pylint: disable=no-else-raise
        if isinstance(value, six.string_types):
            return mofstr(value, indent, maxline, line_pos, end_space,
                          avoid_splits)

        if isinstance(value, (CIMInstance, CIMClass)):
            # embedded instance or class
            return mofstr(value.tomof(), indent, maxline, line_pos, end_space,
                          avoid_splits)
        raise TypeError(
            _format("Scalar value of CIM type {0} has invalid Python type "
                    "type {1} for conversion to a MOF string",
                    type, builtin_type(value)))

    elif type == 'char16':
        return mofstr(value, indent, maxline, line_pos, end_space, avoid_splits,
                      quote_char=u"'")
    elif type == 'boolean':
        val = u'true' if value else u'false'
        return mofval(val, indent, maxline, line_pos, end_space)
    elif type == 'datetime':
        val = six.text_type(value)
        return mofstr(val, indent, maxline, line_pos, end_space, avoid_splits)
    elif type == 'reference':
        val = value.to_wbem_uri()
        return mofstr(val, indent, maxline, line_pos, end_space, avoid_splits)
    elif isinstance(value, (CIMFloat, CIMInt, int, _Longint)):
        val = six.text_type(value)
        return mofval(val, indent, maxline, line_pos, end_space)
    else:
        assert isinstance(value, float), \
            _format("Scalar value of CIM type {0} has invalid Python type {1} "
                    "for conversion to a MOF string",
                    type, builtin_type(value))
        val = repr(value)
        return mofval(val, indent, maxline, line_pos, end_space)