# Path: typepy/_typecode.py
# class Typecode(enum.Enum):
#     NONE = 0
#     INTEGER = 1 << 0
#     REAL_NUMBER = 1 << 1
#     STRING = 1 << 2
#     NULL_STRING = 1 << 3
#     DATETIME = 1 << 4
#     INFINITY = 1 << 5
#     NAN = 1 << 6
#     BOOL = 1 << 7
#     DICTIONARY = 1 << 8
#     LIST = 1 << 9
#     IP_ADDRESS = 1 << 10
#     BYTES = 1 << 11
# 
# Path: typepy/checker/_string.py
# class NullStringTypeChecker(TypeCheckerDelegator):
#     def __init__(self, value, strict_level):
#         super().__init__(
#             value=value, checker_factory=_null_string_factory, strict_level=strict_level
#         )
# 
# class StringTypeChecker(TypeCheckerDelegator):
#     def __init__(self, value, strict_level):
#         super().__init__(value=value, checker_factory=_string_factory, strict_level=strict_level)
# 
# Path: typepy/converter/_string.py
# class NullStringConverter(StringConverter):
#     def force_convert(self):
#         return super().force_convert()
# 
# class StringConverter(AbstractValueConverter):
#     def force_convert(self):
#         try:
#             return MultiByteStrDecoder(self._value).unicode_str
#         except ValueError:
#             return str(self._value)
# 
# Path: typepy/type/_base.py
# class AbstractType(TypeCheckerInterface, ValueConverterInterface):
#     __slots__ = (
#         "_data",
#         "_strict_level",
#         "_params",
#         "__checker",
#         "__converter",
#         "__is_type_result",
#     )
# 
#     @abc.abstractproperty
#     def typecode(self) -> Typecode:  # pragma: no cover
#         pass
# 
#     @abc.abstractmethod
#     def _create_type_checker(self):  # pragma: no cover
#         pass
# 
#     @abc.abstractmethod
#     def _create_type_converter(self):  # pragma: no cover
#         pass
# 
#     @property
#     def typename(self) -> str:
#         return self.typecode.name
# 
#     def __init__(self, value: Any, strict_level: int, **kwargs) -> None:
#         self._data = value
#         self._strict_level = strict_level
#         self._params = kwargs
# 
#         self.__checker = self._create_type_checker()
#         self.__converter = self._create_type_converter()
# 
#         self.__is_type_result: Optional[bool] = None
# 
#     def __repr__(self) -> str:
#         return ", ".join(
#             [
#                 f"value={self._data}",
#                 f"typename={self.typename}",
#                 f"strict_level={self._strict_level}",
#                 f"is_type={self.is_type()}",
#                 f"try_convert={self.try_convert()}",
#             ]
#         )
# 
#     def is_type(self) -> bool:
#         """
#         :return:
#         :rtype: bool
#         """
# 
#         if self.__is_type_result is not None:
#             return self.__is_type_result
# 
#         self.__is_type_result = self.__is_type()
# 
#         return self.__is_type_result
# 
#     def __is_type(self) -> bool:
#         if self.__checker.is_type():
#             return True
# 
#         if self.__checker.is_exclude_instance():
#             return False
# 
#         try:
#             self._converted_value = self.__converter.force_convert()
#         except TypeConversionError:
#             return False
# 
#         if not self.__checker.is_valid_after_convert(self._converted_value):
#             return False
# 
#         return True
# 
#     def validate(self, error_message: Optional[str] = None) -> None:
#         """
#         :raises TypeError:
#             If the value is not matched the type that the class represented.
#         """
# 
#         if self.is_type():
#             return
# 
#         if not error_message:
#             error_message = "invalid value type"
# 
#         raise TypeError(f"{error_message}: expected={self.typename}, actual={type(self._data)}")
# 
#     def convert(self):
#         """
#         :return: Converted value.
#         :raises typepy.TypeConversionError:
#             If the value cannot convert.
#         """
# 
#         if self.is_type():
#             return self.force_convert()
# 
#         raise TypeConversionError(
#             "failed to convert {} from {} to {}".format(
#                 self._data, type(self._data).__name__, self.typename
#             )
#         )
# 
#     def force_convert(self):
#         """
#         :return: Converted value.
#         :raises typepy.TypeConversionError:
#             If the value cannot convert.
#         """
# 
#         return self.__converter.force_convert()
# 
#     def try_convert(self):
#         """
#         :return: Converted value. |None| if failed to convert.
#         """
# 
#         try:
#             return self.convert()
#         except TypeConversionError:
#             return None


from typing import Any
from .._typecode import Typecode
from ..checker import NullStringTypeChecker, StringTypeChecker
from ..converter import NullStringConverter, StringConverter
from ._base import AbstractType
"""
.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
"""




class String(AbstractType):
    """
    |result_matrix_desc|

    .. include:: matrix_string_type.txt

    :py:attr:`.strict_level`
        |strict_level|
    """

    @property
    def typecode(self) -> Typecode:
        return Typecode.STRING

    def __init__(self, value: Any, strict_level: int = 1, **kwargs) -> None:
        super().__init__(value, strict_level, **kwargs)


