/****************************************************************************** * 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 ******************************************************************************/ /////////////////////////////////////////////////////////////////////////////// // // File: TCCTemplate_Functions.ttcn // Description: TCC Useful Functions: Template Functions // Rev: R36B // Prodnr: CNL 113 472 // /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // Module: TCCTemplate_Functions // // Purpose: // This module supports template handling // Originally for TitanSIM R2 needs it for substituting substrings in a // charstring template. // // Module Parameters: // - // // Module depends on: // - // // Current Owner: // Zsolt Szalai (EZSOSZA) // // Last Review Date: // - // // Comments: // Intruduction of ? regexp like behavior like \(x)? in our own pattern // couses many troubles, like with the current templatefunc signature it // can be impossible to determine the parameters(using 2 ? pattern) and // lookup may need much more and complicated additions or rewrite that // we may want at that time; // /////////////////////////////////////////////////////////////////////////////// module TCCTemplate_Functions { // import from TCCConversion_Functions all; import from TCCFileIO_Functions all; modulepar{ charstring TCCTemplate_opentoken := "$("; charstring TCCTemplate_closetoken := ")"; } type function templatefunc(in charstringList pl_params) runs on self return charstring; type record TCCSubstitution { charstring patt, charstring string, templatefunc func optional } type record of TCCSubstitution TCCSubstitutionList; type record of charstring charstringList; group PublicFunctions{ /////////////////////////////////////////////////////////////////////////////// // Function: f_Template_substitutetemplate // // Purpose: // Makes the substitutions according to the dictonary given // // Parameters: // pl_dict - *in* *TCCSubstitutionList* - dictionary // pl_string - *in* *charstring* - string to substitute in // // Return Value: // charstring - substituted string // // Errors: // - // // Detailed description: // - // /////////////////////////////////////////////////////////////////////////////// function f_Template_substitutetemplate(in TCCSubstitutionList pl_dict, in charstring pl_string) return charstring{ var charstring ret := pl_string; //log("original template:",ret,"\n"); // heuristic implementation ///////////////////////////////////////////////////////////////////////// // searches for every pattern /* for (var integer i := 0; i