<?php
namespace com\bilibili;

/**
 * Autogenerated by Thrift Compiler (0.9.3)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
use Thrift\Base\TBase;
use Thrift\Type\TType;
use Thrift\Type\TMessageType;
use Thrift\Exception\TException;
use Thrift\Exception\TProtocolException;
use Thrift\Protocol\TProtocol;
use Thrift\Protocol\TBinaryProtocolAccelerated;
use Thrift\Exception\TApplicationException;


class bbip_result {
  static $_TSPEC;

  /**
   * @var int
   */
  public $range_start = null;
  /**
   * @var int
   */
  public $range_end = null;
  /**
   * @var string
   */
  public $country = null;
  /**
   * @var string
   */
  public $province = null;
  /**
   * @var string
   */
  public $city = null;
  /**
   * @var string
   */
  public $district = null;
  /**
   * @var string
   */
  public $isp = null;
  /**
   * @var string
   */
  public $type = null;
  /**
   * @var string
   */
  public $desc = null;
  /**
   * @var double
   */
  public $lat = null;
  /**
   * @var double
   */
  public $lng = null;
  /**
   * @var int
   */
  public $cidr = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'range_start',
          'type' => TType::I64,
          ),
        2 => array(
          'var' => 'range_end',
          'type' => TType::I64,
          ),
        3 => array(
          'var' => 'country',
          'type' => TType::STRING,
          ),
        4 => array(
          'var' => 'province',
          'type' => TType::STRING,
          ),
        5 => array(
          'var' => 'city',
          'type' => TType::STRING,
          ),
        6 => array(
          'var' => 'district',
          'type' => TType::STRING,
          ),
        7 => array(
          'var' => 'isp',
          'type' => TType::STRING,
          ),
        8 => array(
          'var' => 'type',
          'type' => TType::STRING,
          ),
        9 => array(
          'var' => 'desc',
          'type' => TType::STRING,
          ),
        10 => array(
          'var' => 'lat',
          'type' => TType::DOUBLE,
          ),
        11 => array(
          'var' => 'lng',
          'type' => TType::DOUBLE,
          ),
        12 => array(
          'var' => 'cidr',
          'type' => TType::I16,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['range_start'])) {
        $this->range_start = $vals['range_start'];
      }
      if (isset($vals['range_end'])) {
        $this->range_end = $vals['range_end'];
      }
      if (isset($vals['country'])) {
        $this->country = $vals['country'];
      }
      if (isset($vals['province'])) {
        $this->province = $vals['province'];
      }
      if (isset($vals['city'])) {
        $this->city = $vals['city'];
      }
      if (isset($vals['district'])) {
        $this->district = $vals['district'];
      }
      if (isset($vals['isp'])) {
        $this->isp = $vals['isp'];
      }
      if (isset($vals['type'])) {
        $this->type = $vals['type'];
      }
      if (isset($vals['desc'])) {
        $this->desc = $vals['desc'];
      }
      if (isset($vals['lat'])) {
        $this->lat = $vals['lat'];
      }
      if (isset($vals['lng'])) {
        $this->lng = $vals['lng'];
      }
      if (isset($vals['cidr'])) {
        $this->cidr = $vals['cidr'];
      }
    }
  }

  public function getName() {
    return 'bbip_result';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::I64) {
            $xfer += $input->readI64($this->range_start);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::I64) {
            $xfer += $input->readI64($this->range_end);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 3:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->country);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 4:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->province);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 5:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->city);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 6:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->district);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 7:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->isp);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 8:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->type);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 9:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->desc);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 10:
          if ($ftype == TType::DOUBLE) {
            $xfer += $input->readDouble($this->lat);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 11:
          if ($ftype == TType::DOUBLE) {
            $xfer += $input->readDouble($this->lng);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 12:
          if ($ftype == TType::I16) {
            $xfer += $input->readI16($this->cidr);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('bbip_result');
    if ($this->range_start !== null) {
      $xfer += $output->writeFieldBegin('range_start', TType::I64, 1);
      $xfer += $output->writeI64($this->range_start);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->range_end !== null) {
      $xfer += $output->writeFieldBegin('range_end', TType::I64, 2);
      $xfer += $output->writeI64($this->range_end);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->country !== null) {
      $xfer += $output->writeFieldBegin('country', TType::STRING, 3);
      $xfer += $output->writeString($this->country);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->province !== null) {
      $xfer += $output->writeFieldBegin('province', TType::STRING, 4);
      $xfer += $output->writeString($this->province);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->city !== null) {
      $xfer += $output->writeFieldBegin('city', TType::STRING, 5);
      $xfer += $output->writeString($this->city);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->district !== null) {
      $xfer += $output->writeFieldBegin('district', TType::STRING, 6);
      $xfer += $output->writeString($this->district);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->isp !== null) {
      $xfer += $output->writeFieldBegin('isp', TType::STRING, 7);
      $xfer += $output->writeString($this->isp);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->type !== null) {
      $xfer += $output->writeFieldBegin('type', TType::STRING, 8);
      $xfer += $output->writeString($this->type);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->desc !== null) {
      $xfer += $output->writeFieldBegin('desc', TType::STRING, 9);
      $xfer += $output->writeString($this->desc);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->lat !== null) {
      $xfer += $output->writeFieldBegin('lat', TType::DOUBLE, 10);
      $xfer += $output->writeDouble($this->lat);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->lng !== null) {
      $xfer += $output->writeFieldBegin('lng', TType::DOUBLE, 11);
      $xfer += $output->writeDouble($this->lng);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->cidr !== null) {
      $xfer += $output->writeFieldBegin('cidr', TType::I16, 12);
      $xfer += $output->writeI16($this->cidr);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class InvalidOperation extends TException {
  static $_TSPEC;

  /**
   * @var int
   */
  public $code = null;
  /**
   * @var string
   */
  public $msg = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'code',
          'type' => TType::I32,
          ),
        2 => array(
          'var' => 'msg',
          'type' => TType::STRING,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['code'])) {
        $this->code = $vals['code'];
      }
      if (isset($vals['msg'])) {
        $this->msg = $vals['msg'];
      }
    }
  }

  public function getName() {
    return 'InvalidOperation';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->code);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->msg);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('InvalidOperation');
    if ($this->code !== null) {
      $xfer += $output->writeFieldBegin('code', TType::I32, 1);
      $xfer += $output->writeI32($this->code);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->msg !== null) {
      $xfer += $output->writeFieldBegin('msg', TType::STRING, 2);
      $xfer += $output->writeString($this->msg);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}


