updated to the new pikotools api: changed the way how child_spaces are created in Space class

This commit is contained in:
2021-05-21 17:17:17 +02:00
parent fe67b5d72a
commit f1b9d1b870
9 changed files with 277 additions and 262 deletions

View File

@@ -171,24 +171,18 @@ return false;
*/
pt::Space * find_ticket_param(long param_id, pt::Space & meta)
{
wchar_t param_id_str[50];
pt::Space::TableType * child_table = meta.find_child_space_table();
if( meta.child_spaces )
if( child_table )
{
// for performane
// should be a little faster in each loop comparing only just text
Toa(param_id, param_id_str, sizeof(param_id_str)/sizeof(wchar_t));
for(size_t i=0 ; i<meta.child_spaces->size() ; ++i)
for(pt::Space * sp : *child_table)
{
pt::Space & sp = *(*meta.child_spaces)[i];
if( sp.name && *sp.name == L"param" && sp.is_equal(L"id", param_id_str) )
return &sp;
if( sp->is_child_space_name(L"param") && sp->to_long(L"id") == param_id )
return sp;
}
}
return 0;
return nullptr;
}
@@ -249,15 +243,15 @@ size_t par_index;
void ticket_print_value_select(Info & i, TicketValue & value)
{
if( value.is_param && value.is_value && value.config_par->child_spaces )
if( value.is_param && value.is_value )
{
for(size_t a=0 ; a<value.config_par->child_spaces->size() ; ++a)
{
pt::Space & sp = *(*value.config_par->child_spaces)[a];
pt::Space::TableType * child_table = value.config_par->find_child_space_table();
if( sp.name && *sp.name == L"option" && sp.to_long(L"id") == value.ticket_par->intv )
for(pt::Space * sp : *child_table)
{
if( sp->is_child_space_name(L"option") && sp->to_long(L"id") == value.ticket_par->intv )
{
std::wstring * val = sp.get_wstr(L"value");
std::wstring * val = sp->get_wstr(L"value");
if( val )
i.out << *val;
@@ -336,22 +330,21 @@ void ticket_param_value_for_param_id(Info & i)
{
value_for_param_id.Clear();
size_t conf_index = 0;
pt::Space & space = *ticket_info.cur_conf;
int id = Toi(i.par);
if( space.child_spaces )
{
for( ; conf_index < space.child_spaces->size() ; ++conf_index)
{
pt::Space & sp = *(*space.child_spaces)[conf_index];
pt::Space::TableType * child_table = space.find_child_space_table();
if( sp.name && *sp.name == L"param" && sp.to_int(L"id") == id )
if( child_table )
{
for(pt::Space * sp : *child_table)
{
if( sp->is_child_space_name(L"param") && sp->to_int(L"id") == id )
{
value_for_param_id.Clear();
value_for_param_id.is_param = true;
value_for_param_id.config_par = &sp;
value_for_param_id.param_id = sp.to_long(L"id");
value_for_param_id.config_par = sp;
value_for_param_id.param_id = sp->to_long(L"id");
if( ticket_info.ticket && ticket_info.item )
{
@@ -371,24 +364,22 @@ void ticket_does_param_id_have_value(Info & i)
{
value_for_param_id.Clear();
size_t conf_index = 0;
pt::Space & space = *ticket_info.cur_conf;
pt::Space::TableType * child_table = space.find_child_space_table();
if( i.params.size() == 2 && space.child_spaces )
if( i.params.size() == 2 && child_table )
{
long id = Tol(i.params[0].str);
long id2 = Tol(i.params[1].str);
for( ; conf_index < space.child_spaces->size() ; ++conf_index)
for(pt::Space * sp : *child_table)
{
pt::Space & sp = *(*space.child_spaces)[conf_index];
if( sp.name && *sp.name == L"param" && sp.to_long(L"id") == id )
if( sp->is_child_space_name(L"param") && sp->to_long(L"id") == id )
{
value_for_param_id.Clear();
value_for_param_id.is_param = true;
value_for_param_id.config_par = &sp;
value_for_param_id.param_id = sp.to_long(L"id");
value_for_param_id.config_par = sp;
value_for_param_id.param_id = sp->to_long(L"id");
if( ticket_info.ticket && ticket_info.item )
{
@@ -637,23 +628,21 @@ void tickets_tab_param_value_for_param_id(Info & i)
if( tickets_value.is_ticket )
{
size_t param_index = 0;
pt::Space & space = *ticket_info.cur_conf;
long id = Tol(i.par);
if( space.child_spaces )
{
for( ; param_index < space.child_spaces->size() ; ++param_index)
{
pt::Space & sp = *(*space.child_spaces)[param_index];
pt::Space::TableType * child_table = space.find_child_space_table();
if( sp.name && *sp.name == L"param" &&
sp.to_long(L"id") == id )
if( child_table )
{
for(pt::Space * sp : *child_table)
{
if( sp->is_child_space_name(L"param") && sp->to_long(L"id") == id )
{
value_for_param_id.Clear();
value_for_param_id.is_param = true;
value_for_param_id.config_par = &sp;
value_for_param_id.param_id = sp.to_long(L"id");
value_for_param_id.config_par = sp;
value_for_param_id.param_id = sp->to_long(L"id");
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
ticket_print_value(i, value_for_param_id);
@@ -674,23 +663,22 @@ void tickets_tab_does_param_id_have_value(Info & i)
if( tickets_value.is_ticket && i.params.size() == 2 )
{
size_t param_index = 0;
pt::Space & space = *ticket_info.cur_conf;
long id = Toi(i.params[0].str);
long id2 = Toi(i.params[1].str);
if( space.child_spaces )
{
for( ; param_index < space.child_spaces->size() ; ++param_index)
{
pt::Space & sp = *(*space.child_spaces)[param_index];
pt::Space::TableType * child_table = space.find_child_space_table();
if( sp.name && *sp.name == L"param" && sp.to_long(L"id") == id )
if( child_table )
{
for(pt::Space * sp : *child_table)
{
if( sp->is_child_space_name(L"param") && sp->to_long(L"id") == id )
{
value_for_param_id.Clear();
value_for_param_id.is_param = true;
value_for_param_id.config_par = &sp;
value_for_param_id.param_id = sp.to_long(L"id");
value_for_param_id.config_par = sp;
value_for_param_id.param_id = sp->to_long(L"id");
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
@@ -725,24 +713,26 @@ void tickets_tab_conf_tab(Info & i)
conf_index = i.iter;
pt::Space & space = *ticket_info.cur_conf;
if( space.child_spaces )
{
while( conf_index < space.child_spaces->size() )
{
pt::Space & sp = *(*space.child_spaces)[conf_index];
pt::Space::TableType * child_table = space.find_child_space_table();
if( sp.name && *sp.name == L"param" )
if( child_table )
{
while( conf_index < child_table->size() )
{
pt::Space & sp = *(*child_table)[conf_index];
if( sp.is_child_space_name(L"param") )
break;
conf_index += 1;
}
i.res = conf_index < space.child_spaces->size();
i.res = conf_index < child_table->size();
if( i.res )
{
value.is_param = true;
value.config_par = (*space.child_spaces)[conf_index];
value.config_par = (*child_table)[conf_index];
value.param_id = value.config_par->to_long(L"id");
find_ticket_value(value, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
}
@@ -841,20 +831,21 @@ void tickets_tab_conf_tab_file_tab(Info & i)
tickets_file_number = 0;
pt::Space & mt = *value.value_meta;
pt::Space::TableType * child_table = mt.find_child_space_table();
if( mt.child_spaces )
if( child_table )
{
while( tickets_file_index < mt.child_spaces->size() )
while( tickets_file_index < child_table->size() )
{
pt::Space & sp = *(*mt.child_spaces)[tickets_file_index];
pt::Space & sp = *(*child_table)[tickets_file_index];
if( sp.name && *sp.name == L"file" )
if( sp.is_child_space_name(L"file") )
break;
tickets_file_index += 1;
}
i.res = (tickets_file_index < mt.child_spaces->size());
i.res = (tickets_file_index < child_table->size());
if( i.res && i.iter > 0 )
tickets_file_number += 1;
@@ -871,7 +862,7 @@ void tickets_tab_conf_tab_file_tab_index(Info & i)
{
pt::Space & mt = *value.value_meta;
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
if( mt.find_child_space(tickets_file_index) )
i.out << tickets_file_number;
}
}
@@ -885,9 +876,10 @@ void tickets_tab_conf_tab_file_tab_path(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space * sp = mt.find_child_space(tickets_file_index);
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
i.out << (*mt.child_spaces)[tickets_file_index]->to_wstr(L"path");
if( sp )
i.out << sp->to_wstr(L"path");
}
}
@@ -899,9 +891,10 @@ void tickets_tab_conf_tab_file_tab_itemid(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space * sp = mt.find_child_space(tickets_file_index);
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
i.out << (*mt.child_spaces)[tickets_file_index]->to_wstr(L"itemid");
if( sp )
i.out << sp->to_long(L"itemid");
}
}
@@ -913,9 +906,10 @@ void tickets_tab_conf_tab_file_tab_meta(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space * sp = mt.find_child_space(tickets_file_index);
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
space_value(i, *(*mt.child_spaces)[tickets_file_index]);
if( sp )
space_value(i, *sp);
}
}
@@ -954,26 +948,27 @@ void ticket_tab(Info & i)
value.Clear();
conf_index = i.iter;
pt::Space & space = *ticket_info.cur_conf;
pt::Space & space = *ticket_info.cur_conf; // CHECKME is ticket_info.cur_conf always set?
pt::Space::TableType * child_table = space.find_child_space_table();
if( space.child_spaces )
if( child_table )
{
while( conf_index < space.child_spaces->size() )
while( conf_index < child_table->size() )
{
pt::Space & sp = *(*space.child_spaces)[conf_index];
pt::Space & sp = *(*child_table)[conf_index];
if( sp.name && *sp.name == L"param" )
if( sp.is_child_space_name(L"param") )
break;
conf_index += 1;
}
i.res = conf_index < space.child_spaces->size();
i.res = conf_index < child_table->size();
if( i.res )
{
value.is_param = true;
value.config_par = (*space.child_spaces)[conf_index];
value.config_par = (*child_table)[conf_index];
value.param_id = value.config_par->to_long(L"id");
if( ticket_info.ticket && ticket_info.item )
@@ -1072,21 +1067,21 @@ void ticket_tab_select_tab(Info & i)
if( value.is_param )
{
select_index = i.iter;
pt::Space & sp = *value.config_par;
pt::Space::TableType * child_table = value.config_par->find_child_space_table();
if( sp.child_spaces )
if( child_table )
{
while( select_index < sp.child_spaces->size() )
while( select_index < child_table->size() )
{
pt::Space & sp_child = *(*sp.child_spaces)[select_index];
pt::Space & sp = *(*child_table)[select_index];
if( sp_child.name && *sp_child.name == L"option" )
if( sp.is_child_space_name(L"option") )
break;
select_index += 1;
}
i.res = (select_index < sp.child_spaces->size());
i.res = (select_index < child_table->size());
}
}
}
@@ -1098,13 +1093,13 @@ void ticket_tab_select_tab_is_selected(Info & i)
if( value.is_param )
{
pt::Space & sp = *value.config_par;
pt::Space::TableType * child_table = value.config_par->find_child_space_table();
if( sp.child_spaces && select_index < sp.child_spaces->size() )
if( child_table && select_index < child_table->size() )
{
pt::Space & sp_child = *(*sp.child_spaces)[select_index];
pt::Space & sp = *(*child_table)[select_index];
long id = sp_child.to_long(L"id");
long id = sp.to_long(L"id");
if( value.is_value )
{
@@ -1126,10 +1121,10 @@ void ticket_tab_select_tab_name(Info & i)
if( value.is_param )
{
pt::Space & sp = *value.config_par;
pt::Space * sp = value.config_par->find_child_space(select_index);
if( sp.child_spaces && select_index < sp.child_spaces->size() )
i.out << (*sp.child_spaces)[select_index]->to_wstr(L"value");
if( sp )
i.out << sp->to_wstr(L"value");
}
}
@@ -1140,10 +1135,10 @@ void ticket_tab_select_tab_id(Info & i)
if( value.is_param )
{
pt::Space & sp = *value.config_par;
pt::Space * sp = value.config_par->find_child_space(select_index);
if( sp.child_spaces && select_index < sp.child_spaces->size() )
i.out << (*sp.child_spaces)[select_index]->to_wstr(L"id");
if( sp )
i.out << sp->to_wstr(L"id");
}
}
@@ -1153,10 +1148,10 @@ void ticket_tab_select_tab_meta(Info & i)
if( value.is_param )
{
pt::Space & sp = *value.config_par;
pt::Space * sp = value.config_par->find_child_space(select_index);
if( sp.child_spaces && select_index < sp.child_spaces->size() )
space_value(i, *(*sp.child_spaces)[select_index]);
if( sp )
space_value(i, *sp);
}
}
@@ -1173,21 +1168,21 @@ void ticket_tab_file_tab(Info & i)
if( i.iter == 0 )
ticket_file_number = 0;
pt::Space & mt = *value.value_meta;
pt::Space::TableType * child_table = value.value_meta->find_child_space_table();
if( mt.child_spaces )
if( child_table )
{
while( ticket_file_index < mt.child_spaces->size() )
while( ticket_file_index < child_table->size() )
{
pt::Space & sp = *(*mt.child_spaces)[ticket_file_index];
pt::Space & sp = *(*child_table)[ticket_file_index];
if( sp.name && *sp.name == L"file" )
if( sp.is_child_space_name(L"file") )
break;
ticket_file_index += 1;
}
i.res = (ticket_file_index < mt.child_spaces->size());
i.res = (ticket_file_index < child_table->size());
if( i.res && i.iter > 0 )
ticket_file_number += 1;
@@ -1202,9 +1197,9 @@ void ticket_tab_file_tab_index(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space * sp = value.value_meta->find_child_space(ticket_file_index);
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
if( sp )
i.out << ticket_file_number;
}
}
@@ -1216,10 +1211,10 @@ void ticket_tab_file_tab_path(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space * sp = value.value_meta->find_child_space(ticket_file_index);
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
i.out << (*mt.child_spaces)[ticket_file_index]->to_wstr(L"path");
if( sp )
i.out << sp->to_wstr(L"path");
}
}
@@ -1229,10 +1224,10 @@ void ticket_tab_file_tab_itemid(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space * sp = value.value_meta->find_child_space(ticket_file_index);
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
i.out << (*mt.child_spaces)[ticket_file_index]->to_wstr(L"itemid");
if( sp )
i.out << sp->to_long(L"itemid");
}
}
@@ -1242,10 +1237,10 @@ void ticket_tab_file_tab_meta(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space * sp = value.value_meta->find_child_space(ticket_file_index);
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
space_value(i, *(*mt.child_spaces)[ticket_file_index]);
if( sp )
space_value(i, *sp);
}
}