| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2019 Ericsson Telecom AB // |
| // // |
| // All rights reserved. This program and the accompanying materials // |
| // are made available under the terms of the Eclipse Public License v2.0 // |
| // which accompanies this distribution, and is available at // |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // |
| /////////////////////////////////////////////////////////////////////////////// |
| // Clear XML namespace elements from source |
| // ----------------------------------------- |
| // For validation because if its contain namespace |
| // elements the validation produce a "Element 'Widgets': |
| // No matching global declaration available for |
| // the validation root." error. |
| |
| //========================================================================= |
| // DEFINES: setup different versions |
| //========================================================================= |
| // Version 3.48: change check the nested existence of iterator id {7.950767 / 1.185142} |
| #define VERSION_3 3.48 |
| |
| // Clear namespace elements from input |
| #define CLEAR_XML_NAMESPACE_ELEMENTS 1 |
| |
| // All DEBUG Actions enable or disabled |
| //#define KI_DEBUG_ACTIONS 1 |
| |
| // Use time measure |
| //#define USE_TIME_MEASURE 1 |
| |
| // Print memory usage |
| //#define PRINT_USED_MEMORY 1 |
| |
| // With XML check |
| // #define WITH_XML_CHECK 1 |
| |
| |
| #include "Universal_charstring.hh" |
| #include <sys/types.h> |
| #include <stdio.h> |
| #include <sstream> |
| #include "rapidxml.hh" |
| #include <algorithm> |
| /////////////////////////////////////////////////////////////////////////////// |
| // Override rapidxml: print [rapidxml_print.hpp:copy_and_expand_chars] |
| // for no conversion of <>'"& characters |
| /////////////////////////////////////////////////////////////////////////////// |
| namespace rapidxml |
| { |
| /////////////////////////////////////////////////////////////////////// |
| // Internal |
| //! \cond internal |
| namespace internal |
| { |
| /////////////////////////////////////////////////////////////////////////// |
| // Internal character operations |
| // Copy characters from given range to given output iterator and expand |
| // characters into references (< > ' " &) |
| template<class OutIt> |
| inline OutIt copy_and_expand_chars(const char *begin, const char *end, char noexpand, OutIt out) |
| { |
| while (begin != end) |
| *out++ = *begin++; |
| return out; |
| } |
| } |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| #include "rapidxml_print.hh" |
| #include "EPTF_CLL_UIHandler_GUIFunctions.hh" |
| #include "EPTF_CLL_DataSource_Definitions.hh" |
| #include "EPTF_CLL_DataSource_Functions.hh" |
| #include "EPTF_CLL_UIHandler_Definitions.hh" |
| #include "EPTF_CLL_UIHandler_WidgetFunctions.hh" |
| #include "EPTF_CLL_Variable_Definitions.hh" |
| #include "ttcn_ericsson_se_protocolModules_xtdp_xtdl.hh" |
| |
| #include <libxml/parser.h> |
| #include <libxml/xmlschemas.h> |
| #include <string.h> |
| |
| // ACTION macros -> |
| #ifdef KI_DEBUG_ACTIONS |
| #define ACTION_GUIFUNCTIONS(txt, args...) TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, txt, ## args); |
| #else |
| #define ACTION_GUIFUNCTIONS(txt, args...) no_action_in_guifunctions(txt); |
| #endif |
| #define ACTION_GUIFUNCTIONS_PERMANENT(txt, args...) TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, txt, ## args); // no_action_in_guifunctions(txt); |
| //#define ACTION_GUIFUNCTIONS_PERMANENT(txt, args...) no_action_in_guifunctions(txt); |
| #define NO_ACTION_GUIFUNCTIONS(txt, args...) no_action_in_guifunctions(txt); |
| |
| #ifdef USE_TIME_MEASURE |
| #define MB_OF_MEASURES 12 |
| #define START_MEASURE(pl_idx, pl_str) start_timer(&v_timer_measure_start[pl_idx], &v_tv_measure[pl_idx]); strcpy(&v_time_measure_str[pl_idx][0],pl_str); |
| #define STOP_MEASURE(pl_idx) stop_timer(&v_timer_measure_start[pl_idx], &v_tv_measure[pl_idx], &v_time_measure_diff_summ[pl_idx]); |
| #else |
| #define START_MEASURE(pl_idx, pl_str) ; |
| #define STOP_MEASURE(pl_idx) ; |
| #endif |
| |
| #define MAX_RESERVED_ITVALUES 2048 |
| #define MAX_RESERVED_REPLACE 1024 |
| #define MAX_RESERVED_ESCAPE 2048 |
| #define MAX_RESERVED_PARSE 1024 |
| |
| using namespace rapidxml; |
| using namespace internal; |
| |
| using namespace std; |
| using namespace EPTF__CLL__DataSource__Functions; |
| using namespace EPTF__CLL__UIHandler__WidgetFunctions; |
| using namespace EPTF__CLL__Variable__Definitions; |
| |
| namespace EPTF__CLL__UIHandler__WidgetFunctions { |
| |
| //========================================================================= |
| // External Variables [TTCN-3] |
| //========================================================================= |
| // EPTF_CLL_UIHandler_Definitions: |
| // ------------------------------- |
| // v_UIHandler_GUIFunctions_nofRunning_processExternalData_handlers |
| // - number of running processes counter used waiting for all process done |
| // ------------------------------- |
| // v_EPTF_UIHandler_WidgetFunctions_XTDP_XSD_filepath |
| // - validator XSD path if it its not empty: "" this is the validator XSD path. |
| // if empty, the validate process is not necessary. |
| |
| //========================================================================= |
| // External Functions [TTCN-3] |
| //========================================================================= |
| // EPTF_CLL_UIHandler_WidgetFunctions: |
| // ----------------------------------- |
| // f_EPTF_UIHandler_GUIFunctions_waitForProcessExternalData_handlers |
| // - wait for all non blocking data request process done |
| // ----------------------------------- |
| // f_EPTF_DataSource_getData_nonBlocking |
| // - non blocking get data function |
| |
| //========================================================================= |
| // Variables |
| //========================================================================= |
| |
| static bool v_EPTF_CLL_UIHandler_GUIFunctions_initialized = false; |
| // ------------------------------------------------------------------------------------ |
| // CONSTANTS [lifetime: END OF PROGRAM] |
| static const char c_xml_head[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; |
| static const char c_widgets_start[] = "<Widgets xmlns='http://ttcn.ericsson.se/protocolModules/xtdp/xtdl'>"; |
| static const char c_widgets_end[] = "</Widgets>"; |
| static const char c_xml_root_name[] = "Widgets"; |
| static const char c_xml_element[] = "element"; |
| static bool v_case_sensitive = true; |
| static const char c_str_iterator[] = "iterator"; |
| static const char c_str_metaiterator[] = "metaiterator"; |
| static const char c_str_externalvalue[] = "externalvalue"; |
| static const char c_str_condition[] = "condition"; |
| static const char c_str_insertif[] = "insertif"; |
| static const char c_str_element[] = "element"; |
| static const char c_str_id[] = "id"; |
| static const char c_str_ptcname[] = "ptcname"; |
| static const char c_str_source[] = "source"; |
| static const char c_str_params[] = "params"; |
| static const char c_str_dataparam[] = "dataparam"; |
| static const char c_str_name[] = "name"; |
| static const char c_str_value[] = "value"; |
| static const char c_str_negate[] = "negate"; |
| static const char c_str_true[] = "true"; |
| static const char c_str_metadata[] = "metadata"; |
| static const char c_str_offset_id[] = "offset_id"; |
| static const char c_str_orig_node_ptr[] = "orig_node_ptr"; |
| static const char c_str_orig_node_name[] = "orig_node_name"; |
| static const char c_str_orig_itvalues[] = "orig_itvalues"; |
| static const char c_xml_insert_name[] = "insert_node"; |
| static const char c_xml_delete_name[] = "delete_node"; |
| static const char c_str_TODO[] = "TODO"; |
| static const char c_str_empty[] = ""; |
| static const char c_str_replace_sign[] = "%"; |
| static const char c_str_replace_idx[] = "::idx"; |
| static const char c_str_replace_count[] = "::count"; |
| static const char c_str_replace_ref[] = "::ref"; |
| |
| static const char c_str_xml_version[] = "version"; |
| static const char c_str_xml_version_value[] = "1.0"; |
| static const char c_str_xml_encoding[] = "encoding"; |
| static const char c_str_xml_encoding_value[] = "UTF-8"; |
| static const char c_str_xml_standalone[] = "standalone"; |
| static const char c_str_xml_standalone_value[] = "yes"; |
| |
| static std::size_t v_size_root_name = 0; |
| static std::size_t v_size_iterator = 0; |
| static std::size_t v_size_metaiterator = 0; |
| static std::size_t v_size_externalvalue = 0; |
| static std::size_t v_size_condition = 0; |
| static std::size_t v_size_insertif = 0; |
| static std::size_t v_size_element = 0; |
| static std::size_t v_size_id = 0; |
| static std::size_t v_size_ptcname = 0; |
| static std::size_t v_size_source = 0; |
| static std::size_t v_size_params = 0; |
| static std::size_t v_size_dataparam = 0; |
| static std::size_t v_size_name = 0; |
| static std::size_t v_size_value = 0; |
| static std::size_t v_size_true = 0; |
| static std::size_t v_size_orig_node_ptr = 0; |
| static std::size_t v_size_orig_node_name = 0; |
| static std::size_t v_size_orig_itvalues = 0; |
| static std::size_t v_size_xml_insert_name = 0; |
| static std::size_t v_size_xml_delete_name = 0; |
| static std::size_t v_size_offset_id = 0; |
| |
| |
| // Temporary attributes |
| static const char * v_temp_attributes[] = { c_str_orig_node_ptr, |
| c_str_orig_node_name, |
| c_str_orig_itvalues, |
| c_str_offset_id}; |
| |
| // Temporary attributes length |
| static std::size_t * v_temp_attributes_size[] = { &v_size_orig_node_ptr, |
| &v_size_orig_node_name, |
| &v_size_orig_itvalues, |
| &v_size_offset_id}; |
| |
| // REAL Variables |
| // ------------------------------------------------------------------------------------ |
| // Iterator ID index [lifetime: reset_XML] |
| static int v_iterator_idx = 0; |
| |
| // MAIN DATABASE |
| // ============================================ |
| // Document [rapidxml] |
| static xml_document<> v_doc; |
| // Playlist document [rapidxml] |
| static xml_document<> v_playlist_doc; |
| |
| // For XML parts |
| static vector<char *> v_xmlStrs; |
| #ifdef PRINT_USED_MEMORY |
| static long v_lastXmlStrs_length = 0; |
| static long v_xmlStrs_length = 0; |
| #endif |
| // For variable data |
| static vector<variable_data> v_variableData; |
| // variable data map |
| static map<long, int> v_variableDataMap; |
| // variable data map OFFSET ID |
| static long v_variableDataMapOffsetID; |
| |
| // widget id map for BASE nodes TO doc OR playlist_doc |
| static map<string, xml_node<> *> v_widgetIDMap; |
| // clone widget id map for nodes in clone_doc |
| static map<string, node_parent> v_cloneWidgetIDMap; |
| // playlist widget id map for nodes TO playlist_doc |
| static map<string, playlist_data> v_playlistWidgetIDMap; |
| // Playlist item idx |
| int v_playlistIdx = 0; |
| |
| // ------------------------------------------------------------------------------------ |
| // root and clone root node // [lifetime: for test only] |
| /* TIME DEBUG DATA */ |
| #ifdef USE_TIME_MEASURE |
| static clock_t v_timer_full_start; |
| static struct timeval v_tv_full; |
| static double v_time_full_diff_summ = 0.0; |
| static clock_t v_timer_process_start; |
| static struct timeval v_tv_process; |
| static double v_time_process_diff_summ = 0.0; |
| static clock_t v_timer_measure_start[MB_OF_MEASURES]; |
| static struct timeval v_tv_measure[MB_OF_MEASURES]; |
| static double v_time_measure_diff_summ[MB_OF_MEASURES]; |
| static char v_time_measure_str[MB_OF_MEASURES][256]; |
| #endif |
| |
| |
| |
| |
| //========================================================================= |
| // Functions |
| //========================================================================= |
| |
| /////////////////////////////////////////////////////////// |
| // Function: init_XML |
| // |
| // Purpose: |
| // Initializes the XML parser |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Initialize the parser variables. |
| // |
| /////////////////////////////////////////////////////////// |
| void init_XML(void) |
| { |
| ACTION_GUIFUNCTIONS("init_XML - v_EPTF_CLL_UIHandler_GUIFunctions_initialized[%d]", v_EPTF_CLL_UIHandler_GUIFunctions_initialized); |
| if(v_EPTF_CLL_UIHandler_GUIFunctions_initialized == false) { |
| // Init size variables for quick comparison |
| v_size_root_name = measure(c_xml_root_name); |
| v_size_iterator = measure(c_str_iterator); |
| v_size_metaiterator = measure(c_str_metaiterator); |
| v_size_externalvalue = measure(c_str_externalvalue); |
| v_size_condition = measure(c_str_condition); |
| v_size_insertif = measure(c_str_insertif); |
| v_size_element = measure(c_str_element); |
| v_size_id = measure(c_str_id); |
| v_size_ptcname = measure(c_str_ptcname); |
| v_size_source = measure(c_str_source); |
| v_size_params = measure(c_str_params); |
| v_size_dataparam = measure(c_str_dataparam); |
| v_size_name = measure(c_str_name); |
| v_size_value = measure(c_str_value); |
| v_size_true = measure(c_str_true); |
| v_size_orig_node_ptr = measure(c_str_orig_node_ptr); |
| v_size_orig_node_name = measure(c_str_orig_node_name); |
| v_size_orig_itvalues = measure(c_str_orig_itvalues); |
| v_size_xml_insert_name = measure(c_xml_insert_name); |
| v_size_xml_delete_name = measure(c_xml_delete_name); |
| v_size_offset_id = measure(c_str_offset_id); |
| |
| // [lifetime: reset_XML] |
| // Reset number of running processes external variable |
| v_iterator_idx = 0; // Iterator ID index |
| // RapidXML documents |
| v_doc.clear(); |
| v_playlist_doc.clear(); |
| if(init_xml_doc(&v_playlist_doc) == false) { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: The Playlist XML doc cannot be loaded!"); |
| } |
| v_xmlStrs.clear(); // For xml strings |
| #ifdef PRINT_USED_MEMORY |
| v_xmlStrs_length = 0; |
| #endif |
| v_variableData.clear(); // For variable data |
| v_variableDataMap.clear(); // variable data map |
| v_variableDataMapOffsetID = 0l; // variable data map OFFSET ID |
| v_widgetIDMap.clear(); // widget id map |
| v_playlistWidgetIDMap.clear(); // playlist widget id map |
| v_playlistIdx = 0; // Playlist item idx |
| |
| // [lifetime: expand_XML() or refreshed_XML_forNode()] |
| v_cloneWidgetIDMap.clear(); // clone widget id map |
| v_EPTF_CLL_UIHandler_GUIFunctions_initialized = true; |
| } |
| return; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: cleanup_XML |
| // |
| // Purpose: |
| // cleanup the XML parser |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // cleanup the XML parser variables. |
| // |
| /////////////////////////////////////////////////////////// |
| void cleanup_XML(void) { |
| ACTION_GUIFUNCTIONS("cleanup_XML - v_EPTF_CLL_UIHandler_GUIFunctions_initialized[%d]", v_EPTF_CLL_UIHandler_GUIFunctions_initialized); |
| if(v_EPTF_CLL_UIHandler_GUIFunctions_initialized == true){ |
| // Reset all data |
| reset_XML(); |
| v_playlist_doc.clear(); |
| v_EPTF_CLL_UIHandler_GUIFunctions_initialized = false; |
| } |
| return; |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: reset_XML |
| // |
| // Purpose: |
| // reset the full XML document |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // reset the full XML document. |
| // |
| /////////////////////////////////////////////////////////// |
| void reset_XML(void) { |
| ACTION_GUIFUNCTIONS("reset_XML[v_widgetIDMap.size() | v_variableDataMap.size() | v_cloneWidgetIDMap.size() = %d | %d | %d]", (int)v_widgetIDMap.size(), (int)v_variableDataMap.size(), (int)v_cloneWidgetIDMap.size()); |
| // [lifetime: reset_XML] |
| v_iterator_idx = 0; // Iterator ID index |
| // For xml strings |
| for(unsigned int vl_idx=0; vl_idx< v_xmlStrs.size(); vl_idx++){ |
| ACTION_GUIFUNCTIONS("reset_XML - v_xmlStrs[%d]->%s",vl_idx, v_xmlStrs[vl_idx]); |
| free(v_xmlStrs[vl_idx]); |
| v_xmlStrs[vl_idx] = 0; |
| } |
| v_xmlStrs.clear(); |
| #ifdef PRINT_USED_MEMORY |
| v_xmlStrs_length = 0; |
| #endif |
| // Clear variable data and variable data map |
| clear_variable_data(); |
| v_widgetIDMap.clear(); // widget id map |
| v_playlistWidgetIDMap.clear(); // playlist widget id map |
| v_playlistIdx = 0; // Playlist item idx |
| |
| #ifdef KI_DEBUG_ACTIONS |
| // For v_cloneWidgetIDMap |
| for(std::map<string, node_parent>::iterator vl_node_map = v_cloneWidgetIDMap.begin(); vl_node_map != v_cloneWidgetIDMap.end(); vl_node_map++) { |
| node_parent vl_node_parent = vl_node_map->second; |
| ACTION_GUIFUNCTIONS("reset_XML - v_cloneWidgetIDMap[%s]->%ld : %ld : %d", vl_node_map->first.c_str(), vl_node_parent.node_offset_id, vl_node_parent.parent_offset_node_id, (int)vl_node_parent.iterator_like ); |
| } |
| #endif |
| v_cloneWidgetIDMap.clear(); // clone widget id map |
| |
| // Clear DOCUMENTS |
| v_doc.clear(); |
| v_playlist_doc.clear(); |
| if(init_xml_doc(&v_playlist_doc) == false) { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: The Playlist XML doc cannot be loaded!"); |
| } |
| return; |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: reset_clone_XML |
| // |
| // Purpose: |
| // reset the clone XML document |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // reset the clone XML document. |
| // |
| /////////////////////////////////////////////////////////// |
| void reset_clone_XML(void){ |
| ACTION_GUIFUNCTIONS("reset_clone_XML[v_widgetIDMap.size() | v_variableDataMap.size() | v_cloneWidgetIDMap.size() = %d | %d | %d]", (int)v_widgetIDMap.size(), (int)v_variableDataMap.size(), (int)v_cloneWidgetIDMap.size()); |
| // [lifetime: reset_XML] |
| v_iterator_idx = 0; // Iterator ID index |
| |
| // Clear variable data and variable data map |
| clear_variable_data(); |
| #ifdef KI_DEBUG_ACTIONS |
| // For v_cloneWidgetIDMap |
| for(std::map<string, node_parent>::iterator vl_node_map = v_cloneWidgetIDMap.begin(); vl_node_map != v_cloneWidgetIDMap.end(); vl_node_map++) { |
| node_parent vl_node_parent = vl_node_map->second; |
| ACTION_GUIFUNCTIONS("reset_clone_XML - v_cloneWidgetIDMap[%s]->%ld : %ld : %d", vl_node_map->first.c_str(), vl_node_parent.node_offset_id, vl_node_parent.parent_offset_node_id, (int)vl_node_parent.iterator_like ); |
| } |
| #endif |
| v_cloneWidgetIDMap.clear(); // clone widget id map |
| return; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: expand_XML |
| // |
| // Purpose: |
| // Expand XML conditional, iterator, external value elements |
| // |
| // Parameters: |
| // pl_xml - *in* *charstring* - the input xul XML |
| // pl_parentWidgetID - *in* *charstring* - the parent widget ID |
| // pl_expandedXML - *out* *charstring* - the expanded XML string |
| // |
| // Return Value: |
| // Returns the result of validation and process. |
| // pl_expandedXML - *out* *charstring* - the expanded XML string |
| // |
| // Errors: |
| // - The XML invalid[<error code>] : {<xml string>} |
| // - NO root element in the XML : {<xml string>} |
| // - is_valid_XML: The XML doc cannot be loaded or is not well-formed: {<xml string>}! |
| // - is_valid_XML: The root element in the xml is '<act root>' instead of 'Widgets'! |
| // - is_valid_XML: The the schema cannot be loaded or is not well-formed[<schema filename>]! |
| // - is_valid_XML: The schema patch [<xsd:element name="Widgets" />] invalid! |
| // - is_valid_XML: Unable to create a parser context for the schema[<schema filename>]! |
| // - is_valid_XML: The schema itself is not valid[<schema filename>]! |
| // - is_valid_XML: unable to create a validation context for the schema[<schema filename>]! |
| // - is_valid_XML: Invalid XML {<xml string>} with schema [<schema filename>] - message: <error_message>! |
| // - get_data_parameters: unknown attribute [<attribute name>=<attribute value>]! |
| // - get_data_parameters: invalid call!"); |
| // |
| // Detailed Comments: |
| // Load XML string into rapidXML document. Validate it if |
| // v_EPTF_UIHandler_WidgetFunctions_XTDP_XSD_filepath XSD path are set. |
| // Append physical PTRs into entities "orig_node_ptr" Clone the XML document |
| // than expand all iterator, condition and externalvalue elements using |
| // f_EPTF_DataSource_getData_nonBlocking external function. |
| // |
| /////////////////////////////////////////////////////////// |
| bool expand_XML(const CHARSTRING& pl_xml, const CHARSTRING& pl_parentWidgetID, CHARSTRING& pl_expandedXML) |
| { |
| #ifdef USE_TIME_MEASURE |
| reset_timer(); |
| start_timer(&v_timer_full_start, &v_tv_full); |
| #endif |
| bool vl_ret = true; |
| int vl_validity = VALID_XML; |
| // root and clone root node // [lifetime: temporary] |
| xml_node<> * vl_root_node = v_doc.first_node(); |
| xml_document<> vl_clone_doc; // Clone document [rapidxml] |
| vl_clone_doc.clear(); |
| xml_node<> * vl_clone_root_node = vl_clone_doc.first_node(); |
| process_data vl_process_data; |
| vl_process_data.ITValuesMapsVector.clear(); |
| vl_process_data.checkWidgetIDMapLastRun.clear(); |
| vl_process_data.cloneDocPTR = &vl_clone_doc; |
| vl_process_data.waitforIdx = EPTF__CLL__UIHandler__Definitions::EPTF__UIHandler__Private__CT_component_v__UIHandler__GUIFunctions__nofRunning__processExternalData__handlers.size_of(); |
| EPTF__CLL__UIHandler__Definitions::EPTF__UIHandler__Private__CT_component_v__UIHandler__GUIFunctions__nofRunning__processExternalData__handlers[vl_process_data.waitforIdx] = 0; |
| ACTION_GUIFUNCTIONS("expand_XML[PRE:init_XML] {v_size_iterator:%d} {v_variableData.size():%d}vl_clone_doc:%ld", (int)v_size_iterator, (int)v_variableData.size(),(unsigned long)vl_process_data.cloneDocPTR); |
| init_XML(); |
| pl_expandedXML = CHARSTRING(""); |
| |
| // copy because XML parser are modify it |
| char * vl_cstr_in = (char *)((const char *)pl_xml); |
| // Search start |
| while(*vl_cstr_in!='\0' && *vl_cstr_in!='<'){ vl_cstr_in++; }; |
| char * vl_cstr = strdup_internal(vl_cstr_in); |
| char * vl_parentID = strdup_internal((const char *)pl_parentWidgetID); |
| bool vl_no_parent = false; // Have parent flag |
| #ifdef PRINT_USED_MEMORY |
| v_lastXmlStrs_length = strlen(vl_cstr); |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"expand_XML[START:v_xmlStrs] - [%s]: + {%s}",vl_parentID,vl_cstr); |
| #endif |
| ACTION_GUIFUNCTIONS("expand_XML[START:v_xmlStrs] - (%ld)*[%s]: + {%s}",(unsigned long)&vl_process_data,vl_parentID,vl_cstr); |
| #ifdef CLEAR_XML_NAMESPACE_ELEMENTS |
| clear_namespace_elements(vl_cstr); // Clear unhandled namespace elements |
| #endif |
| // If have parent id |
| if(*vl_parentID != '\0'){ |
| // and have window in XML |
| if(strstr(vl_cstr,"<window")) { |
| // The parent are the main document -> no parent ID |
| *vl_parentID = '\0'; |
| } |
| } |
| |
| // If no parent -> Reset and set act_doc |
| if(*vl_parentID == '\0') { |
| reset_XML(); |
| vl_no_parent = true; |
| } |
| #ifdef KI_DEBUG_ACTIONS |
| std::string vl_xml_out_doc_as_string_in; |
| rapidxml::print(std::back_inserter(vl_xml_out_doc_as_string_in), v_playlist_doc); |
| ACTION_GUIFUNCTIONS("expand_XML[v_playlist_doc:IN]{%s}",(char *)((const char *)vl_xml_out_doc_as_string_in.c_str())); |
| #endif |
| |
| // If no parent |
| if(vl_no_parent == true) { |
| // Parse full document |
| // ----------------------------------------------------------------------------------------------------- |
| // Validate the XML |
| const char * vl_XSD_filepath = (const char *)EPTF__CLL__UIHandler__Definitions::EPTF__UIHandler__Private__CT_component_v__EPTF__UIHandler__WidgetFunctions__XTDP__XSD__filepath; |
| ACTION_GUIFUNCTIONS("expand_XML[INPUT] (%s} -> {%s}", vl_XSD_filepath, vl_cstr); |
| // If XSD file path are set |
| if(vl_XSD_filepath != 0 && *vl_XSD_filepath != '\0'){ |
| vl_validity = is_valid_XML(vl_cstr, vl_XSD_filepath); |
| } |
| if(vl_validity != VALID_XML) { |
| vl_ret = false; |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: The XML invalid[%d] : {%s}", vl_validity, (const char *)pl_xml); |
| } else { |
| // Load XML into rapidxml doc |
| ACTION_GUIFUNCTIONS("expand_XML[Load XML into rapidxml doc]"); |
| try { |
| v_doc.parse<parse_no_entity_translation>(vl_cstr); |
| ACTION_GUIFUNCTIONS("expand_XML[Load XML into rapidxml doc] try(%ld)",(long)v_doc.first_node()); |
| vl_root_node = v_doc.first_node(); |
| } catch (rapidxml::parse_error &e) { // int vl_err |
| ACTION_GUIFUNCTIONS("expand_XML[Load XML into rapidxml doc] catch(%s)",e.what()); |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: The XML doc cannot be loaded or is not well-formed: {%s}!", e.what()); |
| vl_root_node = NULL; |
| vl_validity = ERROR_XML_LOAD; |
| } |
| if(vl_root_node == NULL){ |
| vl_ret = false; |
| if(vl_validity == VALID_XML) { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: NO root element in the XML : {%s}", (const char *)pl_xml); |
| } |
| } else { |
| // Map the nodes |
| append_node_ptrs(&v_doc, &vl_process_data, vl_root_node); |
| action_print_node("expand_XML - v_doc {%s}",vl_root_node); |
| // Clone the document -> |
| // copy whole tree into second tree, which will contain metaiterators and the children expanded according the values of the iterator |
| ACTION_GUIFUNCTIONS("expand_XML[CLONE:START]"); |
| vl_clone_root_node = vl_clone_doc.clone_node(vl_root_node); |
| vl_clone_doc.append_node(vl_clone_root_node); |
| |
| vl_clone_root_node = vl_clone_doc.first_node(); |
| ACTION_GUIFUNCTIONS("expand_XML[CLONE:END]->expand_XML_elements:START"); |
| // Expand XML elements |
| expand_XML_elements( vl_clone_root_node , &vl_process_data, 0l); |
| ACTION_GUIFUNCTIONS("expand_XML{f__EPTF__UIHandler__GUIFunctions__waitForProcessExternalData__handlers:CALL}"); |
| // Wait for all data processed |
| f__EPTF__UIHandler__GUIFunctions__waitForProcessExternalData__handlers(vl_process_data.waitforIdx); |
| |
| // remove debug and ptr attributes |
| vl_clone_root_node = vl_clone_doc.first_node(); |
| action_print_node("expand_XML - v_playlist_doc.out_process_for_metaiterators{start} {%s}",vl_clone_root_node); |
| out_process_for_metaiterators(vl_process_data.cloneDocPTR , vl_clone_root_node, (xml_node<>*) 0); |
| vl_clone_root_node = vl_clone_doc.first_node(); |
| action_print_node("expand_XML - v_playlist_doc.out_process_for_metaiterators{END} {%s}",vl_clone_root_node); |
| ACTION_GUIFUNCTIONS("expand_XML{out_process_for_metaiterators:END}"); |
| std::string vl_xml_out_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_out_as_string), vl_clone_doc); |
| pl_expandedXML = CHARSTRING((char *) vl_xml_out_as_string.c_str()); |
| } |
| } |
| } else { |
| // Insert XML |
| // ----------------------------------------------------------------------------------------------------- |
| variable_data vl_var_data_local; |
| variable_data * vl_var_data_ptr = 0; |
| variable_data * vl_var_parent_data_ptr = 0; |
| xml_node<> * vl_orig_node_ptr = 0; |
| xml_node<> * vl_node_dest = 0; // Destination node |
| std::map<string, node_parent>::iterator vl_node_map = v_cloneWidgetIDMap.find(vl_parentID); |
| ACTION_GUIFUNCTIONS("expand_XML - Insert XML - v_cloneWidgetIDMap[FIND:{%s}]", vl_parentID); |
| print_variableData("expand_XML[Insert XML]"); |
| if(vl_node_map != v_cloneWidgetIDMap.end()) { |
| node_parent vl_node_parent = vl_node_map->second; |
| if(init_xml_doc(&vl_clone_doc) == false) { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: The Clone XML doc cannot be loaded!"); |
| } |
| vl_node_dest = vl_clone_doc.first_node(); |
| vl_orig_node_ptr = vl_node_parent.orig_node_ptr; |
| // Find node ID |
| std::map<long, int>::iterator vl_data_map = v_variableDataMap.find(vl_node_parent.node_offset_id); |
| // iterator item |
| if(vl_data_map != v_variableDataMap.end() && vl_data_map->second<(int)v_variableData.size()) { |
| vl_var_data_ptr = &v_variableData[vl_data_map->second]; |
| } |
| if(vl_node_parent.parent_offset_node_id != 0) { |
| vl_data_map = v_variableDataMap.find(vl_node_parent.parent_offset_node_id); |
| vl_orig_node_ptr = vl_node_parent.orig_node_ptr; |
| // normal data item -> parent iterator |
| if(vl_data_map != v_variableDataMap.end() && vl_data_map->second<(int)v_variableData.size()) { |
| vl_var_parent_data_ptr = &v_variableData[vl_data_map->second]; |
| } |
| } |
| // Normal item and no parent iterator |
| if(vl_var_parent_data_ptr == 0 && vl_var_data_ptr == 0) { |
| ACTION_GUIFUNCTIONS("expand_XML - Normal item and no parent iterator"); |
| vl_orig_node_ptr = vl_node_parent.orig_node_ptr; |
| vl_var_data_local.node_offset_id = vl_node_parent.node_offset_id; // Node OFFSET ID |
| vl_var_data_local.orig_node_ptr = 0; // Original Node PTR |
| vl_var_data_local.orig_node_name = (char *)c_str_empty; // Original Node Name |
| vl_var_data_local.widget_id = (char *)vl_parentID; // Node Widget ID |
| vl_var_data_local.local_var_idx = -1; // Local Variable Index |
| vl_var_data_local.remote_var_name = (char *)c_str_empty; // Remote Variable Name |
| vl_var_data_local.it_values_list.clear(); // IT Values List |
| vl_var_data_local.deleted = false; |
| vl_var_parent_data_ptr = &vl_var_data_local; |
| } |
| } |
| action_print_node("expand_XML - vl_node_parent.orig_node_ptr {%s}",vl_orig_node_ptr); |
| if(vl_var_parent_data_ptr == 0 && vl_var_data_ptr == 0){ |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "WARNING: Widget ID not found : {%s}:%ld:%ld!", (const char *)vl_parentID, (long)vl_var_parent_data_ptr, (long)vl_var_data_ptr); |
| } else { |
| if(vl_var_data_ptr != 0) { |
| } |
| if(vl_var_parent_data_ptr != 0) { |
| } |
| if(vl_var_parent_data_ptr == 0) { |
| vl_var_parent_data_ptr = vl_var_data_ptr; |
| } |
| // No error: Insert |
| ACTION_GUIFUNCTIONS("expand_XML - parse document{%s}", vl_cstr); |
| // 1. parse document [rapidxml] |
| xml_document<> vl_print_doc; |
| xml_node<> * v_print_root_node = 0; |
| vl_print_doc.clear(); |
| |
| try { |
| vl_print_doc.parse<parse_no_entity_translation>(vl_cstr); |
| v_print_root_node = vl_print_doc.first_node(); |
| // new append |
| if (compare_name(v_print_root_node->name(),measure(v_print_root_node->name()), c_xml_root_name, v_size_root_name)) { |
| v_print_root_node = v_print_root_node->first_node(); |
| } |
| } catch (int vl_err) { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: The XML doc cannot be loaded or is not well-formed: {%d}!", vl_err); |
| v_print_root_node = NULL; |
| } |
| if(v_print_root_node == NULL){ |
| vl_ret = false; |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: NO root element in the XML : {%s}", (const char *)pl_xml); |
| } else { |
| vector< xml_node<> * > vl_nodelist; |
| vl_nodelist.clear(); |
| // 2. If its single node add to base v_doc, if depend from previous iterator into playlist v_playlist_doc |
| xml_node<>* vl_node_source = 0; |
| char * vl_orig_node_id = vl_var_parent_data_ptr->widget_id; |
| if(vl_orig_node_ptr!=0) { |
| vl_orig_node_id = get_attribute(vl_orig_node_ptr, (char *)c_str_id); |
| } |
| // Base item: Change original items |
| // ------------------------------------------------------ |
| if(strchr(vl_orig_node_id, '%')==0) { |
| // remove original data |
| vl_node_source = vl_orig_node_ptr; |
| if(vl_node_source == 0){ |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: The Orig node PTR not found[base] {%s}!", vl_parentID); |
| } else { |
| xml_node<> * vl_parent_node = vl_orig_node_ptr->parent(); |
| xml_node<> * vl_prev_node = 0; |
| // Copy child nodes and attributes |
| // 2013.11.07. - new append |
| { |
| vl_parent_node = vl_node_source; |
| // Just insert into |
| for (xml_node<> * vl_child = v_print_root_node; vl_child; vl_child = vl_child->next_sibling()){ |
| vl_node_source = v_doc.clone_node(vl_child); |
| vl_nodelist.push_back(vl_node_source); |
| vl_parent_node->insert_node(vl_prev_node, vl_node_source); |
| // 3. Map the nodes: append_node_ptrs |
| append_node_ptrs(&v_doc, &vl_process_data, vl_node_source); |
| action_print_node("expand_XML - v_doc[vl_node_source] {%s}",vl_node_source); |
| } |
| } |
| } |
| } else { |
| // ITS dynamical -> playlist |
| // Its depend from previous iterator: Insert into playlist document. Under the process when ID are available -> |
| // ------------------------------------------------------------------------------------------------------------- |
| // Insert into playlist |
| // check if its in playlist -> than change, or delete |
| vl_root_node = v_playlist_doc.first_node(); |
| // If no error |
| if(vl_root_node != 0) { |
| xml_node<> * vl_node = 0; |
| // check if exist |
| std::map<std::string, playlist_data>::iterator vl_playlist_map = v_playlistWidgetIDMap.find(std::string(vl_parentID)); |
| if(vl_playlist_map != v_playlistWidgetIDMap.end()) { |
| playlist_data vl_playlist = vl_playlist_map->second; |
| vl_node = vl_playlist.playlist_node_ptr; |
| vl_node->remove_all_nodes(); |
| // Clone name and value |
| vl_node->name(c_xml_insert_name, v_size_xml_insert_name); |
| } else { |
| // Append the insert node item e |
| vl_node = v_playlist_doc.allocate_node(node_element, c_xml_insert_name); |
| char * vl_ptrbuff = v_playlist_doc.allocate_string(vl_parentID); |
| vl_node->append_attribute(v_playlist_doc.allocate_attribute(c_str_id, vl_ptrbuff)); |
| vl_root_node->append_node(vl_node); |
| // playlist widget id map |
| playlist_data vl_playlist; |
| vl_playlist.playlist_node_ptr = vl_node; |
| vl_playlist.idx = v_playlistIdx++; |
| // If have erease it |
| std::map<string, playlist_data>::iterator vl_node_check_map = v_playlistWidgetIDMap.find(std::string(vl_parentID)); |
| if(vl_node_check_map != v_playlistWidgetIDMap.end()) { |
| v_playlistWidgetIDMap.erase(std::string(vl_parentID)); |
| } |
| v_playlistWidgetIDMap.insert(std::make_pair(std::string(vl_parentID), vl_playlist)); |
| ACTION_GUIFUNCTIONS("expand_XML - v_playlistWidgetIDMap.insert{%s}->%ld", vl_parentID, (long)vl_node); |
| } |
| |
| // Copy child nodes and attributes |
| vl_node_source = v_playlist_doc.clone_node(v_print_root_node); |
| vl_node->append_node(vl_node_source); |
| vl_nodelist.push_back(vl_node_source); |
| // 3. Map the nodes: append_node_ptrs |
| append_node_ptrs(&v_playlist_doc, &vl_process_data, vl_node_source); |
| action_print_node("expand_XML - v_playlist_doc[vl_node_source] {%s}",vl_node_source); |
| // If have more |
| for (xml_node<> * vl_child = v_print_root_node->next_sibling(); vl_child; vl_child = vl_child->next_sibling()){ |
| vl_node_source = v_playlist_doc.clone_node(vl_child); |
| vl_node->append_node(vl_node_source); |
| // 3. Map the nodes: append_node_ptrs |
| append_node_ptrs(&v_playlist_doc, &vl_process_data, vl_node_source); |
| vl_nodelist.push_back(vl_node_source); |
| } |
| vl_root_node = v_playlist_doc.first_node(); |
| action_print_node("expand_XML - v_playlist_doc.append_node_ptrs {%s}",vl_root_node); |
| } |
| |
| } |
| // If no error |
| if(vl_root_node !=0 ) { |
| // Like refreshed_XML_forNode |
| std::ostringstream vl_outxml; |
| vl_outxml << c_widgets_start; |
| for (vector<xml_node<> *>::iterator vl_nextnode = vl_nodelist.begin(); vl_nextnode != vl_nodelist.end(); vl_nextnode++) { |
| action_print_node("expand_XML_INSERT[copy->]{%s}", (xml_node<> * )*vl_nextnode); |
| // 2013.11.07. - new append |
| vl_node_source = vl_clone_doc.clone_node((xml_node<> * )*vl_nextnode); |
| vl_node_dest->insert_node(0, vl_node_source); |
| vl_clone_root_node = vl_node_source; |
| // 5. expand XML elements |
| expand_XML_elements( vl_clone_root_node , &vl_process_data, 0l); |
| |
| // 6. Wait for all data processed |
| ACTION_GUIFUNCTIONS("expand_XML{f__EPTF__UIHandler__GUIFunctions__waitForProcessExternalData__handlers:CALL_1}"); |
| f__EPTF__UIHandler__GUIFunctions__waitForProcessExternalData__handlers(vl_process_data.waitforIdx); |
| |
| // 7. remove debug and ptr attributes |
| out_process_for_metaiterators(vl_process_data.cloneDocPTR, vl_clone_root_node, (xml_node<>*) 0); |
| |
| std::string vl_xml_out_doc_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_out_doc_as_string), v_doc); |
| // 8. Print OUTPUT document [rapidxml] |
| vl_print_doc.clear(); |
| xml_node<> * vl_print_root_node; |
| vl_print_root_node = vl_print_doc.clone_node(vl_clone_root_node); |
| vl_print_doc.append_node(vl_print_root_node); |
| std::string vl_xml_proc_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_proc_as_string), vl_print_doc); |
| |
| vl_outxml << vl_xml_proc_as_string; |
| #ifdef KI_DEBUG_ACTIONS |
| ACTION_GUIFUNCTIONS("expand_XML_INSERT[CONCAT][%ld]:{%s}", (long)((xml_node<> * )*vl_nextnode),(char *)((const char *)vl_xml_proc_as_string.c_str())); |
| #endif |
| vl_print_doc.clear(); |
| } /* EndFor */ |
| |
| vl_outxml << c_widgets_end; |
| |
| vl_root_node = v_playlist_doc.first_node(); |
| // If loaded PRINT OUT |
| if(vl_root_node != 0) { |
| #ifdef KI_DEBUG_ACTIONS |
| std::string vl_xml_out_playlist_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_out_playlist_as_string), v_playlist_doc); |
| ACTION_GUIFUNCTIONS("expand_XML_INSERT[PLAYLIST]{%s}",(char *)((const char *)vl_xml_out_playlist_as_string.c_str())); |
| #endif |
| } |
| |
| pl_expandedXML = CHARSTRING((char *) vl_outxml.str().c_str()); |
| ACTION_GUIFUNCTIONS("expand_XML_INSERT[OUT]{%s}",(char *)((const char *)pl_expandedXML)); |
| |
| } else { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: The Orig node PTR not found[dyn] {%s}!", vl_parentID); |
| } |
| vl_nodelist.clear(); |
| } |
| } |
| } |
| // Save if all processed |
| if(vl_ret == true) { |
| v_xmlStrs.push_back(vl_cstr); |
| #ifdef PRINT_USED_MEMORY |
| v_xmlStrs_length += v_lastXmlStrs_length; |
| #endif |
| } else { |
| // cleanup else |
| free(vl_cstr); |
| } |
| free(vl_parentID); |
| // Cleanup [expand_XML] |
| vl_process_data.checkWidgetIDMapLastRun.clear(); // check widget id map |
| // For internal maps |
| for(unsigned int vl_idx=0; vl_idx< vl_process_data.ITValuesMapsVector.size(); vl_idx++){ |
| vl_process_data.ITValuesMapsVector[vl_idx].clear(); |
| } |
| vl_process_data.ITValuesMapsVector.clear(); // For ITValues Maps |
| if(vl_process_data.waitforIdx==0){ |
| f__EPTF__UIHandler__GUIFunctions__waitForProcessExternalData__handlers__reset(); |
| } |
| print_variableData("expand_XML[OUT]"); |
| #ifdef KI_DEBUG_ACTIONS |
| std::string vl_xml_out_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_out_as_string), vl_clone_doc); |
| ACTION_GUIFUNCTIONS("expand_XML[vl_clone_doc]{%s}",(char *)((const char *)vl_xml_out_as_string.c_str())); |
| // Full OUT: |
| std::string vl_xml_doc_out_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_doc_out_as_string), v_doc); |
| ACTION_GUIFUNCTIONS("expand_XML[v_doc]{%s}",(char *)((const char *)vl_xml_doc_out_as_string.c_str())); |
| #endif |
| |
| ACTION_GUIFUNCTIONS("expand_XML[OUT] - (%ld)*{%s}",(unsigned long)&vl_process_data,(char *)((const char *)pl_expandedXML)); |
| vl_clone_doc.clear(); |
| #ifdef USE_TIME_MEASURE |
| stop_timer(&v_timer_full_start, &v_tv_full, &v_time_full_diff_summ); |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"expand_XML[END] - {full=%f} | {process=%f} - [%f] percent",(v_time_full_diff_summ/10000),(v_time_process_diff_summ/10000), (double)(((double)v_time_process_diff_summ*100)/v_time_full_diff_summ)); |
| for(int vl_idx=0;vl_idx<MB_OF_MEASURES;vl_idx++) { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"expand_XML[END] - {full=%f} | {process=%f}| {measure=%f}[%d] - [%s]: - measure [%f] percent",(v_time_full_diff_summ/10000),(v_time_process_diff_summ/10000),(v_time_measure_diff_summ[vl_idx]/10000), vl_idx, &v_time_measure_str[vl_idx][0], (double)(((double)v_time_measure_diff_summ[vl_idx]*100)/v_time_full_diff_summ)); |
| } |
| #endif |
| #ifdef PRINT_USED_MEMORY |
| // Document [rapidxml] |
| long vl_doc_len = v_doc.doc_memory_size(); |
| // Clone document [rapidxml] |
| long vl_clone_doc_len = vl_clone_doc.doc_memory_size(); |
| long vl_playlist_doc_len = v_playlist_doc.doc_memory_size(); |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"expand_XML[END:MEMORY] - {v_doc=%ld} + {vl_clone_doc=%ld} + {v_playlist_doc=%ld} = %ld - {v_xmlStrs=%ld}",vl_doc_len,vl_clone_doc_len,vl_playlist_doc_len,(vl_doc_len+vl_clone_doc_len+vl_playlist_doc_len), v_xmlStrs_length); |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"expand_XML[END:GLOBAL] - {v_variableData=%ld | v_variableDataMap=%ld |v_widgetIDMap=%ld |v_cloneWidgetIDMap=%ld |v_playlistWidgetIDMap=%ld}", (long)v_variableData.size(),(long)v_variableDataMap.size(),(long)v_widgetIDMap.size(),(long)v_cloneWidgetIDMap.size(),(long)v_playlistWidgetIDMap.size()); |
| #endif |
| return(vl_ret); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: remove_XML |
| // |
| // Purpose: |
| // Remove XML elements from active document |
| // |
| // Parameters: |
| // pl_removeWidgetID - *in* *charstring* - the removed widget ID |
| // pl_expandedXML - *out* *charstring* - the expanded XML string |
| // |
| // Return Value: |
| // Returns the result of validation and process. |
| // pl_expandedXML - *out* *charstring* - the expanded XML string after remove |
| // |
| // Errors: |
| // |
| // Detailed Comments: |
| // Remove XML elements from active document. |
| // |
| /////////////////////////////////////////////////////////// |
| bool remove_XML(const CHARSTRING& pl_removeWidgetID) |
| { |
| bool vl_ret = true; |
| const char * vl_parentID = (const char *)pl_removeWidgetID; |
| // root root node // [lifetime: temporary] |
| xml_node<> * vl_root_node = v_doc.first_node(); |
| ACTION_GUIFUNCTIONS("remove_XML[START]->%s", vl_parentID); |
| |
| // If no parent -> Reset and set act_doc |
| if(*vl_parentID != '\0') { |
| variable_data vl_var_data_local; |
| variable_data * vl_var_data_ptr = 0; |
| variable_data * vl_var_parent_data_ptr = 0; |
| xml_node<> * vl_orig_node_ptr = 0; |
| std::map<string, node_parent>::iterator vl_node_map = v_cloneWidgetIDMap.find(vl_parentID); |
| // In the clone map -> |
| if(vl_node_map != v_cloneWidgetIDMap.end()) { |
| node_parent vl_node_parent = vl_node_map->second; |
| //std::map<xml_node<> *, int>::iterator vl_data_map = v_variableDataMap.find(vl_node_parent.node_offset_id); |
| std::map<long, int>::iterator vl_data_map = v_variableDataMap.find(vl_node_parent.node_offset_id); |
| // iterator item |
| if(vl_data_map != v_variableDataMap.end() && vl_data_map->second<(int)v_variableData.size()) { |
| vl_var_data_ptr = &v_variableData[vl_data_map->second]; |
| } |
| if(vl_node_parent.parent_offset_node_id != 0) { |
| // Find node ID |
| vl_data_map = v_variableDataMap.find(vl_node_parent.parent_offset_node_id); |
| vl_orig_node_ptr = vl_node_parent.orig_node_ptr; |
| // normal data item -> parent iterator |
| if(vl_data_map != v_variableDataMap.end() && vl_data_map->second<(int)v_variableData.size()) { |
| vl_var_parent_data_ptr = &v_variableData[vl_data_map->second]; |
| } |
| } |
| std::map<std::string, xml_node<> *>::iterator vl_widget_map = v_widgetIDMap.find(std::string(vl_parentID)); |
| if(vl_widget_map != v_widgetIDMap.end()) { |
| xml_node<> * vl_node = vl_widget_map->second; |
| // If in base document -> |
| if(vl_node->document() == &v_doc) { |
| ACTION_GUIFUNCTIONS("remove_XML - vl_node->document() == &v_doc(BASE DELETE) - [%s]", vl_parentID); |
| // Remove childs from widgetIDMap; cloneWidgetIDMap |
| // OK: remove variable data |
| delete_node_variabledata(vl_parentID); |
| // Just remove nothing all |
| xml_node<> * vl_parent_node = vl_node->parent(); |
| if(vl_parent_node != 0) { |
| vl_parent_node->remove_node(vl_node); |
| } |
| } else { |
| // Remove childs from playlistWidgetIDMap; cloneWidgetIDMap |
| ACTION_GUIFUNCTIONS("remove_XML - vl_node->document() != &v_doc(DYNAMIC DELETE) - [%s]", vl_parentID); |
| // OK: remove variable data |
| delete_node_variabledata(vl_parentID); |
| // Insert into playlist |
| // check if its in playlist -> than change, or insert |
| vl_root_node = v_playlist_doc.first_node(); |
| // If no error |
| if(vl_root_node != 0) { |
| std::map<std::string, playlist_data>::iterator vl_playlist_map = v_playlistWidgetIDMap.find(std::string(vl_parentID)); |
| if(vl_playlist_map != v_playlistWidgetIDMap.end()) { |
| // Change it |
| playlist_data vl_playlist = vl_playlist_map->second; |
| vl_node = vl_playlist.playlist_node_ptr; |
| vl_node->remove_all_nodes(); |
| // Clone name and value |
| vl_node->name(c_xml_delete_name, v_size_xml_delete_name); |
| } else { |
| // Append the insert node item |
| xml_node<>* vl_node = v_playlist_doc.allocate_node(node_element, c_xml_delete_name); |
| char * vl_ptrbuff = v_playlist_doc.allocate_string(vl_parentID); |
| vl_node->append_attribute(v_playlist_doc.allocate_attribute(c_str_id, vl_ptrbuff)); |
| vl_root_node->append_node(vl_node); |
| // playlist widget id map |
| playlist_data vl_playlist; |
| vl_playlist.playlist_node_ptr = vl_node; |
| vl_playlist.idx = v_playlistIdx++; |
| // If have erease it |
| std::map<string, playlist_data>::iterator vl_node_check_map = v_playlistWidgetIDMap.find(std::string(vl_parentID)); |
| if(vl_node_check_map != v_playlistWidgetIDMap.end()) { |
| v_playlistWidgetIDMap.erase(std::string(vl_parentID)); |
| } |
| v_playlistWidgetIDMap.insert(std::make_pair(std::string(vl_parentID), vl_playlist)); |
| vl_root_node = v_playlist_doc.first_node(); |
| } |
| } else { |
| ACTION_GUIFUNCTIONS("remove_XML - No playlist.root_node - [%s]", vl_parentID); |
| } |
| } |
| } else { |
| ACTION_GUIFUNCTIONS("remove_XML - NOT IN v_widgetIDMap - [%s]:%d", vl_parentID, (int)v_widgetIDMap.size()); |
| std::map<string, node_parent>::iterator vl_node_map = v_cloneWidgetIDMap.find(vl_parentID); |
| if(vl_node_map != v_cloneWidgetIDMap.end()) { |
| node_parent vl_node_parent = vl_node_map->second; |
| xml_node<> * vl_node = 0; //vl_node_dest; |
| // Remove childs from playlistWidgetIDMap; cloneWidgetIDMap |
| // OK: remove variable data |
| delete_node_variabledata(vl_parentID); |
| // Insert into playlist |
| // check if its in playlist -> than change, or insert |
| vl_root_node = v_playlist_doc.first_node(); |
| // If no error |
| if(vl_root_node != 0) { |
| std::map<std::string, playlist_data>::iterator vl_playlist_map = v_playlistWidgetIDMap.find(std::string(vl_parentID)); |
| if(vl_playlist_map != v_playlistWidgetIDMap.end()) { |
| // Change it |
| playlist_data vl_playlist = vl_playlist_map->second; |
| vl_node = vl_playlist.playlist_node_ptr; |
| vl_node->remove_all_nodes(); |
| // Clone name and value |
| vl_node->name(c_xml_delete_name, v_size_xml_delete_name); |
| } else { |
| // Append the insert node item |
| xml_node<>* vl_node = v_playlist_doc.allocate_node(node_element, c_xml_delete_name); |
| char * vl_ptrbuff = v_playlist_doc.allocate_string(vl_parentID); |
| vl_node->append_attribute(v_playlist_doc.allocate_attribute(c_str_id, vl_ptrbuff)); |
| vl_root_node->append_node(vl_node); |
| // playlist widget id map |
| playlist_data vl_playlist; |
| vl_playlist.playlist_node_ptr = vl_node; |
| vl_playlist.idx = v_playlistIdx++; |
| std::map<string, playlist_data>::iterator vl_node_check_map = v_playlistWidgetIDMap.find(std::string(vl_parentID)); |
| if(vl_node_check_map != v_playlistWidgetIDMap.end()) { |
| v_playlistWidgetIDMap.erase(std::string(vl_parentID)); |
| } |
| v_playlistWidgetIDMap.insert(std::make_pair(std::string(vl_parentID), vl_playlist)); |
| vl_root_node = v_playlist_doc.first_node(); |
| } |
| } else { |
| ACTION_GUIFUNCTIONS("remove_XML - No playlist.root_node - [%s]", vl_parentID); |
| } |
| } |
| } |
| } else { |
| // Not in clone widget ID map |
| vl_ret = false; |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: Widget ID not found : {%s}!", (const char *)vl_parentID); |
| } |
| |
| } else { |
| // Empty ID |
| vl_ret = false; |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: Empty Widget ID {%s}!", vl_parentID); |
| } |
| #ifdef KI_DEBUG_ACTIONS |
| std::string vl_xml_out_doc_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_out_doc_as_string), v_playlist_doc); |
| print_variableData("remove_XML[OUT]"); |
| ACTION_GUIFUNCTIONS("remove_XML[v_playlist_doc]{%s}",(char *)((const char *)vl_xml_out_doc_as_string.c_str())); |
| #endif |
| #ifdef PRINT_USED_MEMORY |
| // Document [rapidxml] |
| long vl_doc_len = v_doc.doc_memory_size(); |
| // Playlist document [rapidxml] |
| long vl_playlist_doc_len = v_playlist_doc.doc_memory_size(); |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"remove_XML[END:MEMORY] - {v_doc=%ld} + {v_playlist_doc=%ld} = %ld - {v_xmlStrs=%ld}",vl_doc_len,vl_playlist_doc_len,(vl_doc_len+vl_playlist_doc_len), v_xmlStrs_length); |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"remove_XML[END:GLOBAL] - {v_variableData=%ld | v_variableDataMap=%ld |v_widgetIDMap=%ld |v_cloneWidgetIDMap=%ld |v_playlistWidgetIDMap=%ld}", (long)v_variableData.size(),(long)v_variableDataMap.size(),(long)v_widgetIDMap.size(),(long)v_cloneWidgetIDMap.size(),(long)v_playlistWidgetIDMap.size()); |
| #endif |
| return(vl_ret); |
| } |
| /////////////////////////////////////////////////////////// |
| // |
| // Function: f_EPTF_UIHandler_refreshedXMLforNode |
| // |
| // Purpose: |
| // Expand XML for the given node |
| // |
| // Parameters: |
| // pl_node_id - *in* <long> - actual node identifier |
| // pl_xulExpanded - *out* *charstring* - the expanded XML string |
| // |
| // Return Value: |
| // Returns the result of the process. |
| // pl_xulExpanded - *out* *charstring* - the expanded XML string |
| // |
| // Errors: |
| // |
| // Detailed Comments: |
| // Expand XML for the given node. |
| // |
| /////////////////////////////////////////////////////////// |
| bool refreshed_XML_forNode(long pl_node_id, CHARSTRING& pl_xulExpanded) { |
| bool vl_ret = true; |
| pl_xulExpanded = CHARSTRING(""); |
| // root and clone root node // [lifetime: temporary] |
| xml_node<> * vl_root_node = v_doc.first_node(); |
| xml_document<> vl_clone_doc; // Clone document [rapidxml] |
| vl_clone_doc.clear(); |
| xml_node<> * vl_clone_root_node = vl_clone_doc.first_node(); |
| process_data vl_process_data; |
| vl_process_data.ITValuesMapsVector.clear(); |
| vl_process_data.checkWidgetIDMapLastRun.clear(); |
| vl_process_data.cloneDocPTR = &vl_clone_doc; |
| vl_process_data.waitforIdx = EPTF__CLL__UIHandler__Definitions::EPTF__UIHandler__Private__CT_component_v__UIHandler__GUIFunctions__nofRunning__processExternalData__handlers.size_of(); |
| EPTF__CLL__UIHandler__Definitions::EPTF__UIHandler__Private__CT_component_v__UIHandler__GUIFunctions__nofRunning__processExternalData__handlers[vl_process_data.waitforIdx] = 0; |
| |
| ACTION_GUIFUNCTIONS("refreshed_XML_forNode[START:NODE]->%ld", pl_node_id); |
| print_variableData("refreshed_XML_forNode[START]"); |
| |
| // Find node ID |
| std::map<long, int>::iterator vl_data_map = v_variableDataMap.find(pl_node_id); |
| // Get the full document refresh |
| if(pl_node_id == 0) { |
| vl_root_node = v_doc.first_node(); |
| if(vl_root_node == NULL) { |
| vl_ret = false; |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: NO root element in the BASE XML!"); |
| } else { |
| // Reset clone XML data |
| reset_clone_XML(); |
| // copy whole tree into second tree, which will contain metaiterators and the children expanded according the values of the iterator |
| vl_clone_root_node = vl_clone_doc.clone_node(vl_root_node); |
| vl_clone_doc.append_node(vl_clone_root_node); |
| vl_clone_root_node = vl_clone_doc.first_node(); |
| // Expand XML elements |
| expand_XML_elements( vl_clone_root_node, &vl_process_data, 0l); |
| // Wait for all data processed |
| f__EPTF__UIHandler__GUIFunctions__waitForProcessExternalData__handlers(vl_process_data.waitforIdx); |
| |
| // remove debug and ptr attributes |
| vl_clone_root_node = vl_clone_doc.first_node(); |
| out_process_for_metaiterators(vl_process_data.cloneDocPTR, vl_clone_root_node, (xml_node<>*) 0); |
| std::string vl_xml_out_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_out_as_string), vl_clone_doc); |
| pl_xulExpanded = CHARSTRING((char *) vl_xml_out_as_string.c_str()); |
| ACTION_GUIFUNCTIONS("refreshed_XML_forNode[OUT]{%s}",(char *)((const char *)pl_xulExpanded)); |
| } |
| } else if(vl_data_map != v_variableDataMap.end() && vl_data_map->second<(int)v_variableData.size()) { |
| // Sub tree refresh |
| ACTION_GUIFUNCTIONS("refreshed_XML_forNode[vl_data_map->second]->%ld / %ld", (long)vl_data_map->second, (long)v_variableData.size()); |
| variable_data vl_data = v_variableData[vl_data_map->second]; |
| /* v_variableData |
| * --------------------------------------- |
| xml_node<> * orig_node_ptr; |
| char * orig_node_name; |
| long local_var_idx; |
| char * remote_var_name; |
| std::vector<std::pair<string, string> > it_values_list; |
| */ |
| // clear v_variableDataMap and v_variableData child values |
| // Delete child nodes variable data and map |
| ACTION_GUIFUNCTIONS("refreshed_XML_forNode_1 - vl_data (%s)[%s -> %ld] {%ld : %s}: %d",vl_data.widget_id, vl_data.orig_node_name,(long)(vl_data.orig_node_ptr), vl_data.local_var_idx, vl_data.remote_var_name, (int)vl_data.deleted); |
| |
| delete_node_variabledata(vl_data.widget_id); |
| |
| xml_node<> * vl_node_ptr = vl_data.orig_node_ptr; |
| ACTION_GUIFUNCTIONS("refreshed_XML_forNode_2[vl_node_ptr]->%ld:%ld",(long)vl_node_ptr, (long)vl_data.it_values_list.size()); |
| action_print_node("refreshed_XML_forNode_2 - vl_data.orig_node_ptr {%s}",vl_data.orig_node_ptr); |
| // Set IT Values |
| if(init_xml_doc(&vl_clone_doc) == false) { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: The Clone XML doc cannot be loaded!"); |
| } |
| if(0<vl_data.it_values_list.size()) { |
| // Print document [rapidxml] |
| xml_document<> vl_print_doc; |
| vl_print_doc.clear(); |
| xml_node<> * vl_print_root_node; |
| vl_print_root_node = vl_print_doc.clone_node(vl_node_ptr); |
| vl_print_doc.append_node(vl_print_root_node); |
| std::string vl_xml_proc_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_proc_as_string), vl_print_doc); |
| int vl_itvalues_map_idx = vl_process_data.ITValuesMapsVector.size(); |
| vl_process_data.ITValuesMapsVector.push_back(vl_data.it_values_list); |
| ACTION_GUIFUNCTIONS("refreshed_XML_forNode_2[vl_xml_proc_as_string]->{%s}",vl_xml_proc_as_string.c_str()); |
| vl_node_ptr = process_iterator_node(vl_process_data.cloneDocPTR, vl_node_ptr, &(vl_data.it_values_list) , vl_itvalues_map_idx, vl_xml_proc_as_string); |
| vl_print_doc.clear(); |
| } |
| xml_node<> * v_clone_node = vl_clone_doc.first_node(); |
| // clone from original |
| copy_node(&vl_clone_doc,vl_node_ptr, v_clone_node, true); |
| |
| // Expand XML elements |
| expand_XML_elements( v_clone_node, &vl_process_data, 0l); |
| // Wait for all data processed |
| f__EPTF__UIHandler__GUIFunctions__waitForProcessExternalData__handlers(vl_process_data.waitforIdx); |
| // remove debug and ptr attributes |
| out_process_for_metaiterators(vl_process_data.cloneDocPTR, v_clone_node, v_clone_node); |
| |
| // Print OUTPUT document [rapidxml] |
| xml_document<> vl_print_doc; |
| vl_print_doc.clear(); |
| xml_node<> * vl_print_root_node; |
| vl_print_root_node = vl_print_doc.clone_node(v_clone_node); |
| vl_print_doc.append_node(vl_print_root_node); |
| std::string vl_xml_proc_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_proc_as_string), vl_print_doc); |
| |
| pl_xulExpanded = CHARSTRING((char *) vl_xml_proc_as_string.c_str()); |
| vl_print_doc.clear(); |
| } else { |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, "ERROR: refreshed_XML_forNode: No original node PTR found [%ld]!", pl_node_id); |
| std::string vl_xml_out_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_out_as_string), vl_clone_doc); |
| ACTION_GUIFUNCTIONS("refreshed_XML_forNode[vl_clone_doc]{%s}",(char *)((const char *)vl_xml_out_as_string.c_str())); |
| } |
| // Cleanup [refreshed_XML_forNode] |
| vl_process_data.checkWidgetIDMapLastRun.clear(); // check widget id map |
| // For internal maps |
| for(unsigned int vl_idx=0; vl_idx< vl_process_data.ITValuesMapsVector.size(); vl_idx++){ |
| vl_process_data.ITValuesMapsVector[vl_idx].clear(); |
| } |
| vl_process_data.ITValuesMapsVector.clear(); // For ITValues Maps |
| if(vl_process_data.waitforIdx==0){ |
| f__EPTF__UIHandler__GUIFunctions__waitForProcessExternalData__handlers__reset(); |
| } |
| #ifdef PRINT_USED_MEMORY |
| // Document [rapidxml] |
| long vl_doc_len = v_doc.doc_memory_size(); |
| // Clone document [rapidxml] |
| long vl_clone_doc_len = vl_clone_doc.doc_memory_size(); |
| // Playlist document [rapidxml] |
| long vl_playlist_doc_len = v_playlist_doc.doc_memory_size(); |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"refreshed_XML_forNode[END:MEMORY] - {v_doc=%ld} + {vl_clone_doc=%ld} + {v_playlist_doc=%ld} = %ld - {v_xmlStrs=%ld}",vl_doc_len,vl_clone_doc_len,vl_playlist_doc_len,(vl_doc_len+vl_clone_doc_len+vl_playlist_doc_len), v_xmlStrs_length); |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"refreshed_XML_forNode[END:GLOBAL] - {v_variableData=%ld | v_variableDataMap=%ld |v_widgetIDMap=%ld |v_cloneWidgetIDMap=%ld |v_playlistWidgetIDMap=%ld}", (long)v_variableData.size(),(long)v_variableDataMap.size(),(long)v_widgetIDMap.size(),(long)v_cloneWidgetIDMap.size(),(long)v_playlistWidgetIDMap.size()); |
| #endif |
| vl_clone_doc.clear(); |
| ACTION_GUIFUNCTIONS("refreshed_XML_forNode[OUT]{%s}",(char *)((const char *)pl_xulExpanded)); |
| return(vl_ret); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: print_all_XML |
| // |
| // Purpose: |
| // print all XML |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // |
| // Detailed Comments: |
| // print all XML. |
| // |
| /////////////////////////////////////////////////////////// |
| void print_all_XML(void) { |
| |
| std::string vl_xml_out_as_string; |
| |
| std::string vl_xml_doc_out_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_doc_out_as_string), v_doc); |
| ACTION_GUIFUNCTIONS("refreshed_XML_forNode[v_doc]{%s}",(char *)((const char *)vl_xml_doc_out_as_string.c_str())); |
| |
| std::string vl_xml_playlist_doc_as_string; |
| rapidxml::print(std::back_inserter(vl_xml_playlist_doc_as_string), v_playlist_doc); |
| ACTION_GUIFUNCTIONS("refreshed_XML_forNode[v_playlist_doc]{%s}",(char *)((const char *)vl_xml_playlist_doc_as_string.c_str())); |
| return; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: append_node_ptrs |
| // |
| // Purpose: |
| // Append physical PTRs into entities |
| // |
| // Parameters: |
| // pl_doc - *in* <xml_document<> * > - XML document pointer |
| // pl_data - *in* < process_data *> - process data structure index |
| // pl_node - *in | out* <xml_node<> * > - actual node pointer |
| // |
| // Return Value: |
| // pl_node - *out* <xml_node<> * > - actual node pointer with physical PTR |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Append physical PTRs into entities "orig_node_ptr" before clone the XML document. |
| // |
| /////////////////////////////////////////////////////////// |
| void append_node_ptrs(xml_document<> * pl_doc, process_data * pl_data, xml_node<> * pl_node){ |
| bool vl_clearLastrun = false; |
| char v_tmpvalPTR[SIZE_OF_PTR+1] = ""; // cache |
| // Set PTR buffer |
| long vl_ptrlong = (long)pl_node; |
| sprintf(v_tmpvalPTR,"%ld",vl_ptrlong); |
| char * vl_ptrbuff = pl_doc->allocate_string(v_tmpvalPTR); |
| // allocate & add attribute |
| xml_attribute<> * vl_attr = pl_doc->allocate_attribute(c_str_orig_node_ptr, vl_ptrbuff); |
| pl_node->append_attribute(vl_attr); |
| // insert to widget id cache -> |
| char * vl_widgetID = get_attribute(pl_node, (char *)c_str_id); |
| if(*vl_widgetID != '\0') { |
| // iterator? |
| if(is_expandable(pl_node->name(), pl_node->name_size()) == true){ |
| // Check the nested existence of iterator id |
| std::map<string, int>::iterator vl_node_map = pl_data->checkWidgetIDMapLastRun.find(vl_widgetID); |
| if(vl_node_map != pl_data->checkWidgetIDMapLastRun.end()) { |
| std::ostringstream vl_error; |
| vl_error << "EPTF_CLL_UIHandler_GUIFunctions[append_node_ptrs]: Configuration error - an iterator with name " << vl_widgetID <<" already exists in the resolving scope!"; |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, vl_error.str().c_str()); |
| cleanup_XML(); |
| f__EPTF__UIHandler__error( CHARSTRING(vl_error.str().c_str())); |
| } else { |
| ACTION_GUIFUNCTIONS("append_node_ptrs - checkWidgetIDMapLastRun.insert[%s->%ld]",vl_widgetID,(long)pl_node); |
| pl_data->checkWidgetIDMapLastRun.insert(std::make_pair(vl_widgetID,(long) pl_node)); // check widget id map last run |
| vl_clearLastrun = true; |
| } |
| } |
| // If have erease it |
| std::map<string, xml_node<> *>::iterator vl_node_check_map = v_widgetIDMap.find(std::string(vl_widgetID)); |
| if(vl_node_check_map != v_widgetIDMap.end()) { |
| v_widgetIDMap.erase(std::string(vl_widgetID)); |
| } |
| v_widgetIDMap.insert(std::make_pair(std::string(vl_widgetID), pl_node)); |
| ACTION_GUIFUNCTIONS("append_node_ptrs v_widgetIDMap.insert(%s, %ld)", vl_widgetID, (long)pl_node); |
| } |
| // go through the two tree |
| for( xml_node<> * vl_actode = pl_node->first_node(); vl_actode; vl_actode = vl_actode->next_sibling()){ |
| append_node_ptrs(pl_doc, pl_data, vl_actode); |
| } |
| if(vl_clearLastrun == true){ |
| // Check remove nested Iterator ID -> vl_attrid from check widget id map |
| pl_data->checkWidgetIDMapLastRun.erase(vl_widgetID); |
| } |
| return; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: expand_XML_elements |
| // |
| // Purpose: |
| // Expand expandable XML elements |
| // |
| // Parameters: |
| // pl_node - *in | out* <xml_node<> * > - actual node pointer |
| // pl_data - *in* < process_data *> - process data structure index |
| // pl_idx - *in* < unsigned long> - expanded index |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Expand expandable XML elements. Get expandables list, get data sources and |
| // expand it. |
| // |
| /////////////////////////////////////////////////////////// |
| void expand_XML_elements( xml_node<> * pl_node, process_data * pl_data, unsigned long pl_idx) { |
| vector< xml_node<> * > vl_nodelist; |
| vl_nodelist.clear(); |
| process_data * vl_process_data_ptr = pl_data; |
| ACTION_GUIFUNCTIONS("expand_XML_elements - (%ld)*[%s:%ld:%ld]->%ld",(unsigned long)pl_data, pl_node->name(),(unsigned long) pl_node, (unsigned long)pl_data, (unsigned long)vl_nodelist.size()); |
| // Get first level expandable list |
| get_nodes_to_expand(pl_node, &vl_nodelist); |
| action_print_node("expand_XML_elements - get_nodes_to_expand {%s}",pl_node); |
| |
| // Thru the expandables |
| for (vector<xml_node<> *>::iterator vl_expandable = vl_nodelist.begin(); vl_expandable != vl_nodelist.end(); vl_expandable++){ |
| // Get data source parameters |
| char * vl_element; |
| char * vl_id; |
| char * vl_ptcname; |
| char * vl_source; |
| EPTF__CLL__DataSource__Definitions::EPTF__DataSource__Params vl_params; |
| std::ostringstream vl_parameters; |
| if(get_data_source( ((xml_node<> * )*vl_expandable), &vl_element, &vl_id, &vl_ptcname, &vl_source)==true){ |
| ACTION_GUIFUNCTIONS("get_data_source->{element=%s; id=%s; ptcname=%s; source=%s}", vl_element, vl_id, vl_ptcname, vl_source); |
| vl_parameters << vl_element << ":" << vl_ptcname << ":" << vl_source << "["; |
| vl_params = get_data_source_parameters( ((xml_node<> * )*vl_expandable)); |
| INTEGER vl_dataParamsSize(vl_params.size_of()); |
| if(0<vl_dataParamsSize){ |
| for(int vl_idx=0; vl_idx<vl_dataParamsSize;vl_idx++){ |
| vl_parameters << (char *)((const char *)vl_params[vl_idx].paramName()) << "=" << (char *)((const char *)vl_params[vl_idx].paramValue()); |
| ACTION_GUIFUNCTIONS("DATAPARAM->{[%d]: %s = %s}", vl_idx, (char *)((const char *)vl_params[vl_idx].paramName()), (char *)((const char *)vl_params[vl_idx].paramValue())); |
| } |
| } |
| } |
| vl_parameters << "]"; |
| // switch(((xml_node<> * )*vl_expandable)->name()) |
| char * vl_exp_name = ((xml_node<> * )*vl_expandable)->name(); |
| size_t vl_exp_name_size = measure(vl_exp_name); |
| // case (iterator) OR case (externalvalue) |
| // ---------------------------------------- |
| if(is_iterator_like(vl_exp_name, vl_exp_name_size) == true){ |
| if(vl_process_data_ptr != 0) { |
| // Call non blocking Get data |
| vl_process_data_ptr->parameters_String = vl_parameters.str(); |
| EPTF__CLL__DataSource__Definitions::EPTF__DataSource__GetDataHandler vl_dataHandler; |
| vl_dataHandler.getDataHandler() = &f__EPTF__UIHandler__expand__current__iterator; |
| |
| // put the pointer for the node into the userdata section, will be used in the datahandler function. |
| EPTF__CLL__Common__Definitions::EPTF__IntegerList& vl_expandable_ptr = vl_dataHandler.userData(); |
| vl_expandable_ptr.set_size(3); |
| vl_expandable_ptr[0].set_long_long_val( (unsigned long long) pl_data); |
| vl_expandable_ptr[1].set_long_long_val( (unsigned long long) ((xml_node<> * )*vl_expandable)); |
| vl_expandable_ptr[2].set_long_long_val( (unsigned long long) pl_idx); |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator-> - (%ld)*[%ld:%ld]", (unsigned long)pl_data,(unsigned long)vl_expandable_ptr[0].get_long_long_val(),(unsigned long)vl_expandable_ptr[1].get_long_long_val()); |
| // Increase the process counter |
| // TODO: Józsi szerint ez a növelés + a csökkentés nem kell, mert otomata számlálja |
| ++EPTF__CLL__UIHandler__Definitions::EPTF__UIHandler__Private__CT_component_v__UIHandler__GUIFunctions__nofRunning__processExternalData__handlers[pl_data->waitforIdx]; |
| ACTION_GUIFUNCTIONS("expand_XML_elements[f__EPTF__DataSource__getData__nonBlocking:iterator:%ld:%ld:%ld]->(%s;%s;%s)->{%s}", (long)pl_data, (long)((xml_node<> * )*vl_expandable),pl_idx, vl_source, vl_ptcname, vl_element, vl_process_data_ptr->parameters_String.c_str()); |
| f__EPTF__DataSource__getData__nonBlocking( vl_source, vl_ptcname, vl_element, vl_params, vl_dataHandler ); |
| } |
| |
| } |
| // case (condition) |
| // ----------------- |
| else if( compare_name(vl_exp_name, vl_exp_name_size, c_str_condition, v_size_condition)){ |
| if(vl_process_data_ptr != 0){ |
| char * vl_stridsaved = strdup_internal(vl_id); |
| ACTION_GUIFUNCTIONS("expand_XML_elements: vl_stridsaved[%s]", vl_stridsaved); |
| |
| // Call non blocking Get condition |
| EPTF__CLL__DataSource__Definitions::EPTF__DataSource__GetDataHandler vl_dataHandler; |
| vl_dataHandler.getDataHandler() = &f__EPTF__UIHandler__expand__current__condition; |
| // put the pointer for the node into the userdata section, will be used in the datahandler function. |
| EPTF__CLL__Common__Definitions::EPTF__IntegerList& vl_expandable_ptr = vl_dataHandler.userData(); |
| vl_expandable_ptr.set_size(3); |
| vl_expandable_ptr[0].set_long_long_val( (unsigned long long) pl_data ); |
| vl_expandable_ptr[1].set_long_long_val( (unsigned long long) ((xml_node<> * )*vl_expandable)); |
| vl_expandable_ptr[2].set_long_long_val( (unsigned long long) vl_stridsaved); |
| ACTION_GUIFUNCTIONS("vl_expandable_ptr[getCondition]->[%ld:%ld:%ld]", (unsigned long)vl_expandable_ptr[0].get_long_long_val(),(unsigned long)vl_expandable_ptr[1].get_long_long_val(), (unsigned long)vl_expandable_ptr[2].get_long_long_val()); |
| |
| // Increase the process counter |
| ++EPTF__CLL__UIHandler__Definitions::EPTF__UIHandler__Private__CT_component_v__UIHandler__GUIFunctions__nofRunning__processExternalData__handlers[pl_data->waitforIdx]; |
| ACTION_GUIFUNCTIONS("expand_XML_elements[f__EPTF__DataSource__getData__nonBlocking:condition]->(%s;%s;%s)", vl_source, vl_ptcname, vl_element); |
| // Call f_EPTF_DataSource_getCondition_nonBlocking |
| f__EPTF__DataSource__getCondition__nonBlocking( vl_source, vl_ptcname, vl_element, vl_params, vl_dataHandler ); |
| } |
| } else { |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, "expand_XML_elements: Unknown expandable [%s]!", vl_exp_name); |
| } |
| }/* EndFor */ |
| ACTION_GUIFUNCTIONS("expand_XML_elements - (%ld)*[OUT]->%d", (unsigned long)pl_node, (int)(EPTF__CLL__UIHandler__Definitions::EPTF__UIHandler__Private__CT_component_v__UIHandler__GUIFunctions__nofRunning__processExternalData__handlers[pl_data->waitforIdx]==0)); |
| return; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: get_nodes_to_expand |
| // |
| // Purpose: |
| // Get expandable list vector |
| // |
| // Parameters: |
| // pl_node - *in* <xml_node<> * > - actual node pointer |
| // pl_nodeList - *out* <vector< xml_node<>* > * > - expandable node list vector |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Get expandable list vector. |
| // |
| /////////////////////////////////////////////////////////// |
| void get_nodes_to_expand( xml_node<>* pl_node, vector< xml_node<>* > * pl_nodeList) |
| { |
| if(is_expandable(pl_node->name(), pl_node->name_size()) == true) |
| { |
| pl_nodeList->push_back(pl_node); |
| ACTION_GUIFUNCTIONS("get_nodes_to_expand -> PUSH[ROOT]: %s",pl_node->name() ); |
| } else { |
| // Thru the node list |
| for (xml_node<> * vl_act_node = pl_node->first_node(); vl_act_node; vl_act_node = vl_act_node->next_sibling()){ |
| ACTION_GUIFUNCTIONS("get_nodes_to_expand-> Node: %s",vl_act_node->name() ); |
| // if expandable save it |
| if(is_expandable(vl_act_node->name(), vl_act_node->name_size()) == true) |
| { |
| pl_nodeList->push_back(vl_act_node); |
| ACTION_GUIFUNCTIONS("get_nodes_to_expand-> PUSH[child]: %s",vl_act_node->name() ); |
| } else { |
| get_nodes_to_expand(vl_act_node, pl_nodeList); |
| } |
| } |
| } |
| return; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f__EPTF__UIHandler__expand__current__iterator |
| // |
| // Purpose: |
| // Nonblocking Data Handler: Expand the current node iterator, condition and externalvalue. |
| // |
| // Parameters: |
| // pl_source *in* *charstring * - the name of the dataSource 'feature' |
| // pl_source *in* *charstring* - the name of the PTC |
| // (dataSource+ptcName should be a unigue id of the data). Default: "" (i.e. PTC name is ignored) |
| // pl_element *in* *charstring* - the type of data |
| // pl_params *in* <EPTF_DataSource_Params> - additional parameters (default: {}) |
| // pl_errorCode - *in* *INTEGER&* - error code in the response |
| // pl_remoteDataVarName - *in* *charstring* - var name on the remote component. |
| // In case errorCode!=0: it contains the error message |
| // pl_ownerCompRef - *in* *COMPONENT&* - reference to the remote component |
| // pl_localDataVarId - *in* *INTEGER&* - var id on the local component |
| // (contains the current value, not subscribed to remote!) |
| // pl_dataValue - *in* <EPTF_Var_DirectContent> - the value of the data |
| // pl_userData - *in* <EPTF__IntegerList&> -user specific data given at the request |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Nonblocking Data Handler: Expand the current node iterator, condition and externalvalue.. |
| // |
| /////////////////////////////////////////////////////////// |
| void f__EPTF__UIHandler__expand__current__iterator( const CHARSTRING& pl_source, |
| const CHARSTRING& pl_ptcName, |
| const CHARSTRING& pl_element, |
| const EPTF__CLL__DataSource__Definitions::EPTF__DataSource__Params& pl_params, |
| const INTEGER& pl_errorCode, |
| const CHARSTRING& pl_remoteDataVarName, |
| const COMPONENT& pl_ownerCompRef, |
| const INTEGER& pl_localDataVarId, |
| const EPTF__CLL__Variable__Definitions::EPTF__Var__DirectContent& pl_dataValue, |
| const EPTF__CLL__Common__Definitions::EPTF__IntegerList& pl_userData) |
| { |
| //pl_dataValue is a CharstringList with the values of the iterator |
| // START[0]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| START_MEASURE(0, "f__EPTF__UIHandler__expand__current__iterator: start"); |
| EPTF__CLL__Common__Definitions::EPTF__CharstringList vl_values; |
| long unsigned int vl_values_size; |
| const char * * vl_str_values = NULL; |
| char vl_tmp_data_bfr[SIZE_OF_MAXDATA]; |
| unsigned long long vl_wrk_long_ptr = (unsigned long)pl_userData[0].get_long_long_val(); |
| unsigned long long vl_wrk_long_long = (unsigned long long)pl_userData[1].get_long_long_val(); |
| long vl_idx = (long)((unsigned long long)pl_userData[2].get_long_long_val()); |
| process_data * vl_process_data_ptr = (process_data *)vl_wrk_long_ptr; |
| xml_node<>* vl_copyNode = (xml_node<>*)vl_wrk_long_long; |
| v_variableDataMapOffsetID++; // variable data map OFFSET ID |
| xml_node<>* vl_IteratorNode = 0; |
| long vl_variableDataMapOffsetIDAct = v_variableDataMapOffsetID; |
| CHARSTRING vl_tmp_ptr; |
| bool vl_pendingError = false; // Have any error? |
| char * vl_origPtr = 0; |
| char * vl_node_name = (char *)&c_str_empty[0]; |
| vl_origPtr = get_attribute(vl_copyNode, (char *) c_str_orig_node_ptr); |
| vl_node_name = vl_copyNode->name(); |
| char * vl_attrid = get_attribute(vl_copyNode,(char *)c_str_id); |
| ACTION_GUIFUNCTIONS("->f__EPTF__UIHandler__expand__current__iterator - (%ld)*[%ld:%ld:%ld]{%s}->{%s}",(unsigned long)vl_process_data_ptr,(unsigned long)pl_userData[0].get_long_long_val(),(unsigned long)pl_userData[1].get_long_long_val(),vl_idx, vl_attrid, vl_process_data_ptr->parameters_String.c_str()); |
| action_print_node("f__EPTF__UIHandler__expand__current__iterator - vl_copyNode {%s}",vl_copyNode); |
| std::size_t vl_node_name_size = measure(vl_node_name); |
| bool vl_is_externalvalue = compare_name(vl_node_name, vl_node_name_size, c_str_externalvalue, v_size_externalvalue); |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator - vl_copyNode[%ld]->name(){%s-pl_errorCode:%ld}-vl_is_externalvalue:%d -> %s",(unsigned long)vl_copyNode,vl_node_name, (long)pl_errorCode,(int)vl_is_externalvalue, (char *)((const char *) pl_remoteDataVarName)); |
| STOP_MEASURE(0); |
| // -------------------------------------------------------------------------------------------------------------------- |
| // STOP[0]: |
| // START[1]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| START_MEASURE(1, "f__EPTF__UIHandler__expand__current__iterator: get iterator"); |
| |
| // change iterator | external value to metaiterator in the copy node. |
| if(vl_origPtr!=0){ |
| vl_IteratorNode = (xml_node<>*) (long *) atol(vl_origPtr); |
| } |
| if(vl_IteratorNode) { |
| set_node_temp_attributes(vl_process_data_ptr->cloneDocPTR, vl_copyNode, vl_variableDataMapOffsetIDAct, (char *)((const char *)pl_remoteDataVarName),(long)pl_localDataVarId); |
| } |
| if(pl_errorCode != 0 && vl_pendingError == false) { |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, "f_EPTF_DataSource_getData_nonBlocking: Error[%ld] -> {%s}!", (long)pl_errorCode, (char *)((const char *) pl_remoteDataVarName) ); |
| vl_pendingError = true; |
| } else if(*vl_origPtr== '\0'){ |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, "ERROR: f__EPTF__UIHandler__expand__current__iterator: No original node PTR found [%ld]!", (unsigned long) vl_wrk_long_long); |
| vl_pendingError = true; |
| } else if(is_iterator_like(vl_node_name, vl_node_name_size) == false) { |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, "f__EPTF__UIHandler__expand__current__iterator: the node not (iterator | externalvalue) instead of: [%s]!", vl_node_name); |
| vl_pendingError = true; |
| } else { |
| // Data type? |
| if (pl_dataValue.get_selection() == EPTF__Var__DirectContent::ALT_charstringlistVal) { |
| vl_values = pl_dataValue.charstringlistVal(); |
| vl_values_size = vl_values.size_of(); |
| // externalvalue ... |
| if(vl_is_externalvalue == true) { |
| // bugfix_artf361869_empty_iterator: no process on empty iterator in externalvalue |
| vl_values_size = vl_values.size_of(); |
| if(1<vl_values_size){ |
| vl_values_size = 1; |
| } |
| // vl__dataVarName = (TTCN_Logger::begin_event_log2str(),vl_values.log(),TTCN_Logger::end_event_log2str()); |
| vl_str_values = new const char *[vl_values_size]; |
| vl_tmp_ptr = (TTCN_Logger::begin_event_log2str(),vl_values.log(),TTCN_Logger::end_event_log2str()); |
| *(vl_str_values)= (const char *)vl_tmp_ptr; |
| } else { |
| vl_str_values = new const char *[vl_values_size]; |
| for (long unsigned int i = 0; i < vl_values_size; i++){ |
| *(vl_str_values+i) = (const char *)vl_values[i]; |
| } |
| } |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator: %ld->%ld",(long) vl_copyNode, vl_values_size ); |
| } else { |
| // externalvalue ... |
| if(vl_is_externalvalue == true) { |
| // ALT_charstringlistVal - BASE |
| // ALT_intVal |
| vl_values_size = 1; |
| vl_str_values = new const char *[vl_values_size]; |
| *(vl_str_values) = NULL; |
| if (pl_dataValue.get_selection() == EPTF__Var__DirectContent::ALT_intVal) { |
| sprintf(vl_tmp_data_bfr,"%ld",(long)pl_dataValue.intVal()); |
| *(vl_str_values) = (const char *)vl_tmp_data_bfr; |
| } |
| // ALT_floatVal |
| else if (pl_dataValue.get_selection() == EPTF__Var__DirectContent::ALT_floatVal) { |
| sprintf(vl_tmp_data_bfr,"%f",(float)pl_dataValue.floatVal()); |
| *(vl_str_values) = (const char *)vl_tmp_data_bfr; |
| } |
| // ALT_boolVal, |
| else if (pl_dataValue.get_selection() == EPTF__Var__DirectContent::ALT_boolVal) { |
| sprintf(vl_tmp_data_bfr,"%d",(int)pl_dataValue.boolVal()); |
| *(vl_str_values) = (const char *)vl_tmp_data_bfr; |
| } |
| // ALT_charstringVal |
| else if (pl_dataValue.get_selection() == EPTF__Var__DirectContent::ALT_charstringVal) { |
| *(vl_str_values) = (const char *)(pl_dataValue.charstringVal()); |
| } |
| // NOT SUPPORTED |
| // ---------------------------------- |
| // ALT_octetstringVal |
| // ALT_hexstringVal |
| // ALT_bitstringVal |
| // ALT_integerlistVal |
| // ALT_floatlistVal |
| // ALT_statusLEDVal |
| // ALT_unknownVal |
| else { |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, "f__EPTF__UIHandler__expand__current__iterator: function handles only intVal|floatVal|boolVal|charstringVal directContent for now!!"); |
| vl_pendingError = true; |
| } |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator[externalvalue]: {%ld}->%s",vl_values_size, *(vl_str_values)); |
| |
| } else { |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, "f__EPTF__UIHandler__expand__current__iterator: function handles only CharstringList directContent for now!!"); |
| vl_pendingError = true; |
| } |
| } |
| } |
| STOP_MEASURE(1); |
| // -------------------------------------------------------------------------------------------------------------------- |
| // STOP[1]: |
| |
| // If NO Error |
| if(vl_pendingError == false) { |
| char vl_value_idx [SIZE_OF_LONG]; |
| char vl_value_count [SIZE_OF_LONG]; |
| // START[2]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| START_MEASURE(2, "f__EPTF__UIHandler__expand__current__iterator: resubscribe+"); |
| //KI char * vl_attrid = get_attribute(vl_copyNode,(char *)c_str_id); |
| // Put postproc to variable: f_EPTF_UIHandler_updateIterator_PostProc(in integer pl_idx, in EPTF_IntegerList pl_argList) |
| //-------------------------- ------------------------------------------------------------------------------------------- |
| if( *((const char *)pl_remoteDataVarName) != '\0' ) { |
| EPTF__CLL__Variable__Definitions::EPTF__Var__GenericFn vl_funcref; |
| vl_funcref.funcRef() = &f__EPTF__UIHandler__updateIterator__PostProc; |
| { |
| EPTF__CLL__Common__Definitions::EPTF__IntegerList& vl_idxlist = vl_funcref.argList(); |
| vl_idxlist.set_size(1); |
| vl_idxlist[0].set_long_long_val( (unsigned long) vl_copyNode); |
| } |
| // now we are subscribing for every variable. Need to figure out an algorithm to optimalize this. |
| ACTION_GUIFUNCTIONS("f__EPTF__Var__resubscribeRemote(%s)",(const char* )pl_remoteDataVarName); |
| EPTF__CLL__Variable__Functions::f__EPTF__Var__resubscribeRemote(pl_ownerCompRef, pl_remoteDataVarName, EPTF__CLL__DataSource__Definitions::tsp__EPTF__DataSource__subscriptionMode, pl_localDataVarId, "", -1, cg__EPTF__Var__resubscribeRemoteResp__handler__null); |
| } |
| ACTION_GUIFUNCTIONS("pl_remoteDataVarName{%s}->[%ld]",(const char* )pl_remoteDataVarName,(long)pl_localDataVarId); |
| |
| vector< xml_node<> * > vl_NodesToConnect; |
| vl_NodesToConnect.clear(); |
| int vl_itvalues_map_idx = -1; |
| std::ostringstream vl_sstream; |
| |
| // Check if first node are param list |
| xml_node<> * vl_first_node = vl_copyNode->first_node(); |
| bool vl_firstIsParam = false; |
| bool vl_firstNodeProcessed = false; |
| if(vl_first_node!=NULL && compare_name(vl_first_node->name(), vl_first_node->name_size(), c_str_params, v_size_params)) { |
| vl_firstIsParam = true; |
| } |
| |
| ACTION_GUIFUNCTIONS("pl_dataValue{%s}->[%ld]-firstparam(%d)",(const char* )pl_remoteDataVarName, vl_values_size, vl_firstIsParam); |
| // node xml string data map |
| map<xml_node<> *, std::string> vl_nodeXMLStrDataMap; |
| vl_nodeXMLStrDataMap.clear(); |
| STOP_MEASURE(2); |
| |
| // -------------------------------------------------------------------------------------------------------------------- |
| // STOP[2]: |
| // Check nested Iterator ID -> vl_attrid in check widget id map |
| std::string vl_widgetID = std::string(vl_attrid); |
| std::ostringstream vl_widgetIDLastRunStream; |
| vl_widgetIDLastRunStream << vl_widgetID << "_" << vl_idx; |
| std::string vl_widgetIDLastRun = vl_widgetIDLastRunStream.str(); |
| std::ostringstream vl_widgetIDStrStream; |
| vl_widgetIDStrStream << "id=\""<< vl_widgetID << "\""; |
| std::string vl_widgetIDStr = vl_widgetIDStrStream.str(); |
| for (long unsigned int i = 0; i < vl_values_size; i++) { |
| START_MEASURE(3, "f__EPTF__UIHandler__expand__current__iterator: new_itvalues"); |
| vl_sstream.clear(); |
| // START[3]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| ACTION_GUIFUNCTIONS("1 - pl_dataValue[%s->%ld]: %s",vl_attrid,i,(const char *)*(vl_str_values+i)); |
| |
| // base; |
| string vl_tobereplace_base_str = escape_double_quotes(vl_attrid); |
| char * vl_value_base = (char *)(*(vl_str_values+i)); |
| std::ostringstream vl_tobereplace_base; |
| vl_tobereplace_base << c_str_replace_sign << vl_tobereplace_base_str << c_str_replace_sign; |
| // ::idx |
| sprintf(vl_value_idx,"%ld",i); |
| std::ostringstream vl_tobereplace_idx; |
| vl_tobereplace_idx << c_str_replace_sign << vl_tobereplace_base_str << c_str_replace_idx << c_str_replace_sign; |
| // ::count |
| sprintf(vl_value_count,"%ld",vl_values_size); |
| std::ostringstream vl_tobereplace_count; |
| vl_tobereplace_count << c_str_replace_sign << vl_tobereplace_base_str << c_str_replace_count << c_str_replace_sign; |
| // ::ref are the variable name but the LOCAL not the remote :) |
| // char * vl_value_ref = (char *)((const char *)pl_remoteDataVarName); |
| string vl_value_ref_str = escape_double_quotes(((const char *)EPTF__CLL__Variable__Functions::f__EPTF__Var__getName(pl_localDataVarId))); |
| std::ostringstream vl_tobereplace_ref; |
| vl_tobereplace_ref << c_str_replace_sign << vl_tobereplace_base_str << c_str_replace_ref << c_str_replace_sign; |
| |
| map<string, string> vl_it_values; // itvalues map |
| vl_it_values.clear(); |
| vl_it_values.insert(std::make_pair(vl_tobereplace_base.str(), escape_double_quotes(vl_value_base))); |
| vl_it_values.insert(std::make_pair(vl_tobereplace_idx.str(), std::string(vl_value_idx))); |
| vl_it_values.insert(std::make_pair(vl_tobereplace_count.str(), std::string(vl_value_count))); |
| vl_it_values.insert(std::make_pair(vl_tobereplace_ref.str(), vl_value_ref_str)); |
| |
| // Save IT Values Map |
| vl_itvalues_map_idx = vl_process_data_ptr->ITValuesMapsVector.size(); |
| vl_process_data_ptr->ITValuesMapsVector.push_back(vl_it_values); |
| #ifdef KI_DEBUG_ACTIONS |
| for(std::map<std::string , std::string>::iterator vl_it_map = vl_it_values.begin(); vl_it_map != vl_it_values.end(); vl_it_map++) { |
| vl_sstream << vl_it_map->first << "->" << vl_it_map->second << " | "; |
| } |
| ACTION_GUIFUNCTIONS("process_iterator_node - vl_process_data_ptr->ITValuesMapsVector[%d] {%s}",vl_itvalues_map_idx, vl_sstream.str().c_str()); |
| #endif |
| |
| STOP_MEASURE(3); |
| // -------------------------------------------------------------------------------------------------------------------- |
| // STOP[3]: |
| |
| //create "(number of pl_dataValue) * (original number of children under parentNode)" children under vl_copyNode with rapidxml |
| vl_first_node = vl_copyNode->first_node(); |
| for( xml_node<> * vl_pNode = vl_copyNode->first_node(); vl_pNode; vl_pNode=vl_pNode->next_sibling()) { |
| START_MEASURE(4, "f__EPTF__UIHandler__expand__current__iterator: xml -> string"); |
| // START[4]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| std::string vl_xml_proc_as_string; |
| std::map<xml_node<> *, std::string>::iterator vl_data_map = vl_nodeXMLStrDataMap.find(vl_pNode); |
| if(vl_data_map != vl_nodeXMLStrDataMap.end() && 0<vl_data_map->second.length()) { |
| vl_xml_proc_as_string = vl_data_map->second; |
| } else { |
| // Print document [rapidxml] |
| xml_document<> vl_print_doc; |
| vl_print_doc.clear(); |
| xml_node<> * vl_print_root_node; |
| vl_print_root_node = vl_print_doc.clone_node(vl_pNode); |
| vl_print_doc.append_node(vl_print_root_node); |
| rapidxml::print(std::back_inserter(vl_xml_proc_as_string), vl_print_doc); |
| vl_print_doc.clear(); |
| vl_nodeXMLStrDataMap.insert(std::make_pair(vl_pNode, vl_xml_proc_as_string)); |
| } |
| STOP_MEASURE(4); |
| // -------------------------------------------------------------------------------------------------------------------- |
| // STOP[4]: |
| |
| START_MEASURE(5, "f__EPTF__UIHandler__expand__current__iterator: process_iterator_node"); |
| // START[5]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| // If not first node or its not param list or its not processed once |
| if(vl_pNode != vl_first_node || vl_firstIsParam == false || vl_firstNodeProcessed == false){ |
| // process base ::idx | ::count | ::ref on iterator | externalvalue |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator - process_iterator_node[XML:PROCESS:START]: %ld:[%s] {%s}",(long)vl_pNode, vl_sstream.str().c_str(), vl_xml_proc_as_string.c_str()); |
| xml_node<> * vl_pNewNode = process_iterator_node(vl_process_data_ptr->cloneDocPTR, vl_pNode, &vl_it_values, vl_itvalues_map_idx, vl_xml_proc_as_string); |
| vl_NodesToConnect.push_back(vl_pNewNode); |
| vl_firstNodeProcessed = true; // First node processed |
| } else { |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator - process_iterator_node[XML:ELSE]: {%s}", vl_xml_proc_as_string.c_str()); |
| } |
| STOP_MEASURE(5); |
| // -------------------------------------------------------------------------------------------------------------------- |
| // STOP[5]: |
| } |
| vl_it_values.clear(); // itvalues map |
| } |
| |
| START_MEASURE(6, "f__EPTF__UIHandler__expand__current__iterator: clear"); |
| // START[6]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| vl_nodeXMLStrDataMap.clear(); |
| //connect nodes to the copy node, but remove all children first |
| //remove all children |
| vl_copyNode->remove_all_nodes(); |
| unsigned long vl_idx = 0l; |
| for (vector<xml_node<> *>::iterator vl_expanded = vl_NodesToConnect.begin(); vl_expanded != vl_NodesToConnect.end(); vl_expanded++){ |
| vl_copyNode->append_node((xml_node<> * )*vl_expanded); |
| /* call expand_XMLElements() for every children Node */ |
| STOP_MEASURE(6); |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator - expand_XML_elements: (%ld)*{%ld}->%ld", (unsigned long)vl_process_data_ptr, (unsigned long)*vl_expanded, vl_idx); |
| action_print_node("f__EPTF__UIHandler__expand__current__iterator - expand_XML_elements - vl_copyNode {%s}",(xml_node<> * )*vl_expanded); |
| expand_XML_elements( (xml_node<> * )*vl_expanded, vl_process_data_ptr , vl_idx); |
| START_MEASURE(6, "f__EPTF__UIHandler__expand__current__iterator: clear"); |
| vl_idx++; |
| } |
| // Free data |
| if(vl_str_values != NULL) { |
| delete [] vl_str_values; |
| STOP_MEASURE(6); |
| // -------------------------------------------------------------------------------------------------------------------- |
| // STOP[6]: |
| } |
| |
| START_MEASURE(7, "f__EPTF__UIHandler__expand__current__iterator: vl_str_itvalues"); |
| // START[7]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| // save and update variable data |
| // -------------------------------------------------------------------------------- |
| char vl_szTemp[2048]="<NULL>"; |
| |
| xml_attribute<> * vl_attr = vl_copyNode->first_attribute((char *)c_str_orig_itvalues); |
| // action_print_node("f__EPTF__UIHandler__expand__current__iterator[vl_copyNode:{%s}", vl_copyNode); |
| std::map<std::string, std::string> vl_full_it_values; // itvalues map |
| vl_full_it_values.clear(); |
| if(vl_attr != NULL) { |
| strcpy(vl_szTemp, vl_attr->value()); |
| std::istringstream vl_itvalue_idxs_stream(vl_attr->value()); |
| std::string vl_next_string; |
| while (std::getline(vl_itvalue_idxs_stream, vl_next_string, ';')) { |
| // std::cout << vl_next_string << std::endl; |
| int vl_next_idx_value = atoi(vl_next_string.c_str()); |
| map< string, string > vl_it_values = vl_process_data_ptr->ITValuesMapsVector.at(vl_next_idx_value); |
| // For vl_it_values |
| for(std::map<std::string, std::string>::iterator vl_itvalue_item = vl_it_values.begin(); vl_itvalue_item != vl_it_values.end(); vl_itvalue_item++) { |
| std::string vl_first = vl_itvalue_item->first; |
| std::string vl_second = vl_itvalue_item->second; |
| vl_full_it_values.insert(std::make_pair(vl_first, vl_second)); |
| } |
| } |
| } |
| #ifdef KI_DEBUG_ACTIONS |
| std::ostringstream vl_sstream_debug; |
| for(std::map<std::string , std::string>::iterator vl_it_map = vl_full_it_values.begin(); vl_it_map != vl_full_it_values.end(); vl_it_map++) { |
| vl_sstream_debug << vl_it_map->first << "->" << vl_it_map->second << " | "; |
| } |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator - ITVALUES: [%ld:%ld](%s)->{%s} => [%d] {%s}", (long)vl_copyNode, (long)pl_localDataVarId, vl_szTemp, vl_sstream_debug.str().c_str(),vl_itvalues_map_idx, vl_sstream.str().c_str()); |
| #endif |
| |
| STOP_MEASURE(7); |
| // -------------------------------------------------------------------------------------------------------------------- |
| // STOP[7]: |
| |
| START_MEASURE(8, "f__EPTF__UIHandler__expand__current__iterator: vl_var_data_ptr"); |
| // START[8]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| // If its valid |
| //std::map<xml_node<> *, int>::iterator vl_data_map = v_variableDataMap.find(vl_copyNode); |
| char * vl_node_offset_id_str = get_attribute(vl_copyNode, (char *)c_str_offset_id); |
| std::map<long, int>::iterator vl_data_map = v_variableDataMap.end(); |
| if(vl_node_offset_id_str!=0 && *vl_node_offset_id_str!='\0') { |
| long vl_node_offset_id = atol(vl_node_offset_id_str); |
| if(0l<vl_node_offset_id) { |
| std::map<long, int>::iterator vl_data_map = v_variableDataMap.find(vl_node_offset_id); |
| } |
| } |
| if(vl_data_map != v_variableDataMap.end() && vl_data_map->second<(int)v_variableData.size()) { |
| // Existing item |
| variable_data * vl_var_data_ptr = &v_variableData[vl_data_map->second]; |
| #ifdef KI_DEBUG_ACTIONS |
| // Free buffers first |
| if(vl_var_data_ptr->orig_node_name) { |
| free(vl_var_data_ptr->orig_node_name); |
| vl_var_data_ptr->orig_node_name = 0; |
| } |
| if(vl_var_data_ptr->remote_var_name) { |
| free(vl_var_data_ptr->remote_var_name); |
| vl_var_data_ptr->remote_var_name = 0; |
| } |
| #else |
| vl_var_data_ptr->orig_node_name = 0; |
| vl_var_data_ptr->remote_var_name = 0; |
| #endif |
| vl_var_data_ptr->orig_node_ptr = vl_IteratorNode; |
| vl_var_data_ptr->widget_id = vl_attrid; |
| vl_var_data_ptr->local_var_idx = (long)pl_localDataVarId; |
| #ifdef KI_DEBUG_ACTIONS |
| vl_var_data_ptr->orig_node_name = strdup_internal(vl_node_name); |
| vl_var_data_ptr->remote_var_name = strdup_internal((char *)((const char *)pl_remoteDataVarName)); |
| #else |
| vl_var_data_ptr->orig_node_name = (char *)c_str_empty; |
| vl_var_data_ptr->remote_var_name = (char *)c_str_empty; // Remote Variable Name |
| #endif |
| vl_var_data_ptr->it_values_list.clear(); |
| vl_var_data_ptr->deleted = false; |
| vl_var_data_ptr->it_values_list = vl_full_it_values; |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator - UPDATE - v_variableData(%s)[%s : %ld]{%ld : %s}: %d",vl_var_data_ptr->widget_id,vl_var_data_ptr->orig_node_name,(long)( vl_var_data_ptr->orig_node_ptr),vl_var_data_ptr->local_var_idx, vl_var_data_ptr->remote_var_name, (int)vl_var_data_ptr->deleted); |
| } else { |
| // New item -> |
| variable_data vl_var_data; |
| vl_var_data.node_offset_id = vl_variableDataMapOffsetIDAct; |
| vl_var_data.orig_node_ptr = vl_IteratorNode; |
| #ifdef KI_DEBUG_ACTIONS |
| vl_var_data.orig_node_name = strdup_internal(vl_node_name); |
| vl_var_data.remote_var_name = strdup_internal((char *)((const char *)pl_remoteDataVarName)); |
| #else |
| vl_var_data.orig_node_name = (char *)c_str_empty; |
| vl_var_data.remote_var_name = (char *)c_str_empty; // Remote Variable Name |
| #endif |
| vl_var_data.widget_id = vl_attrid; |
| vl_var_data.local_var_idx = (long)pl_localDataVarId; |
| vl_var_data.it_values_list.clear(); |
| vl_var_data.deleted = false; |
| vl_var_data.it_values_list = vl_full_it_values; |
| |
| // Set offset ID |
| set_node_offset_id(vl_process_data_ptr->cloneDocPTR, vl_copyNode, vl_variableDataMapOffsetIDAct); |
| // Insert variable data map |
| v_variableData.push_back(vl_var_data); |
| //v_variableDataMap.insert(std::make_pair(vl_copyNode,(v_variableData.size()-1))); |
| v_variableDataMap.insert(std::make_pair(vl_var_data.node_offset_id,(v_variableData.size()-1))); |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator - INSERT - v_variableData(%s)[%s : ID=%ld]{%ld : %s}: %d",vl_var_data.widget_id,vl_var_data.orig_node_name, vl_var_data.node_offset_id, vl_var_data.local_var_idx, vl_var_data.remote_var_name, (int)vl_var_data.deleted); |
| } |
| // -------------------------------------------------------------------------------------------------------------------- |
| STOP_MEASURE(8); |
| // -------------------------------------------------------------------------------------------------------------------- |
| // STOP[8]: |
| |
| } |
| --EPTF__CLL__UIHandler__Definitions::EPTF__UIHandler__Private__CT_component_v__UIHandler__GUIFunctions__nofRunning__processExternalData__handlers[vl_process_data_ptr->waitforIdx]; |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__iterator - END - (%ld)*[%ld:%ld]", (unsigned long)vl_process_data_ptr,(unsigned long)pl_userData[0].get_long_long_val(),(unsigned long)pl_userData[1].get_long_long_val()); |
| action_print_node("f__EPTF__UIHandler__expand__current__iterator - vl_copyNode - END {%s}",vl_copyNode); |
| |
| return; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: set_itvalue_idx |
| // |
| // Purpose: |
| // Set ITValues idx into orig_itvalues attribute |
| // |
| // Parameters: |
| // pl_clone_doc_ptr - *in* <xml_document<> * > - document pointer |
| // pl_node - *in* <xml_node<> * > - node pointer |
| // pl_value_idx - *in* <char *> the saved IT value index in string |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Save ITValues idx into orig_itvalues attribute. |
| // |
| /////////////////////////////////////////////////////////// |
| void set_itvalue_idx(xml_document<> * pl_clone_doc_ptr, xml_node<> * pl_node, char * pl_value_idx) { |
| // update itvalues idx in attribute |
| xml_attribute<> * vl_attrorig = pl_node->first_attribute((char *)c_str_orig_itvalues); |
| char * vl_orig_itvalues = (char *)c_str_empty; |
| if(vl_attrorig != NULL){ |
| vl_orig_itvalues = vl_attrorig->value(); |
| } |
| ACTION_GUIFUNCTIONS("set_itvalue_idx[%ld]iterator:orig:{%s}:[%s]", (unsigned long) pl_node, vl_orig_itvalues, pl_value_idx); |
| // If not contain - |
| std::string vl_str_act_itvalues(vl_orig_itvalues); |
| if(vl_str_act_itvalues.length()==0 || vl_str_act_itvalues.find(pl_value_idx) == std::string::npos){ |
| vl_str_act_itvalues.append(pl_value_idx); |
| ACTION_GUIFUNCTIONS("set_itvalue_idx-pl_clone_doc_ptr[%ld]iterator:orig:{%s}:vl_str_act_itvalues[%s]", (unsigned long) pl_clone_doc_ptr, vl_orig_itvalues, vl_str_act_itvalues.c_str()); |
| char * vl_attrValuePtr = pl_clone_doc_ptr->allocate_string(vl_str_act_itvalues.c_str()); |
| ACTION_GUIFUNCTIONS("set_itvalue_idx[%ld]iterator:orig:{%s}:vl_attrValuePtr[%s]", (unsigned long) pl_node, vl_orig_itvalues, vl_attrValuePtr); |
| // If have orig |
| if(vl_attrorig != NULL){ |
| pl_node->remove_attribute(vl_attrorig); |
| } |
| ACTION_GUIFUNCTIONS("set_itvalue_idx[%ld]iterator:orig:{%s}:vl_attrValuePtr[%s]-1", (unsigned long) pl_node, vl_orig_itvalues, vl_attrValuePtr); |
| xml_attribute<> * vl_attrnext = pl_clone_doc_ptr->allocate_attribute(c_str_orig_itvalues, vl_attrValuePtr); |
| ACTION_GUIFUNCTIONS("set_itvalue_idx[%ld]iterator:orig:{%s}:vl_attrValuePtr[%s]-2", (unsigned long) pl_node, vl_orig_itvalues, vl_attrValuePtr); |
| pl_node->append_attribute(vl_attrnext); |
| ACTION_GUIFUNCTIONS("set_itvalue_idx[insert]{%s in %s}", pl_value_idx, vl_attrValuePtr); |
| } else { |
| ACTION_GUIFUNCTIONS("set_itvalue_idx[DUPLICATE]{%s in %s}", pl_value_idx, pl_node->name()); |
| } |
| return; |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: get_node_iterators_and_playlist |
| // |
| // Purpose: |
| // Request node iterators an playlist elements |
| // |
| // Parameters: |
| // pl_node - *in* <xml_node<> * > - node pointer |
| // pl_iteratorList - *out* vector< xml_node<>* > * - vector PTR for iterator nodes |
| // pl_playList - *out* vector< playListItem > * - vector for playlist elements |
| // |
| // Return Value: |
| // Returns the PTRs of itarators an playlist elements. |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Request node iterators an playlist elements. |
| // |
| /////////////////////////////////////////////////////////// |
| void get_node_iterators_and_playlist( xml_node<>* pl_node, vector< xml_node<>* > * pl_iteratorList, vector< playListItem > * pl_playList) |
| { |
| if(is_iterator_like(pl_node->name(), pl_node->name_size()) == true) |
| { |
| pl_iteratorList->push_back(pl_node); |
| ACTION_GUIFUNCTIONS("get_node_iterators_and_playlist -> PUSH[iterator]: %s",pl_node->name()); |
| } |
| if(pl_playList!=0){ |
| // check ID and if its in playlist play it ADD / REMOVE |
| char * vl_widgetID = get_attribute(pl_node, (char *)c_str_id); |
| if(*vl_widgetID != '\0') { |
| // check if exist |
| std::map<std::string, playlist_data>::iterator vl_playlist_map = v_playlistWidgetIDMap.find(std::string(vl_widgetID)); |
| if(vl_playlist_map != v_playlistWidgetIDMap.end()){ |
| playlist_data vl_playlist = vl_playlist_map->second; |
| playListItem vl_playlist_out; |
| vl_playlist_out.widget_id = vl_widgetID; // widget ID |
| vl_playlist_out.node_ptr = pl_node; // Node PTR |
| vl_playlist_out.playlist_node_ptr = vl_playlist.playlist_node_ptr; // Playlist Node PTR |
| vl_playlist_out.idx = vl_playlist.idx; // The sorting idx |
| pl_playList->push_back(vl_playlist_out); |
| ACTION_GUIFUNCTIONS("get_node_iterators_and_playlist -> PUSH[playlist]: %s",pl_node->name()); |
| } |
| } |
| } |
| // Thru the node list |
| for (xml_node<> * vl_act_node = pl_node->first_node(); vl_act_node; vl_act_node = vl_act_node->next_sibling()){ |
| get_node_iterators_and_playlist(vl_act_node, pl_iteratorList, pl_playList); |
| } |
| return; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: process_iterator_node |
| // |
| // Purpose: |
| // Process iterator node |
| // |
| // Parameters: |
| // pl_clone_doc_ptr - *in* <xml_document<> * > - document pointer |
| // pl_source - *in* <xml_node<> * > - node pointer |
| // pl_it_values - *in* vector<std::pair<string, string> > * - vector PTR change from | to values |
| // pl_it_idx - *in* <int> the saved IT value index in v_ITValues buffer |
| // pl_xml_as_string *in* <string> processed xml string |
| // |
| // Return Value: |
| // Returns the PTR of the result node. |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Process iterator node. |
| // |
| /////////////////////////////////////////////////////////// |
| xml_node<>* process_iterator_node(xml_document<> * pl_clone_doc_ptr, xml_node<> * pl_source,map<string, string> * pl_it_values, int pl_it_idx, string pl_xml_as_string) |
| { |
| xml_node<> * vl_result = NULL; |
| #ifdef USE_TIME_MEASURE |
| start_timer(&v_timer_process_start, &v_tv_process); |
| #endif |
| // Replace Iterator values |
| // ================================================================================== |
| START_MEASURE(9, "process_iterator_node: replace_all[map]"); |
| // START[9]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| // Process XML |
| // find all %<iteratorvalue>% and replece it from pl_it_values map |
| std::ostringstream vl_sstream; |
| char * vl_start = (char *) pl_xml_as_string.c_str(); // start ptr |
| char * vl_next = strchr(vl_start,'%'); // next item begin ptr |
| char * vl_nextend = 0; // next item end ptr |
| char vl_savedch = '\0'; // saved character |
| while(vl_next!=0) { |
| vl_nextend = strchr(vl_next+1,'%'); |
| if(vl_nextend!=0) { // If have next item |
| vl_savedch = *(vl_nextend+1); |
| *(vl_nextend+1) = '\0'; // close end |
| // search in pl_it_values map |
| std::map<std::string , std::string>::iterator vl_it_map = pl_it_values->find(vl_next); |
| if(vl_it_map != pl_it_values->end()) { // If there is replace value |
| ACTION_GUIFUNCTIONS("process_iterator_node change: %s -> %s",vl_next,vl_it_map->second.c_str()); |
| *vl_next = '\0'; // close begin |
| vl_sstream << vl_start<<vl_it_map->second; // copy previous string + replaced string |
| |
| *vl_next = '%'; // restore begin |
| *(vl_nextend+1) = vl_savedch; // restore end |
| vl_start = vl_nextend+1; // next start ptr |
| vl_next = strchr(vl_start,'%'); // search next begin |
| } else { |
| *(vl_nextend+1) = vl_savedch; // restore end |
| vl_next = vl_nextend; // next start ptr |
| } |
| } else { |
| vl_next = 0; |
| } |
| } |
| vl_sstream << vl_start; |
| pl_xml_as_string = vl_sstream.str(); |
| ACTION_GUIFUNCTIONS("process_iterator_node -> [pl_xml_as_string]: %s",pl_xml_as_string.c_str()); |
| STOP_MEASURE(9); |
| |
| START_MEASURE(11, "process_iterator_node: parse"); |
| // START[11]: |
| // -------------------------------------------------------------------------------------------------------------------- |
| // Parse the procesed XML string |
| // ================================================================================== |
| char * vl_cstr = strdup_internal((const char *)pl_xml_as_string.c_str()); |
| // Load check, because if its invalid the rapidxml crash |
| xml_document<> vl_print_doc; |
| vl_print_doc.clear(); |
| xml_node<> * vl_print_root_node; |
| try { |
| vl_print_doc.parse<parse_no_entity_translation>(vl_cstr); |
| vl_print_root_node = vl_print_doc.first_node(); |
| } catch (int vl_err) { |
| vl_print_root_node = NULL; |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED, "ERROR: The XML doc cannot be loaded or is not well-formed: {%d}!", vl_err); |
| } |
| if(vl_print_root_node != NULL) { |
| // Finally clone it |
| vl_result = pl_clone_doc_ptr->clone_node(vl_print_root_node); |
| v_xmlStrs.push_back(vl_cstr); |
| #ifdef PRINT_USED_MEMORY |
| v_xmlStrs_length += strlen(vl_cstr); |
| #endif |
| } |
| vl_print_doc.clear(); |
| STOP_MEASURE(11); |
| |
| action_print_node("process_iterator_node - vl_result {%s}",vl_result); |
| |
| START_MEASURE(10, "process_iterator_node: itvalues[NOT_USE_ITVALUES_STRING]"); |
| // set IT values index |
| // ================================================================================== |
| char vl_value_idx [SIZE_OF_LONG + 10]; |
| sprintf(vl_value_idx," %d;", pl_it_idx); |
| // Set IT Values current node |
| vector< xml_node<> * > vl_iteratorlist; |
| vl_iteratorlist.clear(); |
| vector< playListItem > vl_playlist; |
| vl_playlist.clear(); |
| // Get iterator and playlist list |
| if(v_playlistWidgetIDMap.empty()==true) { |
| get_node_iterators_and_playlist(vl_result, &vl_iteratorlist, 0); |
| } else { |
| get_node_iterators_and_playlist(vl_result, &vl_iteratorlist, &vl_playlist); |
| } |
| // Do iterator list |
| if(vl_iteratorlist.empty()!=true) { |
| for (vector<xml_node<> *>::iterator vl_nextnode = vl_iteratorlist.begin(); vl_nextnode != vl_iteratorlist.end(); vl_nextnode++){ |
| set_itvalue_idx(pl_clone_doc_ptr, (xml_node<> *)*vl_nextnode, vl_value_idx); |
| } |
| } |
| action_print_node("process_iterator_node - vl_result_1 {%s}",vl_result); |
| // Do playlist |
| if(vl_playlist.empty()!=true) { |
| // sort |
| std::sort(vl_playlist.begin(), vl_playlist.end(), playlist_order()); |
| for (vector<playListItem>::iterator vl_playListItem = vl_playlist.begin(); vl_playListItem != vl_playlist.end(); vl_playListItem++){ |
| // check ID and if its in playlist play it ADD / REMOVE |
| playListItem vl_playListItemAct = (playListItem)*vl_playListItem; |
| xml_node<> * vl_nextnode = vl_playListItemAct.node_ptr; |
| xml_node<> * vl_play_node = vl_playListItemAct.playlist_node_ptr; |
| ACTION_GUIFUNCTIONS("Do playlist[vl_play_node->name()]{%s}->%s",vl_playListItemAct.widget_id, vl_play_node->name()); |
| // Delete child nodes variable data |
| delete_node_variabledata( vl_playListItemAct.widget_id); |
| // If delete |
| if(compare_name( vl_play_node->name(),vl_play_node->name_size(), c_xml_delete_name, v_size_xml_delete_name) == true) { |
| // Just remove nothing all |
| xml_node<> * vl_parent_node = (vl_nextnode)->parent(); |
| if(vl_parent_node != 0) { |
| vl_parent_node->remove_node(vl_nextnode); |
| } |
| } else { |
| // Insert item -> |
| // ------------------------------------------- |
| // clone from original |
| xml_node<> * vl_parent_node = vl_nextnode; |
| // action_print_node("insert_itvalue_idx[PARENT:{%s}", vl_parent_node); |
| for (xml_node<> *vl_nextnode_int = vl_play_node->first_node(); vl_nextnode_int; vl_nextnode_int = vl_nextnode_int->next_sibling()) { |
| //action_print_node("insert_itvalue_idx[copy->]{%s}", vl_nextnode_int); |
| // 2013.11.07. - new append |
| xml_node<> * vl_node_source = pl_clone_doc_ptr->clone_node(vl_nextnode_int); |
| vl_parent_node->insert_node(0, vl_node_source); |
| ACTION_GUIFUNCTIONS("insert_itvalue_idx[copy_X]{%ld | %ld | %ld}",(long)vl_parent_node, (long)0, (long)vl_node_source); |
| } |
| } |
| } |
| } |
| |
| STOP_MEASURE(10); |
| |
| #ifdef USE_TIME_MEASURE |
| stop_timer(&v_timer_process_start, &v_tv_process, &v_time_process_diff_summ); |
| #endif |
| action_print_node("process_iterator_node - vl_result_2 {%s}",vl_result); |
| return(vl_result); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f__EPTF__UIHandler__expand__current__condition |
| // |
| // Purpose: |
| // Nonblocking Data Handler: Expand the current node condition. |
| // |
| // Parameters: |
| // pl_source *in* *charstring * - the name of the dataSource 'feature' |
| // pl_source *in* *charstring* - the name of the PTC |
| // (dataSource+ptcName should be a unigue id of the data). Default: "" (i.e. PTC name is ignored) |
| // pl_element *in* *charstring* - the type of data |
| // pl_params *in* <EPTF_DataSource_Params> - additional parameters (default: {}) |
| // pl_errorCode - *in* *INTEGER&* - error code in the response |
| // pl_remoteDataVarName - *in* *charstring* - var name on the remote component. |
| // In case errorCode!=0: it contains the error message |
| // pl_ownerCompRef - *in* *COMPONENT&* - reference to the remote component |
| // pl_localDataVarId - *in* *INTEGER&* - var id on the local component |
| // (contains the current value, not subscribed to remote!) |
| // pl_dataValue - *in* <EPTF_Var_DirectContent> - the value of the data |
| // pl_userData - *in* <EPTF__IntegerList&> -user specific data given at the request |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Nonblocking Data Handler: Expand the current node condition. |
| // |
| /////////////////////////////////////////////////////////// |
| void f__EPTF__UIHandler__expand__current__condition ( const CHARSTRING& pl_source, |
| const CHARSTRING& pl_ptcName, |
| const CHARSTRING& pl_element, |
| const EPTF__CLL__DataSource__Definitions::EPTF__DataSource__Params& pl_params, |
| const INTEGER& pl_errorCode, |
| const CHARSTRING& pl_remoteDataVarName, |
| const COMPONENT& pl_ownerCompRef, |
| const INTEGER& pl_localDataVarId, |
| const EPTF__CLL__Variable__Definitions::EPTF__Var__DirectContent& pl_dataValue, |
| const EPTF__CLL__Common__Definitions::EPTF__IntegerList& pl_userData) |
| { |
| bool vl_conditionresult = false; |
| unsigned long long vl_wrk_long_ptr = (unsigned long)pl_userData[0].get_long_long_val(); |
| unsigned long long vl_wrk_long_long = (unsigned long long)pl_userData[1].get_long_long_val(); |
| process_data * vl_process_data_ptr = (process_data *)vl_wrk_long_ptr; |
| xml_node<>* vl_copyNode = (xml_node<>*)vl_wrk_long_long; |
| bool vl_pendingError = false; // Have any error? |
| char * vl_origPtr = 0; |
| vl_wrk_long_long = (unsigned long long)pl_userData[2].get_long_long_val(); |
| char * vl_condition_id_saved = (char *)vl_wrk_long_long; |
| vl_origPtr = get_attribute(vl_copyNode, (char *) c_str_orig_node_ptr); |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__condition: [%ld:{%s}]->%d",(unsigned long) vl_copyNode, vl_condition_id_saved, vl_conditionresult ); |
| if(pl_errorCode != 0 && vl_pendingError == false) { |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, "f_EPTF_DataSource_getCondition_nonBlocking: Error[%ld] -> {%s}!", (long)pl_errorCode, (char *)((const char *) pl_remoteDataVarName) ); |
| vl_pendingError = true; |
| } else if(*vl_origPtr == '\0'){ |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, "ERROR: f__EPTF__UIHandler__expand__current__condition: No original node PTR found [%ld]!", (unsigned long) vl_wrk_long_long); |
| vl_pendingError = true; |
| } else { |
| xml_node<>* vl_IteratorNode = (xml_node<>*) (long *) atol(vl_origPtr); |
| if(vl_IteratorNode) { |
| //change condition to metaiterator in the copy node. |
| set_node_temp_attributes(vl_process_data_ptr->cloneDocPTR, vl_copyNode, (long)vl_copyNode, (char *)((const char *)pl_remoteDataVarName),(long)pl_localDataVarId); |
| } |
| // pl_dataValue is a boolean with the values of the condition |
| // Data type |
| if (pl_dataValue.get_selection() == EPTF__Var__DirectContent::ALT_boolVal) { |
| vl_conditionresult = pl_dataValue.boolVal(); |
| ACTION_GUIFUNCTIONS("f__EPTF__UIHandler__expand__current__condition: [%ld]->%d",(unsigned long) vl_copyNode, vl_conditionresult ); |
| } else { |
| TTCN_Logger::log(TTCN_Logger::ERROR_UNQUALIFIED, "f__EPTF__UIHandler__expand__current__condition: function handles only bool directContent for now!!"); |
| vl_pendingError = true; |
| } |
| } |
| // If NO Error |
| if(vl_pendingError == false && vl_condition_id_saved != 0) { |
| xml_node<> * vl_pNewNode = process_condition_node(vl_process_data_ptr->cloneDocPTR, vl_copyNode, vl_conditionresult, vl_condition_id_saved); |
| free(vl_condition_id_saved); // Free saved |
| // No any additional wrk needed |
| if(vl_pNewNode != NULL) { |
| } |
| // Expand inside |
| expand_XML_elements( vl_copyNode, vl_process_data_ptr, 0l); |
| } |
| // =================================================================================================================== |
| |
| --EPTF__CLL__UIHandler__Definitions::EPTF__UIHandler__Private__CT_component_v__UIHandler__GUIFunctions__nofRunning__processExternalData__handlers[vl_process_data_ptr->waitforIdx]; |
| return; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: process_condition_node |
| // |
| // Purpose: |
| // Process condition node |
| // |
| // Parameters: |
| // pl_clone_doc_ptr - *in* <xml_document<> * > - document pointer |
| // pl_source - *in* <xml_node<> * > - node pointer |
| // pl_condition - *in* <bool > - condition value |
| // vl_conditionid - *in* <const char * > - condition ID |
| // |
| // Return Value: |
| // Returns the PTR of the result node. |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Process condition node. |
| // |
| /////////////////////////////////////////////////////////// |
| xml_node<>* process_condition_node(xml_document<> * pl_clone_doc_ptr, xml_node<> * pl_source, bool pl_condition, char * vl_conditionid ) |
| { |
| xml_node<> * vl_result = NULL; |
| vector< xml_node<> * > vl_NodesToRemove; |
| vl_NodesToRemove.clear(); |
| // Process child nodes and attributes |
| for (xml_node<> *vl_child = pl_source->first_node(); vl_child; vl_child = vl_child->next_sibling()){ |
| bool vl_processed = false; |
| ACTION_GUIFUNCTIONS("process_condition_node-> next]: [%s]", vl_child->name()); |
| // If 'insertif' process it |
| if(compare_name( vl_child->name(),vl_child->name_size(), c_str_insertif, v_size_insertif) == true){ |
| char * vl_id = get_attribute( vl_child, (char *)c_str_id); |
| ACTION_GUIFUNCTIONS("process_condition_node-> ID]: [%s]", vl_id ); |
| if(compare(vl_conditionid, measure(vl_conditionid),vl_id,measure(vl_id))) { |
| char * vl_negatePtr = get_attribute(vl_child, (char *) c_str_negate); |
| ACTION_GUIFUNCTIONS("process_condition_node-> set_node_temp_attributes->]: [%s]", vl_id ); |
| set_node_temp_attributes(pl_clone_doc_ptr, vl_child, (long)vl_child, (char *)c_str_TODO, 0l); |
| bool vl_negate = compare(vl_negatePtr,measure(vl_negatePtr),c_str_true, v_size_true); |
| // If true than nothing |
| if((pl_condition == true) ^ (vl_negate == true)){ |
| ACTION_GUIFUNCTIONS("process_condition_node-> PROCESS]: [%s]-> %d", vl_id, (int) pl_condition ); |
| } else { |
| ACTION_GUIFUNCTIONS("process_condition_node-> ELSE]: [%s]-> %d", vl_id, (int) pl_condition ); |
| vl_processed = true; |
| vl_NodesToRemove.push_back(vl_child); |
| } |
| } |
| } |
| // If not processed call for children |
| if(vl_processed == false) { |
| // If not insertif -> |
| process_condition_node(pl_clone_doc_ptr, vl_child, pl_condition, vl_conditionid); |
| } |
| } |
| for (vector<xml_node<> *>::iterator vl_remove = vl_NodesToRemove.begin(); vl_remove != vl_NodesToRemove.end(); vl_remove++){ |
| ACTION_GUIFUNCTIONS("process_condition_node-> REMOVE]: [%s]", ((xml_node<> * )*vl_remove)->name()); |
| ((xml_node<> * )*vl_remove)->remove_all_nodes(); |
| } |
| |
| return(vl_result); |
| } |
| |
| //========================================================================= |
| // SUBROUTINES |
| //========================================================================= |
| |
| /////////////////////////////////////////////////////////// |
| // Function: is_valid_XML |
| // |
| // Purpose: |
| // Validate the XML with the given XSD |
| // |
| // Parameters: |
| // pl_xml_str - *in* <char * > - input XML string |
| // pl_schema_filename - *in* <char * > - input schema file name |
| // |
| // Return Value: |
| // Returns the result of validation. |
| // - VALID_XML : XML valid |
| // - ERROR_INVALID_XML : XML invalid with XSD parser |
| // - ERROR_XML_LOAD : the doc cannot be loaded or is not well-formed |
| // - ERROR_XML_ROOT_ERROR : the root element are not 'Widgets' |
| // - ERROR_XSD_LOAD : the schema cannot be loaded or is not well-formed |
| // - ERROR_XSD_CREATE_PARSER_CTX : unable to create a parser context for the schema |
| // - ERROR_XSD_SCHEMA : the schema itself is not valid |
| // - ERROR_XSD_CREATE_VALIDATION_CTX : unable to create a validation context for the schema |
| // |
| // Errors: |
| // - is_valid_XML: The XML doc cannot be loaded or is not well-formed: {<xml string>}! |
| // - is_valid_XML: The root element in the xml is '<act root>' instead of 'Widgets'! |
| // - is_valid_XML: The the schema cannot be loaded or is not well-formed[<schema filename>]! |
| // - is_valid_XML: The schema patch [<xsd:element name="Widgets" />] invalid! |
| // - is_valid_XML: Unable to create a parser context for the schema[<schema filename>]! |
| // - is_valid_XML: The schema itself is not valid[<schema filename>]! |
| // - is_valid_XML: unable to create a validation context for the schema[<schema filename>]! |
| // - is_valid_XML: Invalid XML {<xml string>} with schema [<schema filename>] - message: <error_message>! |
| // |
| // Detailed Comments: |
| // Validate the XML with the given XSD. |
| // |
| /////////////////////////////////////////////////////////// |
| int is_valid_XML(char * pl_xml_str, const char * pl_schema_filename) |
| { |
| int vl_ret = VALID_XML; |
| xmlInitParser(); |
| ACTION_GUIFUNCTIONS("is_valid_XML[pl_xml_str]->%s", pl_xml_str); |
| xmlDocPtr vl_doc = xmlParseMemory(pl_xml_str, measure(pl_xml_str)); |
| xmlDocPtr vl_schema_doc = NULL; |
| xmlSchemaPtr vl_schema = NULL; |
| xmlSchemaValidCtxtPtr vl_valid_ctxt = NULL; |
| xmlSchemaParserCtxtPtr vl_parser_ctxt = NULL; |
| if(vl_doc == NULL) { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"ERROR: is_valid_XML: The XML doc cannot be loaded or is not well-formed: {%s}!", pl_xml_str); |
| /* the doc cannot be loaded or is not well-formed */ |
| vl_ret = ERROR_XML_LOAD; |
| } else { |
| xmlNode * vl_root_element = NULL; |
| /*Get the root element node */ |
| vl_root_element = xmlDocGetRootElement(vl_doc); |
| if (xmlStrcmp(vl_root_element->name, (const xmlChar *) c_xml_root_name)) { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"ERROR: is_valid_XML: The root element in the xml is '%s' instead of '%s'!", (const char *)vl_root_element->name, c_xml_root_name); |
| /* the root element are not 'Widgets' */ |
| vl_ret = ERROR_XML_ROOT_ERROR; |
| } else { |
| ACTION_GUIFUNCTIONS("is_valid_XML[pl_schema_filename]->%s", pl_schema_filename); |
| vl_schema_doc = xmlReadFile(pl_schema_filename, NULL, XML_PARSE_NONET); |
| if (vl_schema_doc == NULL) { |
| /* the schema cannot be loaded or is not well-formed */ |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"ERROR: is_valid_XML: The the schema cannot be loaded or is not well-formed[%s]!", pl_schema_filename); |
| vl_ret = ERROR_XSD_LOAD; |
| } else { |
| vl_root_element = xmlDocGetRootElement(vl_schema_doc); |
| // Patch into -> <xsd:element name="Widgets" /> |
| xmlNodePtr vl_newnode = xmlNewTextChild (vl_root_element, (xmlNs *)NULL, (xmlChar *)c_xml_element, NULL); |
| xmlAttrPtr vl_newattr = NULL; |
| if(vl_newnode) { |
| vl_newattr = xmlNewProp (vl_newnode, (const xmlChar *)c_str_name, (const xmlChar *)c_xml_root_name); |
| } |
| if(vl_newnode == NULL || vl_newattr == NULL) { |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"ERROR: is_valid_XML: The schema patch [<xsd:%s %s=\"%s\" />] invalid!", c_xml_element, c_str_name, c_xml_root_name); |
| } |
| vl_parser_ctxt = xmlSchemaNewDocParserCtxt(vl_schema_doc); |
| if (vl_parser_ctxt == NULL) { |
| /* unable to create a parser context for the schema */ |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"ERROR: is_valid_XML: Unable to create a parser context for the schema[%s]!", pl_schema_filename); |
| vl_ret = ERROR_XSD_CREATE_PARSER_CTX; |
| } else { |
| vl_schema = xmlSchemaParse(vl_parser_ctxt); |
| if (vl_schema == NULL) { |
| /* the schema itself is not valid */ |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"ERROR: is_valid_XML: The schema itself is not valid[%s]!", pl_schema_filename); |
| vl_ret = ERROR_XSD_SCHEMA; |
| } else { |
| vl_valid_ctxt = xmlSchemaNewValidCtxt(vl_schema); |
| if (vl_valid_ctxt == NULL) { |
| /* unable to create a validation context for the schema */ |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"ERROR: is_valid_XML: unable to create a validation context for the schema[%s]!", pl_schema_filename); |
| vl_ret = ERROR_XSD_CREATE_VALIDATION_CTX; |
| } else { |
| int vl_is_valid = (xmlSchemaValidateDoc(vl_valid_ctxt, vl_doc) == 0); |
| /* force the return value to be non-negative on success */ |
| vl_ret = vl_is_valid ? VALID_XML : ERROR_INVALID_XML; |
| if(vl_ret == ERROR_INVALID_XML){ |
| char * vl_errorstr = (char *)&c_str_empty[0]; |
| xmlErrorPtr vl_error = xmlGetLastError(); |
| if(vl_error != NULL && vl_error->message != NULL) { |
| vl_errorstr = vl_error->message; |
| } |
| TTCN_Logger::log(TTCN_Logger::USER_UNQUALIFIED,"ERROR: is_valid_XML: Invalid XML {%s} with schema [%s] - message: %s!", pl_xml_str, pl_schema_filename, vl_errorstr); |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| if(vl_valid_ctxt != NULL) {xmlSchemaFreeValidCtxt(vl_valid_ctxt);}; |
| if(vl_schema != NULL) {xmlSchemaFree(vl_schema);}; |
| if(vl_parser_ctxt != NULL) {xmlSchemaFreeParserCtxt(vl_parser_ctxt);}; |
| if(vl_schema_doc != NULL) {xmlFreeDoc(vl_schema_doc);}; |
| if(vl_doc != NULL) {xmlFreeDoc(vl_doc);}; |
| xmlCleanupParser(); |
| return (vl_ret); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: measure |
| // |
| // Purpose: |
| // Measure string length |
| // |
| // Parameters: |
| // pl_ptr - *in* <const char * > - input string |
| // |
| // Return Value: |
| // Returns the string length. |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Measure string length. |
| // |
| /////////////////////////////////////////////////////////// |
| std::size_t measure(const char * pl_ptr) |
| { |
| return(internal::measure(pl_ptr)); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: compare |
| // |
| // Purpose: |
| // Compare strings |
| // |
| // Parameters: |
| // pl_p1 - *in* <const char * > - input string 1 |
| // pl_size1 - *in* <size_t> - input string 1 length |
| // pl_p2 - *in* <const char * > - input string 2 |
| // pl_size2 - *in* <size_t> - input string 2 length |
| // |
| // Return Value: |
| // Returns the result of compare ==true if equal. |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Compare two string. |
| // |
| /////////////////////////////////////////////////////////// |
| bool compare(const char * pl_p1, std::size_t pl_size1, const char * pl_p2, std::size_t pl_size2) |
| { |
| return(internal::compare(pl_p1, pl_size1, pl_p2, pl_size2, v_case_sensitive)); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: compare name |
| // |
| // Purpose: |
| // Compare strings |
| // |
| // Parameters: |
| // pl_p1 - *in* <const char * > - input string 1 with namespace |
| // pl_size1 - *in* <size_t> - input string 1 length |
| // pl_p2 - *in* <const char * > - input string 2 |
| // pl_size2 - *in* <size_t> - input string 2 length |
| // |
| // Return Value: |
| // Returns the result of compare_name ==true if equal. |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Compare two string without namespace <xxx:yyy /> tag. |
| // |
| /////////////////////////////////////////////////////////// |
| bool compare_name(const char * pl_p1, std::size_t pl_size1, const char * pl_p2, std::size_t pl_size2) |
| { |
| bool vl_ret = false; |
| #ifdef CLEAR_XML_NAMESPACE_ELEMENTS |
| vl_ret = internal::compare(pl_p1, pl_size1, pl_p2, pl_size2, v_case_sensitive); |
| #else |
| int vl_idxFrom = pl_size1-pl_size2; |
| if(0<=vl_idxFrom){ |
| vl_ret = internal::compare((pl_p1+vl_idxFrom), pl_size2, pl_p2, pl_size2, v_case_sensitive); |
| ACTION_GUIFUNCTIONS("compare_name(%s->%s):%d",(pl_p1+vl_idxFrom), pl_p2, vl_ret ); |
| } |
| #endif |
| return(vl_ret); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: is_expandable |
| // |
| // Purpose: |
| // The current node expandable? |
| // |
| // Parameters: |
| // pl_name - *in* <const char * > - input entity name |
| // pl_name_size - *in* <size_t> - input name string length |
| // |
| // Return Value: |
| // Returns ==true if the node name expandable. |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // The current node expandable? |
| // |
| /////////////////////////////////////////////////////////// |
| bool is_expandable(const char * pl_name, std::size_t pl_name_size) |
| { |
| bool vl_bret = false; |
| if (pl_name){ |
| if (pl_name_size == 0) { |
| pl_name_size = measure(pl_name); |
| } |
| if(compare_name(pl_name, pl_name_size, c_str_iterator, v_size_iterator) || |
| compare_name(pl_name, pl_name_size, c_str_externalvalue, v_size_externalvalue) || |
| compare_name(pl_name, pl_name_size, c_str_condition, v_size_condition)){ |
| vl_bret = true; |
| } |
| } |
| return(vl_bret); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: is_iterator_like |
| // |
| // Purpose: |
| // The current node iterator OR externalvalue? |
| // |
| // Parameters: |
| // pl_name - *in* <const char * > - input entity name |
| // pl_name_size - *in* <size_t> - input name string length |
| // |
| // Return Value: |
| // Returns ==true if the node name expandable. |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // The current node iterator OR externalvalue? |
| // |
| /////////////////////////////////////////////////////////// |
| bool is_iterator_like(const char * pl_name, std::size_t pl_name_size) |
| { |
| bool vl_bret = false; |
| if (pl_name){ |
| if (pl_name_size == 0) { |
| pl_name_size = measure(pl_name); |
| } |
| if(compare_name(pl_name, pl_name_size, c_str_iterator, v_size_iterator) || |
| compare_name(pl_name, pl_name_size, c_str_externalvalue, v_size_externalvalue)){ |
| vl_bret = true; |
| } |
| } |
| return(vl_bret); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: get_data_source |
| // |
| // Purpose: |
| // Get the data source |
| // |
| // Parameters: |
| // pl_expandable - *in* <xml_node<> * > - node pointer |
| // pl_element_out - *out* <char ** > - element pointer out |
| // pl_id_out - *out* <char ** > - id pointer out |
| // pl_ptcname_out - *out* <char ** > - ptc pointer out |
| // pl_source_out - *out* <char ** > - source pointer out |
| // |
| // Return Value: |
| // Returns ==true if no any error. |
| // |
| // Errors: |
| // - get_data_parameters: unknown attribute [<attribute name>=<attribute value>]! |
| // - get_data_parameters: invalid call!"); |
| // |
| // Detailed Comments: |
| // Get the data source. |
| // |
| /////////////////////////////////////////////////////////// |
| bool get_data_source( xml_node |