Added reverse() function to strings.bif.

Closes #969.
This commit is contained in:
Yun Zheng Hu 2013-03-16 17:09:29 +01:00 committed by Robin Sommer
parent 6b0552fa4f
commit 9a88dc500a
5 changed files with 44 additions and 1 deletions

View file

@ -1122,3 +1122,16 @@ function hexdump%(data_str: string%) : string
return result;
%}
## Returns a reversed copy of the string
##
## str: The string to reverse.
##
## Returns: A reversed copy of *str*
##
function reverse%(str: string%) : string
%{
string s = string((const char*)str->Bytes(), str->Len());
reverse(s.begin(), s.end());
return new StringVal(s.length(), (const char*)s.c_str());
%}