# Path: typepy/_typecode.py
# class Typecode(enum.Enum):
#     NONE = 0
#     INTEGER = 1 << 0
#     REAL_NUMBER = 1 << 1
#     STRING = 1 << 2
#     NULL_STRING = 1 << 3
#     DATETIME = 1 << 4
#     INFINITY = 1 << 5
#     NAN = 1 << 6
#     BOOL = 1 << 7
#     DICTIONARY = 1 << 8
#     LIST = 1 << 9
#     IP_ADDRESS = 1 << 10
#     BYTES = 1 << 11
# 
# Path: typepy/checker/_string.py
# class NullStringTypeChecker(TypeCheckerDelegator):
#     def __init__(self, value, strict_level):
#         super().__init__(
#             value=value, checker_factory=_null_string_factory, strict_level=strict_level
#         )
# 
# class StringTypeChecker(TypeCheckerDelegator):
#     def __init__(self, value, strict_level):
#         super().__init__(value=value, checker_factory=_string_factory, strict_level=strict_level)
# 
# Path: typepy/converter/_string.py
# class NullStringConverter(StringConverter):
#     def force_convert(self):
#         return super().force_convert()
# 
# class StringConverter(AbstractValueConverter):
#     def force_convert(self):
#         try:
#             return MultiByteStrDecoder(self._value).unicode_str
#         except ValueError:
#             return str(self._value)
# 
# Path: typepy/type/_base.py
# class AbstractType(TypeCheckerInterface, ValueConverterInterface):
#     __slots__ = (
#         "_data",
#         "_strict_level",
#         "_params",
#         "__checker",
#         "__converter",
#         "__is_type_result",
#     )
# 
#     @abc.abstractproperty
#     def typecode(self) -> Typecode:  # pragma: no cover
#         pass
# 
#     @abc.abstractmethod
#     def _create_type_checker(self):  # pragma: no cover
#         pass
# 
#     @abc.abstractmethod
#     def _create_type_converter(self):  # pragma: no cover
#         pass
# 
#     @property
#     def typename(self) -> str:
#         return self.typecode.name
# 
#     def __init__(self, value: Any, strict_level: int, **kwargs) -> None:
#         self._data = value
#         self._strict_level = strict_level
#         self._params = kwargs
# 
#         self.__checker = self._create_type_checker()
#         self.__converter = self._create_type_converter()
# 
#         self.__is_type_result: Optional[bool] = None
# 
#     def __repr__(self) -> str:
#         return ", ".join(
#             [
#                 f"value={self._data}",
#                 f"typename={self.typename}",
#                 f"strict_level={self._strict_level}",
#                 f"is_type={self.is_type()}",
#                 f"try_convert={self.try_convert()}",
#             ]
#         )
# 
#     def is_type(self) -> bool:
#         """
#         :return:
#         :rtype: bool
#         """
# 
#         if self.__is_type_result is not None:
#             return self.__is_type_result
# 
#         self.__is_type_result = self.__is_type()
# 
#         return self.__is_type_result
# 
#     def __is_type(self) -> bool:
#         if self.__checker.is_type():
#             return True
# 
#         if self.__checker.is_exclude_instance():
#             return False
# 
#         try:
#             self._converted_value = self.__converter.force_convert()
#         except TypeConversionError:
#             return False
# 
#         if not self.__checker.is_valid_after_convert(self._converted_value):
#             return False
# 
#         return True
# 
#     def validate(self, error_message: Optional[str] = None) -> None:
#         """
#         :raises TypeError:
#             If the value is not matched the type that the class represented.
#         """
# 
#         if self.is_type():
#             return
# 
#         if not error_message:
#             error_message = "invalid value type"
# 
#         raise TypeError(f"{error_message}: expected={self.typename}, actual={type(self._data)}")
# 
#     def convert(self):
#         """
#         :return: Converted value.
#         :raises typepy.TypeConversionError:
#             If the value cannot convert.
#         """
# 
#         if self.is_type():
#             return self.force_convert()
# 
#         raise TypeConversionError(
#             "failed to convert {} from {} to {}".format(
#                 self._data, type(self._data).__name__, self.typename
#             )
#         )
# 
#     def force_convert(self):
#         """
#         :return: Converted value.
#         :raises typepy.TypeConversionError:
#             If the value cannot convert.
#         """
# 
#         return self.__converter.force_convert()
# 
#     def try_convert(self):
#         """
#         :return: Converted value. |None| if failed to convert.
#         """
# 
#         try:
#             return self.convert()
#         except TypeConversionError:
#             return None


# Path: typepy/type/_string.py
from typing import Any
from .._typecode import Typecode
from ..checker import NullStringTypeChecker, StringTypeChecker
from ..converter import NullStringConverter, StringConverter
from ._base import AbstractType

"""
.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
"""




class String(AbstractType):
    """
    |result_matrix_desc|

    .. include:: matrix_string_type.txt

    :py:attr:`.strict_level`
        |strict_level|
    """

    @property
    def typecode(self) -> Typecode:
        return Typecode.STRING

    def __init__(self, value: Any, strict_level: int = 1, **kwargs) -> None:
        super().__init__(value, strict_level, **kwargs)


    def _create_type_checker(self) -> StringTypeChecker: