diff options
Diffstat (limited to '')
-rw-r--r-- | src/functiontostring.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/functiontostring.cpp b/src/functiontostring.cpp new file mode 100644 index 0000000..0c04091 --- /dev/null +++ b/src/functiontostring.cpp | |||
@@ -0,0 +1,50 @@ | |||
1 | #include "functiontostring.h" | ||
2 | |||
3 | #include <stdlib.h> | ||
4 | #include <bu/sio.h> | ||
5 | using namespace Bu; | ||
6 | |||
7 | FunctionToString::FunctionToString() | ||
8 | { | ||
9 | } | ||
10 | |||
11 | FunctionToString::~FunctionToString() | ||
12 | { | ||
13 | } | ||
14 | |||
15 | Bu::FString FunctionToString::getName() const | ||
16 | { | ||
17 | return "toString"; | ||
18 | } | ||
19 | |||
20 | Variable FunctionToString::call( Variable &input, VarList lParams ) | ||
21 | { | ||
22 | Bu::FString sStr; | ||
23 | Bu::FString sSep; | ||
24 | if( lParams.getSize() == 0 ) | ||
25 | { | ||
26 | sSep = " "; | ||
27 | } | ||
28 | else | ||
29 | { | ||
30 | sSep = lParams.first().getString(); | ||
31 | } | ||
32 | switch( input.getType() ) | ||
33 | { | ||
34 | case Variable::typeString: | ||
35 | return input; | ||
36 | |||
37 | case Variable::typeList: | ||
38 | for( VarList::iterator i = input.begin(); i; i++ ) | ||
39 | { | ||
40 | if( i != input.begin() ) | ||
41 | sStr += sSep; | ||
42 | sStr += (*i).getString(); | ||
43 | } | ||
44 | return Variable( sStr ); | ||
45 | |||
46 | default: | ||
47 | return Variable( input.getString() ); | ||
48 | } | ||
49 | } | ||
50 | |||