<?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 ObjectDictionary
{
    static public $isValidate = false;

    static public $_TSPEC = array(
        1 => array(
            'var' => 'values',
            'isRequired' => true,
            'type' => TType::MAP,
            'ktype' => TType::STRING,
            'vtype' => TType::LST,
            'key' => array(
                'type' => TType::STRING,
            ),
            'val' => array(
                'type' => TType::LST,
                'etype' => TType::STRING,
                'elem' => array(
                    'type' => TType::STRING,
                    ),
                ),
        ),
    );

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

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

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


    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->values = array();
                        $_size303 = 0;
                        $_ktype304 = 0;
                        $_vtype305 = 0;
                        $xfer += $input->readMapBegin($_ktype304, $_vtype305, $_size303);
                        for ($_i307 = 0; $_i307 < $_size303; ++$_i307) {
                            $key308 = '';
                            $val309 = array();
                            $xfer += $input->readString($key308);
                            $val309 = array();
                            $_size310 = 0;
                            $_etype313 = 0;
                            $xfer += $input->readListBegin($_etype313, $_size310);
                            for ($_i314 = 0; $_i314 < $_size310; ++$_i314) {
                                $elem315 = null;
                                $xfer += $input->readString($elem315);
                                $val309 []= $elem315;
                            }
                            $xfer += $input->readListEnd();
                            $this->values[$key308] = $val309;
                        }
                        $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('ObjectDictionary');
        if ($this->values !== null) {
            if (!is_array($this->values)) {
                throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
            }
            $xfer += $output->writeFieldBegin('values', TType::MAP, 1);
            $output->writeMapBegin(TType::STRING, TType::LST, count($this->values));
            foreach ($this->values as $kiter316 => $viter317) {
                $xfer += $output->writeString($kiter316);
                $output->writeListBegin(TType::STRING, count($viter317));
                foreach ($viter317 as $iter318) {
                    $xfer += $output->writeString($iter318);
                }
                $output->writeListEnd();
            }
            $output->writeMapEnd();
            $xfer += $output->writeFieldEnd();
        }
        $xfer += $output->writeFieldStop();
        $xfer += $output->writeStructEnd();
        return $xfer;
    }
}
