/ GetColumnValue: */ /
| 1859 | /* GetColumnValue: */ |
| 1860 | /***********************************************************************/ |
| 1861 | PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i) |
| 1862 | { |
| 1863 | PJAR arp; |
| 1864 | PJVAL val = NULL; |
| 1865 | |
| 1866 | for (; i < Nod && row; i++) { |
| 1867 | if (Nodes[i].Op == OP_NUM) { |
| 1868 | Value->SetValue(row->GetType() == TYPE_JAR ? ((PJAR)row)->size() : 1); |
| 1869 | return(Value); |
| 1870 | } else if (Nodes[i].Op == OP_XX) { |
| 1871 | return MakeJson(G, row, i); |
| 1872 | } else switch (row->GetType()) { |
| 1873 | case TYPE_JOB: |
| 1874 | if (!Nodes[i].Key) { |
| 1875 | // Expected Array was not there, wrap the value |
| 1876 | if (i < Nod-1) |
| 1877 | continue; |
| 1878 | else |
| 1879 | val = new(G) JVALUE(row); |
| 1880 | |
| 1881 | } else |
| 1882 | val = ((PJOB)row)->GetKeyValue(Nodes[i].Key); |
| 1883 | |
| 1884 | break; |
| 1885 | case TYPE_JAR: |
| 1886 | arp = (PJAR)row; |
| 1887 | |
| 1888 | if (!Nodes[i].Key) { |
| 1889 | if (Nodes[i].Op == OP_EQ) |
| 1890 | val = arp->GetArrayValue(Nodes[i].Rank); |
| 1891 | else if (Nodes[i].Op == OP_EXP) |
| 1892 | return ExpandArray(g, arp, i); |
| 1893 | else |
| 1894 | return CalculateArray(g, arp, i); |
| 1895 | |
| 1896 | } else { |
| 1897 | // Unexpected array, unwrap it as [0] |
| 1898 | val = arp->GetArrayValue(0); |
| 1899 | i--; |
| 1900 | } // endif's |
| 1901 | |
| 1902 | break; |
| 1903 | case TYPE_JVAL: |
| 1904 | val = (PJVAL)row; |
| 1905 | break; |
| 1906 | default: |
| 1907 | snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->GetType()); |
| 1908 | val = NULL; |
| 1909 | } // endswitch Type |
| 1910 | |
| 1911 | if (i < Nod-1) |
| 1912 | row = (val) ? val->GetJson() : NULL; |
| 1913 | |
| 1914 | } // endfor i |
| 1915 | |
| 1916 | SetJsonValue(g, Value, val); |
| 1917 | return Value; |
| 1918 | } // end of GetColumnValue |
nothing calls this directly
no test coverage detected