pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38025?usp=email )
Change subject: Misc_Helpers: Introduce API helper f_str_startswith
......................................................................
Misc_Helpers: Introduce API helper f_str_startswith
Counterpart of f_str_endswith(), this API is usually available in
several programming languages like python, and it's handy to have since
it's usually used and hence dev doesn't need to think on how to
implement it using regexp, etc.
This API will be used in a follow-up patch implementing Prometheus
metrics checker module.
Change-Id: Iad392ac652714a54a25954ea697f082d55772aa8
---
M library/Misc_Helpers.ttcn
1 file changed, 10 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
osmith: Looks good to me, approved
diff --git a/library/Misc_Helpers.ttcn b/library/Misc_Helpers.ttcn
index a742b0b..967c8d1 100644
--- a/library/Misc_Helpers.ttcn
+++ b/library/Misc_Helpers.ttcn
@@ -79,6 +79,16 @@
return count;
}
+/* Return true if str starts exactly with token: */
+function f_str_startswith(charstring str, charstring token) return boolean
+{
+ if (lengthof(str) < lengthof(token)) {
+ return false;
+ }
+ var charstring str_start := substr(str, 0, lengthof(token));
+ return str_start == token;
+}
+
/* Return true if str ends exactly with token: */
function f_str_endswith(charstring str, charstring token) return boolean
{
--
To view, visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38025?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Iad392ac652714a54a25954ea697f082d55772aa8
Gerrit-Change-Number: 38025
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>