/examples/thrift/packages/moodle_enrol_manual/Types.php

https://bitbucket.org/hhteam/moodle_thrift_tools · PHP · 337 lines · 313 code · 18 blank · 6 comment · 59 complexity · 3088f50757e04a5f568e11afeb791949 MD5 · raw file

  1. <?php
  2. namespace moodle_enrol_manual;
  3. /**
  4. * Autogenerated by Thrift Compiler (0.9.0-dev)
  5. *
  6. * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  7. * @generated
  8. */
  9. use Thrift\Base\TBase;
  10. use Thrift\Type\TType;
  11. use Thrift\Type\TMessageType;
  12. use Thrift\Exception\TException;
  13. use Thrift\Exception\TProtocolException;
  14. use Thrift\Protocol\TProtocol;
  15. use Thrift\Exception\TApplicationException;
  16. class ApiError extends TException {
  17. static $_TSPEC;
  18. public $errorCode = null;
  19. public $humanMessage = null;
  20. public $userData = null;
  21. public function __construct($vals=null) {
  22. if (!isset(self::$_TSPEC)) {
  23. self::$_TSPEC = array(
  24. 1 => array(
  25. 'var' => 'errorCode',
  26. 'type' => TType::I32,
  27. ),
  28. 2 => array(
  29. 'var' => 'humanMessage',
  30. 'type' => TType::STRING,
  31. ),
  32. 3 => array(
  33. 'var' => 'userData',
  34. 'type' => TType::MAP,
  35. 'ktype' => TType::STRING,
  36. 'vtype' => TType::STRING,
  37. 'key' => array(
  38. 'type' => TType::STRING,
  39. ),
  40. 'val' => array(
  41. 'type' => TType::STRING,
  42. ),
  43. ),
  44. );
  45. }
  46. if (is_array($vals)) {
  47. if (isset($vals['errorCode'])) {
  48. $this->errorCode = $vals['errorCode'];
  49. }
  50. if (isset($vals['humanMessage'])) {
  51. $this->humanMessage = $vals['humanMessage'];
  52. }
  53. if (isset($vals['userData'])) {
  54. $this->userData = $vals['userData'];
  55. }
  56. }
  57. }
  58. public function getName() {
  59. return 'ApiError';
  60. }
  61. public function read($input)
  62. {
  63. $xfer = 0;
  64. $fname = null;
  65. $ftype = 0;
  66. $fid = 0;
  67. $xfer += $input->readStructBegin($fname);
  68. while (true)
  69. {
  70. $xfer += $input->readFieldBegin($fname, $ftype, $fid);
  71. if ($ftype == TType::STOP) {
  72. break;
  73. }
  74. switch ($fid)
  75. {
  76. case 1:
  77. if ($ftype == TType::I32) {
  78. $xfer += $input->readI32($this->errorCode);
  79. } else {
  80. $xfer += $input->skip($ftype);
  81. }
  82. break;
  83. case 2:
  84. if ($ftype == TType::STRING) {
  85. $xfer += $input->readString($this->humanMessage);
  86. } else {
  87. $xfer += $input->skip($ftype);
  88. }
  89. break;
  90. case 3:
  91. if ($ftype == TType::MAP) {
  92. $this->userData = array();
  93. $_size0 = 0;
  94. $_ktype1 = 0;
  95. $_vtype2 = 0;
  96. $xfer += $input->readMapBegin($_ktype1, $_vtype2, $_size0);
  97. for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
  98. {
  99. $key5 = '';
  100. $val6 = '';
  101. $xfer += $input->readString($key5);
  102. $xfer += $input->readString($val6);
  103. $this->userData[$key5] = $val6;
  104. }
  105. $xfer += $input->readMapEnd();
  106. } else {
  107. $xfer += $input->skip($ftype);
  108. }
  109. break;
  110. default:
  111. $xfer += $input->skip($ftype);
  112. break;
  113. }
  114. $xfer += $input->readFieldEnd();
  115. }
  116. $xfer += $input->readStructEnd();
  117. return $xfer;
  118. }
  119. public function write($output) {
  120. $xfer = 0;
  121. $xfer += $output->writeStructBegin('ApiError');
  122. if ($this->errorCode !== null) {
  123. $xfer += $output->writeFieldBegin('errorCode', TType::I32, 1);
  124. $xfer += $output->writeI32($this->errorCode);
  125. $xfer += $output->writeFieldEnd();
  126. }
  127. if ($this->humanMessage !== null) {
  128. $xfer += $output->writeFieldBegin('humanMessage', TType::STRING, 2);
  129. $xfer += $output->writeString($this->humanMessage);
  130. $xfer += $output->writeFieldEnd();
  131. }
  132. if ($this->userData !== null) {
  133. if (!is_array($this->userData)) {
  134. throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
  135. }
  136. $xfer += $output->writeFieldBegin('userData', TType::MAP, 3);
  137. {
  138. $output->writeMapBegin(TType::STRING, TType::STRING, count($this->userData));
  139. {
  140. foreach ($this->userData as $kiter7 => $viter8)
  141. {
  142. $xfer += $output->writeString($kiter7);
  143. $xfer += $output->writeString($viter8);
  144. }
  145. }
  146. $output->writeMapEnd();
  147. }
  148. $xfer += $output->writeFieldEnd();
  149. }
  150. $xfer += $output->writeFieldStop();
  151. $xfer += $output->writeStructEnd();
  152. return $xfer;
  153. }
  154. }
  155. class ManualEnrolUsersArgsStruct {
  156. static $_TSPEC;
  157. public $roleid = null;
  158. public $userid = null;
  159. public $courseid = null;
  160. public $timestart = null;
  161. public $timeend = null;
  162. public $suspend = null;
  163. public function __construct($vals=null) {
  164. if (!isset(self::$_TSPEC)) {
  165. self::$_TSPEC = array(
  166. 1 => array(
  167. 'var' => 'roleid',
  168. 'type' => TType::I32,
  169. ),
  170. 2 => array(
  171. 'var' => 'userid',
  172. 'type' => TType::I32,
  173. ),
  174. 3 => array(
  175. 'var' => 'courseid',
  176. 'type' => TType::I32,
  177. ),
  178. 4 => array(
  179. 'var' => 'timestart',
  180. 'type' => TType::I32,
  181. ),
  182. 5 => array(
  183. 'var' => 'timeend',
  184. 'type' => TType::I32,
  185. ),
  186. 6 => array(
  187. 'var' => 'suspend',
  188. 'type' => TType::I32,
  189. ),
  190. );
  191. }
  192. if (is_array($vals)) {
  193. if (isset($vals['roleid'])) {
  194. $this->roleid = $vals['roleid'];
  195. }
  196. if (isset($vals['userid'])) {
  197. $this->userid = $vals['userid'];
  198. }
  199. if (isset($vals['courseid'])) {
  200. $this->courseid = $vals['courseid'];
  201. }
  202. if (isset($vals['timestart'])) {
  203. $this->timestart = $vals['timestart'];
  204. }
  205. if (isset($vals['timeend'])) {
  206. $this->timeend = $vals['timeend'];
  207. }
  208. if (isset($vals['suspend'])) {
  209. $this->suspend = $vals['suspend'];
  210. }
  211. }
  212. }
  213. public function getName() {
  214. return 'ManualEnrolUsersArgsStruct';
  215. }
  216. public function read($input)
  217. {
  218. $xfer = 0;
  219. $fname = null;
  220. $ftype = 0;
  221. $fid = 0;
  222. $xfer += $input->readStructBegin($fname);
  223. while (true)
  224. {
  225. $xfer += $input->readFieldBegin($fname, $ftype, $fid);
  226. if ($ftype == TType::STOP) {
  227. break;
  228. }
  229. switch ($fid)
  230. {
  231. case 1:
  232. if ($ftype == TType::I32) {
  233. $xfer += $input->readI32($this->roleid);
  234. } else {
  235. $xfer += $input->skip($ftype);
  236. }
  237. break;
  238. case 2:
  239. if ($ftype == TType::I32) {
  240. $xfer += $input->readI32($this->userid);
  241. } else {
  242. $xfer += $input->skip($ftype);
  243. }
  244. break;
  245. case 3:
  246. if ($ftype == TType::I32) {
  247. $xfer += $input->readI32($this->courseid);
  248. } else {
  249. $xfer += $input->skip($ftype);
  250. }
  251. break;
  252. case 4:
  253. if ($ftype == TType::I32) {
  254. $xfer += $input->readI32($this->timestart);
  255. } else {
  256. $xfer += $input->skip($ftype);
  257. }
  258. break;
  259. case 5:
  260. if ($ftype == TType::I32) {
  261. $xfer += $input->readI32($this->timeend);
  262. } else {
  263. $xfer += $input->skip($ftype);
  264. }
  265. break;
  266. case 6:
  267. if ($ftype == TType::I32) {
  268. $xfer += $input->readI32($this->suspend);
  269. } else {
  270. $xfer += $input->skip($ftype);
  271. }
  272. break;
  273. default:
  274. $xfer += $input->skip($ftype);
  275. break;
  276. }
  277. $xfer += $input->readFieldEnd();
  278. }
  279. $xfer += $input->readStructEnd();
  280. return $xfer;
  281. }
  282. public function write($output) {
  283. $xfer = 0;
  284. $xfer += $output->writeStructBegin('ManualEnrolUsersArgsStruct');
  285. if ($this->roleid !== null) {
  286. $xfer += $output->writeFieldBegin('roleid', TType::I32, 1);
  287. $xfer += $output->writeI32($this->roleid);
  288. $xfer += $output->writeFieldEnd();
  289. }
  290. if ($this->userid !== null) {
  291. $xfer += $output->writeFieldBegin('userid', TType::I32, 2);
  292. $xfer += $output->writeI32($this->userid);
  293. $xfer += $output->writeFieldEnd();
  294. }
  295. if ($this->courseid !== null) {
  296. $xfer += $output->writeFieldBegin('courseid', TType::I32, 3);
  297. $xfer += $output->writeI32($this->courseid);
  298. $xfer += $output->writeFieldEnd();
  299. }
  300. if ($this->timestart !== null) {
  301. $xfer += $output->writeFieldBegin('timestart', TType::I32, 4);
  302. $xfer += $output->writeI32($this->timestart);
  303. $xfer += $output->writeFieldEnd();
  304. }
  305. if ($this->timeend !== null) {
  306. $xfer += $output->writeFieldBegin('timeend', TType::I32, 5);
  307. $xfer += $output->writeI32($this->timeend);
  308. $xfer += $output->writeFieldEnd();
  309. }
  310. if ($this->suspend !== null) {
  311. $xfer += $output->writeFieldBegin('suspend', TType::I32, 6);
  312. $xfer += $output->writeI32($this->suspend);
  313. $xfer += $output->writeFieldEnd();
  314. }
  315. $xfer += $output->writeFieldStop();
  316. $xfer += $output->writeStructEnd();
  317. return $xfer;
  318. }
  319. }