Example #1
0
 public function encodeTable($name, $t, $render = null)
 {
     if ($this->output_format !== "copy") {
         $this->setFormat($this->output_format);
     }
     $txt = "";
     $this->checkFormat($name);
     if ($this->format_preference === "sqlite" && !$this->extern_preference) {
         $this->format_preference = "csv";
     }
     if ($render === null) {
         if ($this->format_preference === "csv") {
             $csv = new coopy_Csv($this->delim_preference);
             $txt = $csv->renderTable($t);
         } else {
             if ($this->format_preference === "ndjson") {
                 $txt = _hx_deref(new coopy_Ndjson($t))->render();
             } else {
                 if ($this->format_preference === "html" || $this->format_preference === "www") {
                     $this->renderTable($name, $t);
                 } else {
                     if ($this->format_preference === "sqlite") {
                         $this->io->writeStderr("! Cannot yet output to sqlite, aborting\n");
                         return "";
                     } else {
                         $value = coopy_Coopy::jsonify($t);
                         $txt = haxe_format_JsonPrinter::hprint($value, null, "  ");
                     }
                 }
             }
         }
     } else {
         $txt = $render->render($t);
     }
     return $txt;
 }