Attention is currently required from: pespin.
1 comment:
File asterisk/AMI_Functions.ttcn:
Patch Set #2, Line 109: var integer pos := f_strstr(str, ": ", 0);
Looks like you could use TITAN's TEXT encoder for doing this:
```
type record AMI_Field {
charstring key,
charstring val
} with {
encode "TEXT"
variant "SEPARATOR(':')"
};
type set of AMI_Field AMI_Msg with {
encode "TEXT"
variant "SEPARATOR('\r\n')"
variant "END('\r\n')"
};
external function enc_AMI_Msg(in AMI_Msg msg) return charstring
with { extension "prototype(convert) encode(TEXT)" }
external function dec_AMI_Msg(in charstring stream) return AMI_Msg
with { extension "prototype(convert) decode(TEXT)" }
```
See https://gitlab.eclipse.org/eclipse/titan/titan.core/-/blob/master/usrguide/referenceguide/4-ttcn3_language_extensions.adoc?ref_type=heads#user-content-text-encoder-and-decoder.
Not saying you have to do it this way, but if we can offload some work to TITAN - why not.
I have a small self-test:
```
private type component dummy_CT { };
testcase TC_tuwat() runs on dummy_CT {
var AMI_Msg msg := {
{ "field1", "value1" },
{ "field2", "value2" },
{ "field3", "value3" }
};
var charstring text := enc_AMI_Msg(msg);
log("AMI msg encoded: ", text);
var AMI_Msg msg_dec := dec_AMI_Msg(text);
log("AMI msg decoded: ", msg_dec);
}
```
and here is the output it produces:
```
MTC@LEGION: AMI msg encoded: "field1:value1\r\nfield2:value2\r\nfield3:value3\r\n"
MTC@LEGION: AMI msg decoded: { { key := "field1", val := "value1" }, { key := "field2", val := "value2" }, { key := "field3", val := "value3" } }
```
To view, visit change 36594. To unsubscribe, or for help writing mail filters, visit settings.