26 _live_catalog =
nullptr;
35 _entries(copy._entries),
36 _entries_by_name(copy._entries_by_name),
37 _entries_by_field(copy._entries_by_field)
39 _live_catalog =
nullptr;
47 if (_live_catalog !=
nullptr) {
51 SwitchCatalogs::iterator si;
52 for (si = _switch_catalogs.begin(); si != _switch_catalogs.end(); ++si) {
64 EntriesByName::const_iterator ni;
65 ni = _entries_by_name.find(name);
66 if (ni != _entries_by_name.end()) {
79 EntriesByField::const_iterator ni;
80 ni = _entries_by_field.find(field);
81 if (ni != _entries_by_field.end()) {
97 if (_live_catalog !=
nullptr) {
100 return _live_catalog;
104 live_catalog->_catalog =
this;
105 live_catalog->_live_entries.reserve(_entries.size());
107 zero_entry._begin = 0;
109 for (
size_t i = 0; i < _entries.size(); i++) {
110 live_catalog->_live_entries.push_back(zero_entry);
117 r_fill_live_catalog(live_catalog, packer, last_switch);
145 if (live_catalog != _live_catalog) {
154 void DCPackerCatalog::
159 entry._field = field;
160 entry._parent = parent;
161 entry._field_index = field_index;
163 int entry_index = (int)_entries.size();
164 _entries.push_back(entry);
165 _entries_by_field.insert(EntriesByField::value_type(field, entry_index));
171 _entries_by_name[name] = entry_index;
177 string local_name = field->
get_name();
178 if (local_name != name) {
179 _entries_by_name.insert(EntriesByName::value_type(local_name, entry_index));
188 void DCPackerCatalog::
191 string next_name_prefix = name_prefix;
193 if (parent !=
nullptr && !field->
get_name().empty()) {
195 next_name_prefix += field->
get_name();
196 add_entry(next_name_prefix, field, parent, field_index);
198 next_name_prefix +=
".";
202 if (switch_parameter !=
nullptr) {
207 _switch_prefixes[switch_parameter] = next_name_prefix;
214 for (
int i = 0; i < num_nested; i++) {
216 if (nested !=
nullptr) {
217 r_fill_catalog(next_name_prefix, nested, field, i);
227 void DCPackerCatalog::
228 r_fill_live_catalog(LiveCatalog *live_catalog,
DCPacker &packer,
232 int field_index = live_catalog->find_entry_by_field(current_field);
233 if (field_index >= 0) {
234 nassertv(field_index < (
int)live_catalog->_live_entries.size());
242 r_fill_live_catalog(live_catalog, packer, last_switch);
250 if (field_index >= 0) {
260 nassertv(switch_case !=
nullptr);
262 live_catalog->_catalog->update_switch_fields(last_switch, switch_case);
263 nassertv(switch_catalog !=
nullptr);
264 live_catalog->_catalog = switch_catalog;
267 LiveCatalogEntry zero_entry;
268 zero_entry._begin = 0;
270 for (
size_t i = live_catalog->_live_entries.size();
271 i < switch_catalog->_entries.size();
273 live_catalog->_live_entries.push_back(zero_entry);
294 SwitchCatalogs::const_iterator si = _switch_catalogs.find(switch_case);
295 if (si != _switch_catalogs.end()) {
302 SwitchPrefixes::const_iterator pi = _switch_prefixes.find(switch_parameter);
303 if (pi == _switch_prefixes.end()) {
309 string name_prefix = (*pi).second;
320 for (
int i = 1; i < num_nested; i++) {
322 if (nested !=
nullptr) {
323 switch_catalog->r_fill_catalog(name_prefix, nested, switch_case, i);
329 ((
DCPackerCatalog *)
this)->_switch_catalogs[switch_case] = switch_catalog;
331 return switch_catalog;