<?php
namespace metastore;

/**
 * Autogenerated by Thrift Compiler (0.16.0)
 *
 * 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 PropertyGetResponse
{
    static public $isValidate = false;

    static public $_TSPEC = array(
        1 => array(
            'var' => 'properties',
            'isRequired' => false,
            'type' => TType::MAP,
            'ktype' => TType::STRING,
            'vtype' => TType::MAP,
            'key' => array(
                'type' => TType::STRING,
            ),
            'val' => array(
                'type' => TType::MAP,
                'ktype' => TType::STRING,
                'vtype' => TType::STRING,
                'key' => array(
                    'type' => TType::STRING,
                ),
                'val' => array(
                    'type' => TType::STRING,
                    ),
                ),
        ),
    );

    /**
     * @var array
     */
    public $properties = null;

    public function __construct($vals = null)
    {
        if (is_array($vals)) {
            if (isset($vals['properties'])) {
                $this->properties = $vals['properties'];
            }
        }
    }

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


    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::MAP) {
                        $this->properties = array();
                        $_size74 = 0;
                        $_ktype75 = 0;
                        $_vtype76 = 0;
                        $xfer += $input->readMapBegin($_ktype75, $_vtype76, $_size74);
                        for ($_i78 = 0; $_i78 < $_size74; ++$_i78) {
                            $key79 = '';
                            $val80 = array();
                            $xfer += $input->readString($key79);
                            $val80 = array();
                            $_size81 = 0;
                            $_ktype82 = 0;
                            $_vtype83 = 0;
                            $xfer += $input->readMapBegin($_ktype82, $_vtype83, $_size81);
                            for ($_i85 = 0; $_i85 < $_size81; ++$_i85) {
                                $key86 = '';
                                $val87 = '';
                                $xfer += $input->readString($key86);
                                $xfer += $input->readString($val87);
                                $val80[$key86] = $val87;
                            }
                            $xfer += $input->readMapEnd();
                            $this->properties[$key79] = $val80;
                        }
                        $xfer += $input->readMapEnd();
                    } 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('PropertyGetResponse');
        if ($this->properties !== null) {
            if (!is_array($this->properties)) {
                throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
            }
            $xfer += $output->writeFieldBegin('properties', TType::MAP, 1);
            $output->writeMapBegin(TType::STRING, TType::MAP, count($this->properties));
            foreach ($this->properties as $kiter88 => $viter89) {
                $xfer += $output->writeString($kiter88);
                $output->writeMapBegin(TType::STRING, TType::STRING, count($viter89));
                foreach ($viter89 as $kiter90 => $viter91) {
                    $xfer += $output->writeString($kiter90);
                    $xfer += $output->writeString($viter91);
                }
                $output->writeMapEnd();
            }
            $output->writeMapEnd();
            $xfer += $output->writeFieldEnd();
        }
        $xfer += $output->writeFieldStop();
        $xfer += $output->writeStructEnd();
        return $xfer;
    }
}
