diff options
Diffstat (limited to '')
-rw-r--r-- | src/functionreplace.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/functionreplace.cpp b/src/functionreplace.cpp index 589ef55..6cf455e 100644 --- a/src/functionreplace.cpp +++ b/src/functionreplace.cpp | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | #include <bu/plugger.h> | 3 | #include <bu/plugger.h> |
4 | PluginInterface3( pluginFunctionReplace, replace, FunctionReplace, Function, | 4 | PluginInterface3( pluginFunctionReplace, replace, FunctionReplace, Function, |
5 | "Mike Buland", 0, 1 ); | 5 | "Mike Buland", 0, 1 ); |
6 | 6 | ||
7 | FunctionReplace::FunctionReplace() | 7 | FunctionReplace::FunctionReplace() |
8 | { | 8 | { |
@@ -14,38 +14,38 @@ FunctionReplace::~FunctionReplace() | |||
14 | 14 | ||
15 | Bu::String FunctionReplace::getName() const | 15 | Bu::String FunctionReplace::getName() const |
16 | { | 16 | { |
17 | return "replace"; | 17 | return "replace"; |
18 | } | 18 | } |
19 | 19 | ||
20 | Variable FunctionReplace::call( Variable &input, VarList lParams ) | 20 | Variable FunctionReplace::call( Variable &input, VarList lParams ) |
21 | { | 21 | { |
22 | Bu::String sA, sB; | 22 | Bu::String sA, sB; |
23 | sA = lParams.first().getString(); | 23 | sA = lParams.first().getString(); |
24 | sB = lParams.last().getString(); | 24 | sB = lParams.last().getString(); |
25 | switch( input.getType() ) | 25 | switch( input.getType() ) |
26 | { | 26 | { |
27 | case Variable::typeString: | 27 | case Variable::typeString: |
28 | { | 28 | { |
29 | Variable vOut( input.getString().replace( sA, sB ) ); | 29 | Variable vOut( input.getString().replace( sA, sB ) ); |
30 | return vOut; | 30 | return vOut; |
31 | } | 31 | } |
32 | break; | 32 | break; |
33 | 33 | ||
34 | case Variable::typeList: | 34 | case Variable::typeList: |
35 | { | 35 | { |
36 | Variable vOut( Variable::typeList ); | 36 | Variable vOut( Variable::typeList ); |
37 | for( VarList::iterator i = input.begin(); i; i++ ) | 37 | for( VarList::iterator i = input.begin(); i; i++ ) |
38 | { | 38 | { |
39 | vOut.append( (*i).getString().replace( sA, sB ) ); | 39 | vOut.append( (*i).getString().replace( sA, sB ) ); |
40 | } | 40 | } |
41 | return vOut; | 41 | return vOut; |
42 | } | 42 | } |
43 | break; | 43 | break; |
44 | 44 | ||
45 | default: | 45 | default: |
46 | break; | 46 | break; |
47 | } | 47 | } |
48 | throw Bu::ExceptionBase( | 48 | throw Bu::ExceptionBase( |
49 | "replace does not work on non-string or non-list types."); | 49 | "replace does not work on non-string or non-list types."); |
50 | } | 50 | } |
51 | 51 | ||