mirror of https://github.com/Icinga/icinga2.git
parent
9141855454
commit
b58ddfb158
|
@ -879,7 +879,7 @@ type objects are made available using global variables which match the type's na
|
|||
The type object's `prototype` property can be used to find out which methods a certain type
|
||||
supports:
|
||||
|
||||
/* This returns: ["contains","find","len","lower","replace","reverse","split","substr","to_string","upper"] */
|
||||
/* This returns: ["contains","find","len","lower","replace","reverse","split","substr","to_string","trim","upper"] */
|
||||
keys(String.prototype)
|
||||
|
||||
Additional documentation on type methods is available in the
|
||||
|
|
|
@ -508,6 +508,14 @@ Signature:
|
|||
|
||||
Returns a copy of the string in reverse order.
|
||||
|
||||
### <a id="string-trim"></a> String#trim
|
||||
|
||||
Signature:
|
||||
|
||||
function trim();
|
||||
|
||||
Removes trailing whitespaces and returns the string.
|
||||
|
||||
## <a id="object-type"></a> Object type
|
||||
|
||||
This is the base type for all types in the Icinga application.
|
||||
|
|
|
@ -133,6 +133,13 @@ static String StringReverse(void)
|
|||
return self.Reverse();
|
||||
}
|
||||
|
||||
static String StringTrim(void)
|
||||
{
|
||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||
String self = vframe->Self;
|
||||
return self.Trim();
|
||||
}
|
||||
|
||||
Object::Ptr String::GetPrototype(void)
|
||||
{
|
||||
static Dictionary::Ptr prototype;
|
||||
|
@ -149,6 +156,7 @@ Object::Ptr String::GetPrototype(void)
|
|||
prototype->Set("contains", new Function(WrapFunction(StringContains), true));
|
||||
prototype->Set("replace", new Function(WrapFunction(StringReplace), true));
|
||||
prototype->Set("reverse", new Function(WrapFunction(StringReverse), true));
|
||||
prototype->Set("trim", new Function(WrapFunction(StringTrim), true));
|
||||
}
|
||||
|
||||
return prototype;
|
||||
|
|
Loading…
Reference in New Issue