/ ReadDB: Data Base read routine for JSN access method. */ /
| 1120 | /* ReadDB: Data Base read routine for JSN access method. */ |
| 1121 | /***********************************************************************/ |
| 1122 | int TDBJSN::ReadDB(PGLOBAL g) { |
| 1123 | int rc; |
| 1124 | |
| 1125 | N++; |
| 1126 | |
| 1127 | if (NextSame) { |
| 1128 | SameRow = NextSame; |
| 1129 | NextSame = 0; |
| 1130 | M++; |
| 1131 | return RC_OK; |
| 1132 | } else if ((rc = TDBDOS::ReadDB(g)) == RC_OK) { |
| 1133 | if (!IsRead() && ((rc = ReadBuffer(g)) != RC_OK)) |
| 1134 | return rc; // Deferred reading failed |
| 1135 | |
| 1136 | if (Pretty >= 0) { |
| 1137 | // Recover the memory used for parsing |
| 1138 | PlugSubSet(G->Sarea, G->Sarea_Size); |
| 1139 | |
| 1140 | if ((Row = ParseJson(G, To_Line, strlen(To_Line), &Pretty, &Comma))) { |
| 1141 | Row = FindRow(g); |
| 1142 | SameRow = 0; |
| 1143 | Fpos++; |
| 1144 | M = 1; |
| 1145 | rc = RC_OK; |
| 1146 | } else if (Pretty != 1 || strcmp(To_Line, "]")) { |
| 1147 | safe_strcpy(g->Message, sizeof(g->Message), G->Message); |
| 1148 | rc = RC_FX; |
| 1149 | } else |
| 1150 | rc = RC_EF; |
| 1151 | |
| 1152 | } else { |
| 1153 | // Here we get a movable Json binary tree |
| 1154 | PJSON jsp; |
| 1155 | SWAP* swp; |
| 1156 | |
| 1157 | jsp = (PJSON)To_Line; |
| 1158 | swp = new(g) SWAP(G, jsp); |
| 1159 | swp->SwapJson(jsp, false); // Restore pointers from offsets |
| 1160 | Row = jsp; |
| 1161 | Row = FindRow(g); |
| 1162 | SameRow = 0; |
| 1163 | Fpos++; |
| 1164 | M = 1; |
| 1165 | rc = RC_OK; |
| 1166 | } // endif Pretty |
| 1167 | |
| 1168 | } // endif ReadDB |
| 1169 | |
| 1170 | return rc; |
| 1171 | } // end of ReadDB |
| 1172 | |
| 1173 | /***********************************************************************/ |
| 1174 | /* Make the top tree from the object path. */ |
no test coverage detected