00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "xFileArrayDef.h"
00016 #include "xFileDataDef.h"
00017 #include "xFileDataObject.h"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 int XFileArrayDef::
00030 get_size(const XFileNode::PrevData &prev_data) const {
00031 if (is_fixed_size()) {
00032 return _fixed_size;
00033 } else {
00034 XFileNode::PrevData::const_iterator pi;
00035 pi = prev_data.find(_dynamic_size);
00036 nassertr_always(pi != prev_data.end(), 0);
00037 nassertr((*pi).second != (XFileDataObject *)NULL, 0);
00038 return (*pi).second->i();
00039 }
00040 }
00041
00042
00043
00044
00045
00046
00047 void XFileArrayDef::
00048 output(ostream &out) const {
00049 if (is_fixed_size()) {
00050 out << "[" << _fixed_size << "]";
00051 } else {
00052 out << "[" << _dynamic_size->get_name() << "]";
00053 }
00054 }
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 bool XFileArrayDef::
00066 matches(const XFileArrayDef &other, const XFileDataDef *parent,
00067 const XFileDataDef *other_parent) const {
00068 if (other.is_fixed_size() != is_fixed_size()) {
00069 return false;
00070 }
00071 if (is_fixed_size()) {
00072 if (other.get_fixed_size() != get_fixed_size()) {
00073 return false;
00074 }
00075
00076 } else {
00077 int child_index = parent->find_child_index(get_dynamic_size());
00078 int other_child_index =
00079 other_parent->find_child_index(other.get_dynamic_size());
00080 if (other_child_index != child_index) {
00081 return false;
00082 }
00083 }
00084
00085 return true;
00086 }