# -*- coding: utf-8 -*-
#
# Autogenerated by Thrift Compiler (0.16.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
#  options string: py:coding=utf-8
#

from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException
from thrift.protocol.TProtocol import TProtocolException
from thrift.TRecursive import fix_spec

import sys

from thrift.transport import TTransport
all_structs = []


class TextSpan(object):
    """
    A span of text within a single communication, identified by a pair
    of zero-indexed character offsets into a Thrift string. Thrift strings
    are encoded using UTF-8:
      https://thrift.apache.org/docs/types
    The offsets are character-based, not byte-based - a character with a
    three-byte UTF-8 representation only counts as one character.

    NOTE: This span represents a best guess, or 'provenance':
    it cannot be guaranteed that this text span matches the _exact_
    text of the original document, but is the annotation's best
    effort at such a representation.

    Attributes:
     - start: Start character, inclusive.
     - ending: End character, exclusive

    """


    def __init__(self, start=None, ending=None,):
        self.start = start
        self.ending = ending

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.I32:
                    self.start = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.I32:
                    self.ending = iprot.readI32()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('TextSpan')
        if self.start is not None:
            oprot.writeFieldBegin('start', TType.I32, 1)
            oprot.writeI32(self.start)
            oprot.writeFieldEnd()
        if self.ending is not None:
            oprot.writeFieldBegin('ending', TType.I32, 2)
            oprot.writeI32(self.ending)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.start is None:
            raise TProtocolException(message='Required field start is unset!')
        if self.ending is None:
            raise TProtocolException(message='Required field ending is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class AudioSpan(object):
    """
    A span of audio within a single communication, identified by a
    pair of time offests. Time offsets are zero-based.

    NOTE: This span represents a best guess, or 'provenance':
    it cannot be guaranteed that this text span matches the _exact_
    text of the original document, but is the annotation's best
    effort at such a representation.

    Attributes:
     - start: Start time (in seconds)
     - ending: End time (in seconds)

    """


    def __init__(self, start=None, ending=None,):
        self.start = start
        self.ending = ending

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.I64:
                    self.start = iprot.readI64()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.I64:
                    self.ending = iprot.readI64()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('AudioSpan')
        if self.start is not None:
            oprot.writeFieldBegin('start', TType.I64, 1)
            oprot.writeI64(self.start)
            oprot.writeFieldEnd()
        if self.ending is not None:
            oprot.writeFieldBegin('ending', TType.I64, 2)
            oprot.writeI64(self.ending)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.start is None:
            raise TProtocolException(message='Required field start is unset!')
        if self.ending is None:
            raise TProtocolException(message='Required field ending is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)
all_structs.append(TextSpan)
TextSpan.thrift_spec = (
    None,  # 0
    (1, TType.I32, 'start', None, None, ),  # 1
    (2, TType.I32, 'ending', None, None, ),  # 2
)
all_structs.append(AudioSpan)
AudioSpan.thrift_spec = (
    None,  # 0
    (1, TType.I64, 'start', None, None, ),  # 1
    (2, TType.I64, 'ending', None, None, ),  # 2
)
fix_spec(all_structs)
del all_structs
