Writes a vector of (pointers to) classes to the given file. Assumes the existence of bool T::Serialize(FILE*) const that returns false in case of error. There is no Serialize for simple types, as you would have a normal GenericVector of those. Returns false in case of error.
| 512 | // normal GenericVector of those. |
| 513 | // Returns false in case of error. |
| 514 | bool Serialize(FILE* fp) const { |
| 515 | inT32 used = GenericVector<T*>::size_used_; |
| 516 | if (fwrite(&used, sizeof(used), 1, fp) != 1) return false; |
| 517 | for (int i = 0; i < used; ++i) { |
| 518 | inT8 non_null = GenericVector<T*>::data_[i] != NULL; |
| 519 | if (fwrite(&non_null, sizeof(non_null), 1, fp) != 1) return false; |
| 520 | if (non_null && !GenericVector<T*>::data_[i]->Serialize(fp)) return false; |
| 521 | } |
| 522 | return true; |
| 523 | } |
| 524 | bool Serialize(TFile* fp) const { |
| 525 | inT32 used = GenericVector<T*>::size_used_; |
| 526 | if (fp->FWrite(&used, sizeof(used), 1) != 1) return false; |